diff options
| author | Étienne Loks <etienne.loks@iggdrasil.net> | 2019-09-06 11:20:52 +0200 | 
|---|---|---|
| committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2019-09-06 11:20:52 +0200 | 
| commit | 2b53f8c6b5e685b501f2b180bd0000d72ac4016f (patch) | |
| tree | 445db0a06f6bb425b81e4902f4e796ae9d7cf54b /ishtar_common/tests.py | |
| parent | d0c41db15d9bc583a639a6f46b9376092dda1e11 (diff) | |
| download | Ishtar-2b53f8c6b5e685b501f2b180bd0000d72ac4016f.tar.bz2 Ishtar-2b53f8c6b5e685b501f2b180bd0000d72ac4016f.zip  | |
Serializers: test all types
Diffstat (limited to 'ishtar_common/tests.py')
| -rw-r--r-- | ishtar_common/tests.py | 25 | 
1 files changed, 21 insertions, 4 deletions
diff --git a/ishtar_common/tests.py b/ishtar_common/tests.py index aa67d2e6b..9c7beb28a 100644 --- a/ishtar_common/tests.py +++ b/ishtar_common/tests.py @@ -614,10 +614,15 @@ class GenericSerializationTest:              result = json.loads(json_result[key])              serialization_count = len(result)              # all serialization have to be tested -            self.assertTrue(serialization_count) +            self.assertTrue(serialization_count, +                            msg="No data to test for {}".format(key))              # only "natural" serialization -            self.assertNotIn("pk", result[0]) -            self.assertNotIn("id", result[0]) +            self.assertNotIn( +                "pk", result[0], +                msg="Serialization for {} do not use natural keys".format(key)) +            self.assertNotIn( +                "id", result[0], +                msg="Serialization for {} do not use natural keys".format(key))              # has to be at least equal (can be superior for model with              # recursion)              self.assertTrue( @@ -652,12 +657,23 @@ class GenericSerializationTest:  class SerializationTest(GenericSerializationTest, TestCase):      fixtures = COMMON_FIXTURES + WAREHOUSE_FIXTURES +    def create_types(self): +        from archaeological_finds.models import MaterialTypeQualityType, \ +            ObjectTypeQualityType, AlterationType, AlterationCauseType, \ +            TreatmentEmergencyType, CommunicabilityType +        for model in (models.LicenseType, MaterialTypeQualityType, +                      ObjectTypeQualityType, AlterationType, +                      AlterationCauseType, TreatmentEmergencyType, +                      CommunicabilityType): +            model.objects.create(txt_idx="test", label="Test") +      def test_type_serialization(self): +        self.create_types()          self.generic_serialization_test(type_serialization)      def create_default_conf(self):          values = {} -        models.get_current_profile()  # create a default profile +        models.get_current_profile(force=True)  # create a default profile          models.GlobalVar.objects.create(slug="test")          cform = models.CustomForm.objects.create(              name="Test", form='ishtar_common.forms.TestForm') @@ -758,6 +774,7 @@ class SerializationTest(GenericSerializationTest, TestCase):          from archaeological_operations.models import RelationType as OperationRT          cr_rel_type_nb = CRRT.objects.count()          ope_rel_type_nb = OperationRT.objects.count() +        self.create_types()          models.AuthorType.objects.create(label="Test", txt_idx="test")  | 
