<commit_before># -*- coding: utf-8 -*-
from __future__ import unicode_literals
from copy import deepcopy

from django.conf import settings
from django.test import TestCase

from channels.backends.hipchat import HipChatChannel
from channels.exceptions import HttpError, ImproperlyConfigured


channels = settings.CHANNELS["CHANNELS"]
config = channels["channels.backends.hipchat.HipChatChannel"]


class HipChatChannelTestCase(TestCase):
    def setUp(self):
        self.channel = HipChatChannel(config)

    def test_init(self):
        with self.assertRaises(ImproperlyConfigured):
            HipChatChannel({})

    def test_send(self):
        self.channel.send("Test message")

    def test_send_fail(self):
        conf = deepcopy(config)
        conf["TOKEN"] = "token"
        channel = HipChatChannel(conf)

        with self.assertRaises(HttpError):
            channel.send("Test message", fail_silently=False)

        channel.send("Test message", fail_silently=True)<commit_msg>Update HipChatChannelTestCase<commit_after># -*- coding: utf-8 -*-
from __future__ import unicode_literals
from copy import deepcopy

from django.conf import settings
from django.test import TestCase

from channels.backends.hipchat import HipChatChannel
from channels.exceptions import HttpError, ImproperlyConfigured


channels = settings.CHANNELS["CHANNELS"]
config = channels["channels.backends.hipchat.HipChatChannel"]


class HipChatChannelTestCase(TestCase):
    def setUp(self):
        self.channel = HipChatChannel(config)

    def test_init(self):
        with self.assertRaises(ImproperlyConfigured):
            HipChatChannel({})

        with self.assertRaises(ImproperlyConfigured):
            conf = deepcopy(config)
            conf["COLOR"] = "blue"
            HipChatChannel(conf)

        with self.assertRaises(ImproperlyConfigured):
            conf = deepcopy(config)
            conf["NOTIFY"] = "true"
            HipChatChannel(conf)

    def test_send(self):
        self.channel.send("Test message")

    def test_send_fail(self):
        conf = deepcopy(config)
        conf["TOKEN"] = "token"
        channel = HipChatChannel(conf)

        with self.assertRaises(HttpError):
            channel.send("Test message", fail_silently=False)

        channel.send("Test message", fail_silently=True)
{'fraction_non_alphanumeric': 0.09659335920655455, 'fraction_numerical': 0.0008624407072013799, 'mean_word_length': 3.427480916030534, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '5091545', 'n_tokens_mistral': 669, 'n_tokens_neox': 638, 'n_words': 140}