def setUp(self):
     self.simple_model = create_simple_model_with_json_representation()[0]
     self.simple_model_as_json = create_simple_model_with_json_representation(
     )[1]
     self.complex_model = create_complex_model_with_json_representation()[0]
     self.complex_model_as_json = create_complex_model_with_json_representation(
     )[1]
 def test_class_with_json_dumps_when_iterable(self):
     complex_models = [
         create_complex_model_with_json_representation(i)[0]
         for i in range(10)
     ]
     complex_models_as_json = [
         create_complex_model_with_json_representation(i)[1]
         for i in range(10)
     ]
     encoded = json.dumps(complex_models,
                          cls=ComplexModelMappingJSONEncoder)
     encoded_as_dict = json.loads(encoded)
     self.assertCountEqual(encoded_as_dict, complex_models_as_json)
 def test_class_with_json_loads_with_iterable(self):
     complex_models = [
         create_complex_model_with_json_representation(i)[0]
         for i in range(10)
     ]
     complex_models_as_json = [
         create_complex_model_with_json_representation(i)[1]
         for i in range(10)
     ]
     json_as_string = json.dumps(complex_models_as_json)
     decoded = json.loads(json_as_string,
                          cls=ComplexModelMappingJSONDecoder)
     self.assertEqual(decoded, complex_models)
Example #4
0
 def setUp(self):
     self.simple_model = create_simple_model_with_json_representation()[0]
     self.simple_model_as_json = create_simple_model_with_json_representation()[1]
     self.complex_model = create_complex_model_with_json_representation()[0]
     self.complex_model_as_json = create_complex_model_with_json_representation()[1]
 def test_serialize_with_iterable(self):
     complex_models = [create_complex_model_with_json_representation(i)[0] for i in range(10)]
     complex_models_as_json = [create_complex_model_with_json_representation(i)[1] for i in range(10)]
     serialized = ComplexModelSerializer().serialize(complex_models)
     self.assertEqual(serialized, complex_models_as_json)
 def test_class_with_json_dumps_when_iterable(self):
     complex_models = [create_complex_model_with_json_representation(i)[0] for i in range(10)]
     complex_models_as_json = [create_complex_model_with_json_representation(i)[1] for i in range(10)]
     encoded = json.dumps(complex_models, cls=ComplexModelMappingJSONEncoder)
     encoded_as_dict = json.loads(encoded)
     self.assertCountEqual(encoded_as_dict, complex_models_as_json)
 def test_class_with_json_loads_with_iterable(self):
     complex_models = [create_complex_model_with_json_representation(i)[0] for i in range(10)]
     complex_models_as_json = [create_complex_model_with_json_representation(i)[1] for i in range(10)]
     json_as_string = json.dumps(complex_models_as_json)
     decoded = json.loads(json_as_string, cls=ComplexModelMappingJSONDecoder)
     self.assertEqual(decoded, complex_models)