<commit_before>from django.test import TestCase, Client, override_settings
from announce.models import Group, Person
from announce.bellman import Bellman

from mock import patch


def make_post(user_name='bob', user_id='test_id', token='1234abc', text=''):
    return {'token': token,
            'user_name': user_name,
            'user_id': user_id,
            'text': text,
            }


@override_settings(SLACK_TOKEN='1234abc')
class SecurityTestCase(TestCase):
    def test_post_check(self):
        c = Client()
        response = c.get('/announce/', {'token': '1234abc'})
        self.assertFalse(response.content)
        self.assertTrue(response.status_code, 400)

    def test_token_check(self):
        c = Client()
        response = c.post('/announce/',
                          make_post(token='fake')
                          )
        self.assertFalse(response.content)
        self.assertTrue(response.status_code, 400)


@override_settings(SLACK_TOKEN='1234abc',
                   SLACK_INCOMING_WEBHOOK_URL='')
class AnnounceTestCase(TestCase):
    def setUp(self):
        Group.objects.create(group_name='test_group')
        Person.objects.create(person_name='bob', person_id='test_id')
        p1 = Person(person_name='foo', person_id='1')
        p1.save()
        p2 = Person(person_name='bar', person_id='2')<commit_msg>fixing tests<commit_after>from django.test import TestCase, Client, override_settings
from announce.models import Group, Person
from announce.bellman import Bellman

from mock import patch


def make_post(user_name='bob', user_id='test_id', token='1234abc', text=''):
    return {'token': token,
            'user_name': user_name,
            'user_id': user_id,
            'text': text,
            }


@override_settings(SLACK_TOKEN='1234abc')
class SecurityTestCase(TestCase):
    def test_post_check(self):
        c = Client()
        response = c.get('/announce/', {'token': '1234abc'})
        self.assertEqual(response.content, 'Did not receive an HTTP POST.')
        self.assertTrue(response.status_code, 400)

    def test_token_check(self):
        c = Client()
        response = c.post('/announce/',
                          make_post(token='fake')
                          )
        self.assertEqual(response.content, 'Received an invalid token.')
        self.assertTrue(response.status_code, 400)


@override_settings(SLACK_TOKEN='1<PASSWORD>',
                   SLACK_INCOMING_WEBHOOK_URL='')
class AnnounceTestCase(TestCase):
    def setUp(self):
        Group.objects.create(group_name='test_group')
        Person.objects.create(person_name='bob', person_id='test_id')
        p1 = Person(person_name='foo', person_id='1')
        p1.save()
        p2 = Person(person_name='bar', person_id='2')
{'fraction_non_alphanumeric': 0.12689257390050468, 'fraction_numerical': 0.018385003604902667, 'mean_word_length': 2.8974719101123596, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, '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': '2243332', 'n_tokens_mistral': 863, 'n_tokens_neox': 821, 'n_words': 156}