diff options
author | Étienne Loks <etienne.loks@iggdrasil.net> | 2019-09-09 01:06:47 +0200 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2019-09-09 01:06:47 +0200 |
commit | 8a17c17d45a2c9b63c5a70c4a6e3e56cc3c942d4 (patch) | |
tree | 529b8afe90d9535b75e6d4a712e00949382acb56 | |
parent | 51f31dd7dfd62c2d9de75e83ccf1727190514157 (diff) | |
download | Ishtar-8a17c17d45a2c9b63c5a70c4a6e3e56cc3c942d4.tar.bz2 Ishtar-8a17c17d45a2c9b63c5a70c4a6e3e56cc3c942d4.zip |
Serialization: fix WarehouseDivisionLink filter - test export action
-rw-r--r-- | archaeological_warehouse/serializers.py | 4 | ||||
-rw-r--r-- | ishtar_common/tasks.py | 2 | ||||
-rw-r--r-- | ishtar_common/tests.py | 44 |
3 files changed, 44 insertions, 6 deletions
diff --git a/archaeological_warehouse/serializers.py b/archaeological_warehouse/serializers.py index 38ebf4342..ff7c23778 100644 --- a/archaeological_warehouse/serializers.py +++ b/archaeological_warehouse/serializers.py @@ -39,8 +39,8 @@ def generate_warehouse_queryset(base_query_key, ids): list(models.Warehouse.objects.filter(q).values_list( "id", flat=True))) warehouse_div_ids.update( - list(models.WarehouseDivision.objects.filter(q_div).values_list( - "id", flat=True))) + list(models.WarehouseDivisionLink.objects.filter( + q_div).values_list("id", flat=True))) result_queryset = { models.Warehouse.__name__: models.Warehouse.objects.filter(id__in=warehouse_ids), diff --git a/ishtar_common/tasks.py b/ishtar_common/tasks.py index a68a30b86..631996684 100644 --- a/ishtar_common/tasks.py +++ b/ishtar_common/tasks.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- -# Copyright (C) 2013-2014 Étienne Loks <etienne.loks_AT_peacefrogsDOTnet> +# Copyright (C) 2013-2019 Étienne Loks <etienne.loks_AT_peacefrogsDOTnet> # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as diff --git a/ishtar_common/tests.py b/ishtar_common/tests.py index b814cbe5c..22876784c 100644 --- a/ishtar_common/tests.py +++ b/ishtar_common/tests.py @@ -63,6 +63,7 @@ from archaeological_warehouse.serializers import WAREHOUSE_MODEL_LIST from ishtar_common.serializers_utils import serialization_info from ishtar_common.utils import post_save_geo, update_data, move_dict_data, \ rename_and_simplify_media_name, try_fix_file +from ishtar_common.tasks import launch_export COMMON_FIXTURES = [ @@ -670,8 +671,9 @@ class GenericSerializationTest: 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)) + msg="Restore for model {}.{} failed. Initial: {}, restored: " + "{}.".format(model.__module__, model.__name__, + previous_nb, current_nb)) class SerializationTest(GenericSerializationTest, TestCase): @@ -1054,13 +1056,16 @@ class SerializationTest(GenericSerializationTest, TestCase): self.generic_restore_test(zip_filename, current_number, [models.Document]) - def test_full_restore(self): + def full_create(self): self.create_types() self.create_default_conf() self.create_default_importer() self.create_geo_default() self.create_directory_default() self.create_document_default() + + def test_full_restore(self): + self.full_create() model_list = get_type_models() + CONF_MODEL_LIST + IMPORT_MODEL_LIST + \ GEO_MODEL_LIST + DIRECTORY_MODEL_LIST + OPERATION_MODEL_LIST + \ CR_MODEL_LIST + FIND_MODEL_LIST + WAREHOUSE_MODEL_LIST @@ -1069,6 +1074,39 @@ class SerializationTest(GenericSerializationTest, TestCase): self.generic_restore_test(zip_filename, current_number, model_list) + def test_export_action(self): + self.full_create() + model_list = get_type_models() + CONF_MODEL_LIST + IMPORT_MODEL_LIST + \ + GEO_MODEL_LIST + DIRECTORY_MODEL_LIST + OPERATION_MODEL_LIST + \ + CR_MODEL_LIST + FIND_MODEL_LIST + WAREHOUSE_MODEL_LIST + task = models.ExportTask.objects.create(state="S") + launch_export(task) + current_number = {} + for model in model_list: + current_number[(model.__module__, model.__name__)] = \ + model.objects.count() + self.generic_restore_test(task.result.path, current_number, + model_list) + + task = models.ExportTask.objects.create( + filter_type="O", filter_text="66666", state="S") + current_number.update( + { + ("archaeological_operations.models", "ArchaeologicalSite"): 1, + ("archaeological_operations.models", "Operation"): 1, + ("archaeological_context_records.models", "ContextRecord"): 1, + ("archaeological_finds.models_finds", "BaseFind"): 1, + ("archaeological_finds.models_finds", "Find"): 1, + ("archaeological_warehouse.models", "Warehouse"): 1, + ("archaeological_warehouse.models", "Container"): 1, + ("archaeological_warehouse.models", "WarehouseDivisionLink"): 1, + ("archaeological_warehouse.models", "ContainerLocalisation"): 1, + } + ) + launch_export(task) + self.generic_restore_test(task.result.path, current_number, + model_list) + class AccessControlTest(TestCase): def test_administrator(self): |