<commit_before>from django.contrib.auth.models import User
from django.test import TestCase
from hc.api.models import Channel


class AddChannelTestCase(TestCase):

    def setUp(self):
        self.alice = User(username="alice")
        self.alice.set_password("password")
        self.alice.save()

    def test_it_works(self):
        url = "/integrations/add/"
        form = {"kind": "email", "value": "<EMAIL>"}

        self.client.login(username="alice", password="password")
        r = self.client.post(url, form)

        assert r.status_code == 302
        assert Channel.objects.count() == 1

    def test_it_rejects_bad_kind(self):
        url = "/integrations/add/"
        form = {"kind": "dog", "value": "Lassie"}

        self.client.login(username="alice", password="password")
        r = self.client.post(url, form)

        assert r.status_code == 400, r.status_code

    def test_instructions_work(self):
        self.client.login(username="alice", password="password")
        for frag in ("email", "webhook", "pd", "pushover", "slack", "hipchat"):
            url = "/integrations/add_%s/" % frag
            r = self.client.get(url)
            self.assertContains(r, "Integration Settings", status_code=200)<commit_msg>Fix tests when Pushover is not configured<commit_after>from django.conf import settings
from django.contrib.auth.models import User
from django.test import TestCase
from hc.api.models import Channel


class AddChannelTestCase(TestCase):

    def setUp(self):
        self.alice = User(username="alice")
        self.alice.set_password("password")
        self.alice.save()

        settings.PUSHOVER_API_TOKEN = "bogus_token"
        settings.PUSHOVER_SUBSCRIPTION_URL = "bogus_url"

    def test_it_works(self):
        url = "/integrations/add/"
        form = {"kind": "email", "value": "<EMAIL>"}

        self.client.login(username="alice", password="password")
        r = self.client.post(url, form)

        assert r.status_code == 302
        assert Channel.objects.count() == 1

    def test_it_rejects_bad_kind(self):
        url = "/integrations/add/"
        form = {"kind": "dog", "value": "Lassie"}

        self.client.login(username="alice", password="password")
        r = self.client.post(url, form)

        assert r.status_code == 400, r.status_code

    def test_instructions_work(self):
        self.client.login(username="alice", password="password")
        for frag in ("email", "webhook", "pd", "pushover", "slack", "hipchat"):
            url = "/integrations/add_%s/" % frag
            r = self.client.get(url)
            self.assertContains(r, "Integration Settings", status_code=200)
{'fraction_non_alphanumeric': 0.14081862561021405, 'fraction_numerical': 0.007510326699211416, 'mean_word_length': 2.935007385524372, 'pattern_counts': {'":': 8, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3291559', 'n_tokens_mistral': 844, 'n_tokens_neox': 804, 'n_words': 173}