<commit_before>import falcon
from app.utils.testing import APITestCase


VALID_DATA = {
    'email': '<EMAIL>',
    'password': '<PASSWORD>'
}


class UserResourceTestCase(APITestCase):

    def test_create_a_user(self):
        body = self.simulate_post('/user', VALID_DATA)
        self.assertEqual(self.srmock.status, falcon.HTTP_201)
        self.assertNotEqual(len(body['token']), 0)

    def test_create_a_dup_user(self):
        self.simulate_post('/user', VALID_DATA)
        self.assertEqual(self.srmock.status, falcon.HTTP_201)

        self.simulate_post('/user', VALID_DATA)
        self.assertEqual(self.srmock.status, falcon.HTTP_409)<commit_msg>Test invalid requests<commit_after>import falcon
from app.utils.testing import APITestCase


VALID_DATA = {
    'email': '<EMAIL>',
    'password': '<PASSWORD>'
}

INVALID_DATA = {
    'MISSING_EMAIL': {
        'password': '<PASSWORD>'
    },
    'BAD_EMAIL': {
        'email': 'not an email',
        'password': '<PASSWORD>'
    },
    'MISSING_PASSWORD': {
        'email': '<EMAIL>'
    },
    'BAD_PASSWORD': {
        'email': '<EMAIL>',
        'password': '<PASSWORD>'
    }
}


class UserResourceTestCase(APITestCase):

    def test_create_a_user(self):
        body = self.simulate_post('/user', VALID_DATA)
        self.assertEqual(self.srmock.status, falcon.HTTP_201)
        self.assertNotEqual(len(body['token']), 0)

    def test_create_a_dup_user(self):
        self.simulate_post('/user', VALID_DATA)
        self.assertEqual(self.srmock.status, falcon.HTTP_201)

        self.simulate_post('/user', VALID_DATA)
        self.assertEqual(self.srmock.status, falcon.HTTP_409)

    def test_invalid_create_a_user(self):
        self.simulate_post('/user', INVALID_DATA['MISSING_EMAIL'])
        self.assertEqual(self.srmock.status, falcon.HTTP_400)

        self.simulate_post('/user', INVALID_DATA['BAD_EMAIL'])
        self.assertEqual(self.srmock.status, falcon.HTTP_400)

        self.simulate_post('/user', INVALID_DATA['MISSING_PASSWORD'])
        self.assertEqual(self.srmock.status, falcon.HTTP_400)

        self.simulate_post('/user', INVALID_DATA['BAD_PASSWORD'])
        self.assertEqual(self.srmock.status, falcon.HTTP_400)
{'fraction_non_alphanumeric': 0.141500904159132, 'fraction_numerical': 0.014466546112115732, 'mean_word_length': 3.4437751004016066, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 12, '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': '3694435', 'n_tokens_mistral': 782, 'n_tokens_neox': 743, 'n_words': 102}