@ -1,24 +0,0 @@ | |||||
import json | |||||
from hc.api.models import Channel | |||||
from hc.test import BaseTestCase | |||||
from mock import patch | |||||
class ChannelModelTestCase(BaseTestCase): | |||||
@patch("hc.api.models.requests.post") | |||||
def test_it_refreshes_hipchat_access_token(self, mock_post): | |||||
mock_post.return_value.json.return_value = {"expires_in": 100} | |||||
value = json.dumps({ | |||||
"oauthId": "foo", | |||||
"oauthSecret": "bar" | |||||
}) | |||||
channel = Channel(kind="hipchat", project=self.project, value=value) | |||||
channel.refresh_hipchat_access_token() | |||||
# It should request a token using a correct tokenUrl | |||||
mock_post.assert_called() | |||||
self.assertTrue("expires_at" in channel.value) |
@ -1,37 +0,0 @@ | |||||
from hc.api.models import Channel | |||||
from hc.test import BaseTestCase | |||||
from mock import patch | |||||
class AddHipChatTestCase(BaseTestCase): | |||||
url = "/integrations/add_hipchat/" | |||||
def test_instructions_work(self): | |||||
self.client.login(username="[email protected]", password="password") | |||||
r = self.client.get(self.url) | |||||
self.assertContains(r, "appropriate HipChat room") | |||||
def test_it_returns_capabilities(self): | |||||
r = self.client.get("/integrations/hipchat/capabilities/") | |||||
self.assertContains(r, "installedUrl") | |||||
@patch("hc.front.views.Channel.refresh_hipchat_access_token") | |||||
@patch("hc.front.views.requests.get") | |||||
def test_it_adds_channel(self, mock_get, mock_refresh): | |||||
mock_get.return_value.json.return_value = { | |||||
"oauthId": "test-id" | |||||
} | |||||
mock_get.return_value.text = "{}" | |||||
self.client.login(username="[email protected]", password="password") | |||||
s = "https://api.hipchat.com/foo" | |||||
r = self.client.post(self.url + "?installable_url=%s" % s) | |||||
self.assertEqual(r.status_code, 302) | |||||
self.assertTrue(mock_refresh.called) | |||||
c = Channel.objects.get() | |||||
self.assertEqual(c.kind, "hipchat") | |||||
self.assertEqual(c.value, "{}") | |||||
self.assertEqual(c.project, self.project) |
@ -1,96 +0,0 @@ | |||||
{% extends "base.html" %} | |||||
{% load humanize static hc_extras %} | |||||
{% block title %}Notification Channels - {% site_name %}{% endblock %} | |||||
{% block content %} | |||||
<div class="row"> | |||||
<div class="col-sm-12"> | |||||
<h1>HipChat</h1> | |||||
<div class="jumbotron"> | |||||
<p>If your team uses <a href="https://www.hipchat.com/">HipChat</a>, | |||||
you can set up {% site_name %} to post status updates directly to an | |||||
appropriate HipChat room.</p> | |||||
<div class="text-center"> | |||||
{% csrf_token %} | |||||
<a href="{{ install_url }}" class="btn btn-lg btn-default"> | |||||
<img class="ai-icon" src="{% static 'img/integrations/hipchat.png' %}" alt="HipChat" /> | |||||
Connect HipChat | |||||
</a> | |||||
</div> | |||||
</div> | |||||
<h2>Setup Guide</h2> | |||||
<div class="row ai-step"> | |||||
<div class="col-sm-6"> | |||||
<span class="step-no">1</span> | |||||
<p> | |||||
After | |||||
clicking on "Connect HipChat", you will be | |||||
asked to log into HipChat. | |||||
</p> | |||||
</div> | |||||
<div class="col-sm-6"> | |||||
<img | |||||
class="ai-guide-screenshot" | |||||
alt="Screenshot" | |||||
src="{% static 'img/integrations/setup_hipchat_1.png' %}"> | |||||
</div> | |||||
</div> | |||||
<div class="row ai-step"> | |||||
<div class="col-sm-6"> | |||||
<span class="step-no">2</span> | |||||
<p> | |||||
Next, HipChat will let you select the chat room | |||||
for receiving {% site_name %} notifications. | |||||
</p> | |||||
</div> | |||||
<div class="col-sm-6"> | |||||
<img | |||||
class="ai-guide-screenshot" | |||||
alt="Screenshot" | |||||
src="{% static 'img/integrations/setup_hipchat_2.png' %}"> | |||||
</div> | |||||
</div> | |||||
<div class="row ai-step"> | |||||
<div class="col-sm-6"> | |||||
<span class="step-no">3</span> | |||||
<p> | |||||
Next, HipChat will show you the permissions | |||||
requested by {% site_name %}. There's only one permission | |||||
needed: "Send Notification". | |||||
</p> | |||||
</div> | |||||
<div class="col-sm-6"> | |||||
<img | |||||
class="ai-guide-screenshot" | |||||
alt="Screenshot" | |||||
src="{% static 'img/integrations/setup_hipchat_3.png' %}"> | |||||
</div> | |||||
</div> | |||||
<div class="row ai-step"> | |||||
<div class="col-sm-6"> | |||||
<span class="step-no">4</span> | |||||
<p> | |||||
That is all! You will now be redirected back to | |||||
"Integrations" page on {% site_name %} and see | |||||
the new integration! | |||||
</p> | |||||
</div> | |||||
<div class="col-sm-6"> | |||||
<img | |||||
class="ai-guide-screenshot" | |||||
alt="Screenshot" | |||||
src="{% static 'img/integrations/setup_hipchat_4.png' %}"> | |||||
</div> | |||||
</div> | |||||
</div> | |||||
</div> | |||||
{% endblock %} |
@ -1,23 +0,0 @@ | |||||
{% load hc_extras static %} | |||||
{ | |||||
"name": "{% site_name %}", | |||||
"description": "Get Notified When Your Cron Jobs Fail", | |||||
"key": "io.healthchecks.hipchat", | |||||
"links": { | |||||
"homepage": "{% site_root %}", | |||||
"self": "{% site_root %}{% url 'hc-hipchat-capabilities' %}" | |||||
}, | |||||
"capabilities": { | |||||
"installable": { | |||||
"allowGlobal": false, | |||||
"allowRoom": true, | |||||
"installedUrl": "{% site_root %}{% url 'hc-add-hipchat'%}" | |||||
}, | |||||
"hipchatApiConsumer": { | |||||
"avatar": "{% site_root %}{% static 'img/logo-512-green.png' %}", | |||||
"scopes": [ | |||||
"send_notification" | |||||
] | |||||
} | |||||
} | |||||
} |
@ -1,55 +0,0 @@ | |||||
{% load hc_extras humanize static %} | |||||
{ | |||||
"message": "“{{ check.name_then_code|escapejs }}” is {{ check.status|upper }}.", | |||||
{% if check.status == "up" %} | |||||
"color": "green", | |||||
{% else %} | |||||
"color": "red", | |||||
{% endif %} | |||||
"card": { | |||||
"style": "application", | |||||
"url": "{% site_root %}{% url 'hc-log' check.code %}", | |||||
"format": "medium", | |||||
"id": "{{ check.code }}", | |||||
"title": "{{ check.name_then_code|escapejs }}", | |||||
"icon": { | |||||
{% if check.status == "up" %} | |||||
"url": "{% site_root %}{% static 'img/up.png' %}" | |||||
{% else %} | |||||
"url": "{% site_root %}{% static 'img/down.png' %}" | |||||
{% endif %} | |||||
}, | |||||
"attributes": [ | |||||
{% if check.kind == "simple" %} | |||||
{"label": "Period", | |||||
"value": {"label": "{{ check.timeout|hc_duration }}"} | |||||
}, | |||||
{% elif check.kind == "cron" %} | |||||
{"label": "Schedule", | |||||
"value": {"label": "{{ check.schedule|escapejs }}"} | |||||
}, | |||||
{% endif %} | |||||
{"label": "Last Ping", | |||||
{% if check.last_ping %} | |||||
"value": {"label": "{{ check.last_ping|naturaltime }}"} | |||||
{% else %} | |||||
"value": {"label": "Never"} | |||||
{% endif %} | |||||
}, | |||||
{% if check.tags_list %} | |||||
{"label": "Tags", | |||||
"value": {"label": "{{ check.tags_list|join:", " }}"} | |||||
}, | |||||
{% endif %} | |||||
{"label": "Total Pings", | |||||
"value": {"label": "{{ check.n_pings }}"} | |||||
} | |||||
], | |||||
"activity": { | |||||
"html": "“{{ check.name_then_code|escapejs }}” is {{ check.status|upper }}." | |||||
} | |||||
} | |||||
} |