<commit_before># Tests for json_creator
import json_creator
import json
import unittest
import time


class TestGetPresenceJson(unittest.TestCase):
    def test_presence_json(self):
        json_data = {'action': 'presence',
                     'time': time.time(),
                     'type': 'status',
                     'user':
                         {'account_name': 'M', 'status': 'Here'}}
        correct_json = json.dumps(json_data)
        function_json = json_creator.get_presence_json('M', 'Here')
        self.assertEqual(correct_json, function_json)


class TestGetProbeJson(unittest.TestCase):
    def test_presence_json(self):
        json_data = {'action': 'probe',
                     'time': time.time()}
        correct_json = json.dumps(json_data)
        function_json = json_creator.get_probe_json()
        self.assertEqual(correct_json, function_json)


class TestIsLongName(unittest.TestCase):
    def test_long_name(self):
        self.assertTrue(json_creator.is_long_name('a' * 26))

    def test_short_name(self):
        self.assertFalse(json_creator.is_long_name('a' * 25))


class TestGetAutenticateMessage(unittest.TestCase):
    def test_normal_case(self):
        authenticate_data = {'action': 'authenticate', 'time': time.time(),
                             'user':
                                 {'account_name': 'M', 'password': '<PASSWORD>'}}
        correct_json = json.dumps(authenticate_data)
        function_json = json_creator.get_authenticate_json('M', '123')
        self.assertEqual(correct_json, function_json)

    def test_no_pass_case(self):
        authenticate_data = {'action': 'authenticate', 'time': time.time(),
                             'user':
                                 {'account_name': 'M', 'password': ''}}
        correct_json = json.dumps(authenticate_data)
        function_json = json_creator.get_authenticate_json('M', '')
        self.assertEqual(correct_json, function_json)

    def test_long_name(self):<commit_msg>Add tests for probe generating function for OK case and exception-raising case<commit_after># Tests for json_creator
import json_creator
import json
import unittest
import time


class TestGetPresenceJson(unittest.TestCase):
    def test_presence_json(self):
        json_data = {'action': 'presence',
                     'time': time.time(),
                     'type': 'status',
                     'user':
                         {'account_name': 'M', 'status': 'Here'}}
        correct_json = json.dumps(json_data)
        function_json = json_creator.get_presence_json('M', 'Here')
        self.assertEqual(correct_json, function_json)


class TestGetProbeJson(unittest.TestCase):
    def test_probe_json(self):
        json_data = {'action': 'probe',
                     'time': time.time()}
        correct_json = json.dumps(json_data)
        function_json = json_creator.get_probe_json()
        self.assertEqual(correct_json, function_json)


class TestGetEmptyResponse(unittest.TestCase):
    def test_ok_response(self):
        json_data = {'response': 'ok'}
        correct_json = json.dumps(json_data)
        function_json = json_creator.get_empty_response_json('ok')
        self.assertEqual(correct_json, function_json)

    def test_wrong_type_response(self):
        with self.assertRaises(TypeError):
            function_json = json_creator.get_empty_response_json(None, None)


class TestIsLongName(unittest.TestCase):
    def test_long_name(self):
        self.assertTrue(json_creator.is_long_name('a' * 26))

    def test_short_name(self):
        self.assertFalse(json_creator.is_long_name('a' * 25))


class TestGetAutenticateMessage(unittest.TestCase):
    def test_normal_case(self):
        authenticate_data = {'action': 'authenticate', 'time': time.time(),
                             'user':
                                 {'account_name': 'M', 'password': '<PASSWORD>'}}
        correct_json = json.dumps(authenticate_data)
        function_json = json_creator.get_authenticate_json('M', '<PASSWORD>')
        self.assertEqual(correct_json, function_json)

    def test_no_pass_case(self):
        authenticate_data = {'action': 'authenticate', 'time': time.time(),
                             'user':
                                 {'account_name': 'M', 'password': ''}}
        correct_json = json.dumps(authenticate_data)
        function_json = json_creator.get_authenticate_json('M', '')
        self.assertEqual(correct_json, function_json)

    def test_long_name(self):
{'fraction_non_alphanumeric': 0.11621741051701281, 'fraction_numerical': 0.0024304021210782146, 'mean_word_length': 2.7228618421052633, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6052364', 'n_tokens_mistral': 1356, 'n_tokens_neox': 1306, 'n_words': 230}