def test_stringify_expectations_for_string(self, json_dumps_mock): data = "foo" generator = LogicalIdGenerator(self.prefix, data_obj=data) self.assertEqual(data, generator._stringify(data)) json_dumps_mock.assert_not_called()
def test_stringify_expectations_for_string(self, json_dumps_mock): data = "foo" generator = LogicalIdGenerator(self.prefix, data_obj=data) self.assertEqual(data, generator._stringify(data)) json_dumps_mock.assert_not_called()
def test_stringify_expectations(self, json_dumps_mock): data = ["foo"] expected = "bar" json_dumps_mock.return_value = expected generator = LogicalIdGenerator(self.prefix, data_obj=data) self.assertEqual(expected, generator._stringify(data)) json_dumps_mock.assert_called_with(data, separators=(',', ':'), sort_keys=True)
def test_stringify_expectations(self, json_dumps_mock): data = ["foo"] expected = "bar" json_dumps_mock.return_value = expected generator = LogicalIdGenerator(self.prefix, data_obj=data) self.assertEqual(expected, generator._stringify(data)) json_dumps_mock.assert_called_with(data, separators=(',', ':'), sort_keys=True)
def test_stringify_strings(self): data = "some data" generator = LogicalIdGenerator(self.prefix, data_obj=data) # Strings should be returned unmodified ie. json dump is short circuited self.assertEqual(data, generator._stringify(data))
def test_stringify_array_sorting(self): data = ["a", 1, {"z": "x", "b": "d"}] expected = '["a",1,{"b":"d","z":"x"}]' generator = LogicalIdGenerator(self.prefix, data_obj=data) self.assertEqual(expected, generator._stringify(data))
def test_stringify_basic_objects_sorting(self): data = {"c": [4, 3, 1], "a": "b"} expected = '{"a":"b","c":[4,3,1]}' generator = LogicalIdGenerator(self.prefix, data_obj=data) self.assertEqual(expected, generator._stringify(data))
def test_stringify_strings(self): data = "some data" generator = LogicalIdGenerator(self.prefix, data_obj=data) # Strings should be returned unmodified ie. json dump is short circuited self.assertEqual(data, generator._stringify(data))
def test_stringify_array_sorting(self): data = ["a", 1, {"z": "x", "b": "d"}] expected = '["a",1,{"b":"d","z":"x"}]' generator = LogicalIdGenerator(self.prefix, data_obj=data) self.assertEqual(expected, generator._stringify(data))
def test_stringify_basic_objects_sorting(self): data = {"c": [4,3,1], "a": "b"} expected = '{"a":"b","c":[4,3,1]}' generator = LogicalIdGenerator(self.prefix, data_obj=data) self.assertEqual(expected, generator._stringify(data))