diff options
| author | Étienne Loks <etienne.loks@iggdrasil.net> | 2019-09-02 13:06:48 +0200 | 
|---|---|---|
| committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2019-09-02 13:06:48 +0200 | 
| commit | 12be9b206762b6872c680e072b9a2509334b4652 (patch) | |
| tree | e7d9c54b7e7f53e5cf23bb18a9e809f49c74c5f2 /ishtar_common/tests.py | |
| parent | 9d82b632716c190746623f851beed1a67e027abf (diff) | |
| download | Ishtar-12be9b206762b6872c680e072b9a2509334b4652.tar.bz2 Ishtar-12be9b206762b6872c680e072b9a2509334b4652.zip  | |
Serialization: manage importers
Diffstat (limited to 'ishtar_common/tests.py')
| -rw-r--r-- | ishtar_common/tests.py | 27 | 
1 files changed, 26 insertions, 1 deletions
diff --git a/ishtar_common/tests.py b/ishtar_common/tests.py index 0e3832e24..7be176c05 100644 --- a/ishtar_common/tests.py +++ b/ishtar_common/tests.py @@ -52,7 +52,8 @@ from ishtar_common import views  from ishtar_common.apps import admin_site  from ishtar_common.serializers import type_serialization, \      SERIALIZATION_VERSION, serialization_info, \ -    restore_serialized, conf_serialization, CONF_MODEL_LIST +    restore_serialized, conf_serialization, CONF_MODEL_LIST, \ +    importer_serialization, IMPORT_MODEL_LIST  from ishtar_common.utils import post_save_geo, update_data, move_dict_data, \      rename_and_simplify_media_name, try_fix_file @@ -651,6 +652,15 @@ class SerializationTest(TestCase):          self.create_default_conf()          self.generic_serialization_test(conf_serialization) +    def create_default_importer(self): +        models.ValueFormater.objects.create( +            name="Test", slug="test", format_string="HOPS-{}" +        ) + +    def test_importer_serialization(self): +        self.create_default_importer() +        self.generic_serialization_test(importer_serialization) +      def test_serialization_zip(self):          zip_filename = type_serialization(archive=True)          # only check the validity of the zip, the type content is tested above @@ -733,6 +743,21 @@ class SerializationTest(TestCase):              os.path.isfile(values["document_template"].template.path)          ) +    def test_importer_restore(self): +        self.create_default_importer() +        current_number = {} +        for model in IMPORT_MODEL_LIST: +            current_number[model.__name__] = model.objects.count() +        zip_filename = importer_serialization(archive=True) +        restore_serialized(zip_filename, delete_existing=True) +        for model in IMPORT_MODEL_LIST: +            previous_nb = current_number[model.__name__] +            current_nb = model.objects.count() +            self.assertEqual( +                previous_nb, current_nb, +                msg="Restore for model {} failed. Initial: {}, restored: " +                    "{}.".format(model.__name__, previous_nb, current_nb)) +  class AccessControlTest(TestCase):      def test_administrator(self):  | 
