@@ -807,7 +807,7 @@ def test_from_json_raised_error(self):
807
807
with self .assertRaises (ValidationError ) as context :
808
808
Formidable .from_json ({'json_invalid' : True })
809
809
810
- self .assertEqual (len (context .exception .messages ), 3 )
810
+ self .assertEqual (len (context .exception .messages ), 2 )
811
811
for message in context .exception .messages :
812
812
self .assertEqual (message , 'This field is required.' )
813
813
@@ -827,3 +827,21 @@ def test_get_serializer_with_context(self):
827
827
schema_definition ,
828
828
context = {"hello" : "world" })
829
829
self .assertEqual (serializer .context , {"hello" : "world" })
830
+
831
+ def test_duplication (self ):
832
+ """
833
+ try to duplicate a `Formidable`` object using the ``from_json``
834
+ and then it's ``to_json`` methods
835
+ """
836
+ form = Formidable .objects .create (label = 'test' , description = 'desc' )
837
+ json = form .to_json ()
838
+ new_form = Formidable .from_json (json )
839
+ self .assertEqual ('test' , new_form .label )
840
+ self .assertEqual ('desc' , new_form .description )
841
+
842
+ def test_duplication_empty_desc (self ):
843
+ form = Formidable .objects .create (label = 'test' , description = '' )
844
+ json = form .to_json ()
845
+ new_form = Formidable .from_json (json )
846
+ self .assertEqual ('test' , new_form .label )
847
+ self .assertEqual ('' , new_form .description )
0 commit comments