def setUp(self): self.string_data = 'sdfgsdfgsdfgsdfg' self.string_response = randomizer(self.string_data) self.integer_data = 1234567890 self.integer_response = randomizer(self.integer_data) self.boolean_data = False self.boolean_response = randomizer(self.boolean_data)
def test_sequence_response(self): """ Response (sequence) should have the same length and structure as input """ payload = [1, 'a', ['a', 'b', [{'a': 'b'}, 'a']], False] response = randomizer(payload) self.assertEqual(len(payload), len(response)) self.assertEqual(len(payload[2]), len(response[2])) self.assertEqual(len(payload[2][2]), len(response[2][2]))
def test_dictionary_response(self): """ Response (dictionary) should have the same length and structure as input TODO: on older python versions key ordering could cause problems - that's why they must be reordered """ payload = { 'array': [1, 'a', ['a', 'b', [{'a': 'b'}, 'a']], False], 'boolean': False, 'sub_dict': { 'key1': 'value1', 'sub_sub_dict': { 'key1': 'value1' } } } response = randomizer(payload) self.assertEqual(len(payload), len(response))
def test_dictionary_response(self): """ Response (dictionary) should have the same length and structure as input TODO: on older python versions key ordering could cause problems - that's why they must be reordered """ payload = { 'array': [1, 'a', ['a', 'b', [{ 'a': 'b' }, 'a']], False], 'boolean': False, 'sub_dict': { 'key1': 'value1', 'sub_sub_dict': { 'key1': 'value1' } } } response = randomizer(payload) self.assertEqual(len(payload), len(response))