<commit_before>from fortunate import models, views

from fortunate.tests.base import Base

class ViewsTest(Base):
    
    fortunes = list('abcdefg')

    def set_fortune(self, *args, **kwargs):
        payload = kwargs
        response = self.client.post('/fortune/', data=payload)
        return response                

    def test_token_get(self):
        response = self.client.get('/token/')
        self.assert200(response)
        self.assertEqual(len(response.json['token']), 16)

    def test_fortune_post(self):
        response = self.client.get('/token/')
        result = self.set_fortune(token=response.json['token'], fortune=self.fortunes[0])

        self.assert200(result)
        self.assertEqual('a', result.json['fortune'])

        result = self.set_fortune(token=response.json['token'], fortune=self.fortunes[1])
        self.assert200(result)


    def test_fortune_post_empty(self):
        response = self.client.get('/token/')
        result = self.set_fortune(token=response.json['token'])

        self.assert400(result)
        self.assertTrue('Required' in result.json['message'])

    def test_fortune_post_invalid_token(self):
        result = self.set_fortune(token='x', fortune='x')
        self.assert400(result)
        self.assertTrue('Invalid' in result.json['message'])

    def test_fortune_get(self):
        response = self.client.get('/token/')
        result = self.set_fortune(token=response.json['token'], fortune=self.fortunes[0])
        fortune = self.client.get('/fortune/', data={'token': response.json['token']})
        
        self.assert200(fortune)
        self.assertEqual('a', fortune.json['fortune'])<commit_msg>Added one more assert for existing user<commit_after>from fortunate import models, views

from fortunate.tests.base import Base

class ViewsTest(Base):
    
    fortunes = list('abcdefg')

    def set_fortune(self, *args, **kwargs):
        payload = kwargs
        response = self.client.post('/fortune/', data=payload)
        return response                

    def test_token_get(self):
        response = self.client.get('/token/')
        self.assert200(response)
        self.assertEqual(len(response.json['token']), 16)

        response = self.client.get('/token/')
        self.assert200(response)

    def test_fortune_post(self):
        response = self.client.get('/token/')
        result = self.set_fortune(token=response.json['token'], fortune=self.fortunes[0])

        self.assert200(result)
        self.assertEqual('a', result.json['fortune'])

        result = self.set_fortune(token=response.json['token'], fortune=self.fortunes[1])
        self.assert200(result)

    def test_fortune_post_empty(self):
        response = self.client.get('/token/')
        result = self.set_fortune(token=response.json['token'])

        self.assert400(result)
        self.assertTrue('Required' in result.json['message'])

    def test_fortune_post_invalid_token(self):
        result = self.set_fortune(token='x', fortune='x')
        self.assert400(result)
        self.assertTrue('Invalid' in result.json['message'])

    def test_fortune_get(self):
        response = self.client.get('/token/')
        result = self.set_fortune(token=response.json['token'], fortune=self.fortunes[0])
        fortune = self.client.get('/fortune/', data={'token': response.json['token']})
        
        self.assert200(fortune)
        self.assertEqual('a', fortune.json['fortune'])
{'fraction_non_alphanumeric': 0.14413892908827786, 'fraction_numerical': 0.014182344428364689, 'mean_word_length': 3.0851063829787235, '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': '7044778', 'n_tokens_mistral': 1055, 'n_tokens_neox': 1020, 'n_words': 164}