From 6a17c8768bc5c5cda7f1ed26da550fb2da9d21f7 Mon Sep 17 00:00:00 2001 From: Austin Date: Thu, 14 Dec 2017 16:20:30 -0800 Subject: [PATCH] Adds a test for out integration form --- hc/front/tests/test_add_pagertree.py | 29 ++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 hc/front/tests/test_add_pagertree.py diff --git a/hc/front/tests/test_add_pagertree.py b/hc/front/tests/test_add_pagertree.py new file mode 100644 index 00000000..a1f100f5 --- /dev/null +++ b/hc/front/tests/test_add_pagertree.py @@ -0,0 +1,29 @@ +from hc.api.models import Channel +from hc.test import BaseTestCase + + +class AddVictorOpsTestCase(BaseTestCase): + url = "/integrations/add_pagertree/" + + def test_instructions_work(self): + self.client.login(username="alice@example.org", password="password") + r = self.client.get(self.url) + self.assertContains(r, "to create a PagerTree incident when a check goes down, and resolve it when a check goes back up.") + + def test_it_works(self): + form = {"value": "http://example.org"} + + self.client.login(username="alice@example.org", password="password") + r = self.client.post(self.url, form) + self.assertRedirects(r, "/integrations/") + + c = Channel.objects.get() + self.assertEqual(c.kind, "pagertree") + self.assertEqual(c.value, "http://example.org") + + def test_it_rejects_bad_url(self): + form = {"value": "not an URL"} + + self.client.login(username="alice@example.org", password="password") + r = self.client.post(self.url, form) + self.assertContains(r, "Enter a valid URL")