from hc.api.models import Channel
from hc.test import BaseTestCase


class AddOpsGenieTestCase(BaseTestCase):
    url = "/integrations/add_opsgenie/"

    def test_instructions_work(self):
        self.client.login(username="alice@example.org", password="password")
        r = self.client.get(self.url)
        self.assertContains(r, "incident management system")

    def test_it_works(self):
        form = {"value": "123456"}

        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, "opsgenie")
        self.assertEqual(c.value, "123456")

    def test_it_trims_whitespace(self):
        form = {"value": "   123456   "}

        self.client.login(username="alice@example.org", password="password")
        self.client.post(self.url, form)

        c = Channel.objects.get()
        self.assertEqual(c.value, "123456")

@@ -333,34 +333,49 @@
 r, %22
-incident management system
+escalation policies and incident tracking
 %22)%0A%0A

Fix test.