diff options
Diffstat (limited to 'archaeological_operations/tests.py')
| -rw-r--r-- | archaeological_operations/tests.py | 43 | 
1 files changed, 43 insertions, 0 deletions
diff --git a/archaeological_operations/tests.py b/archaeological_operations/tests.py index 409ee5079..69d3e7f26 100644 --- a/archaeological_operations/tests.py +++ b/archaeological_operations/tests.py @@ -31,6 +31,7 @@ from django.apps import apps  from django.conf import settings  from django.contrib.auth.models import Group  from django.contrib.contenttypes.models import ContentType +from django.core.files import File as DjangoFile  from django.core.files.uploadedfile import SimpleUploadedFile  from django.db.models import Q  from django.test import tag @@ -4711,6 +4712,48 @@ class ApiTest(OperationInitTest, APITestCase):                      ope_type = str(ope_type).replace("'", "'")                      self.assertIn(ope_type, content) +    @tag("libreoffice") +    @patch("requests.get") +    def test_match_doc_update(self, mock_get): +        if not settings.USE_LIBREOFFICE: +            return +        self._mock_request(mock_get) +        self.client.login(username=self.username, password=self.password) +        source = self._get_source() + +        url = "/admin/{}/{}/".format( +            "ishtar_common", models_rest.ApiExternalSource.__name__.lower() +        ) +        params = { +            "action": "update_types_from_source", +            "_selected_action": [source.pk], +        } +        self.client.post(url, params, follow=True) + +        base = "default-source.ods" +        filename = settings.ROOT_PATH + "../archaeological_operations/tests/" + base +        with open(filename, "rb") as fle: +            source.match_document.save(base, DjangoFile(fle)) + +        params["action"] = "update_association_from_match_document" +        response = self.client.post(url, params, follow=True).content.decode() +        result = {"updated": 4} +        msg = str(_(f"{result['updated']} match key(s) updated.")) +        self.assertIn(msg, response) +        ctype = "archaeological_operations.remaintype" +        distant_key = distant_label = "ail" +        msg = str( +            _( +                f"{ctype} - {distant_key}, {distant_label} not referenced in the database." +            ) +        ) +        self.assertIn(msg, response) +        sheet_name = ( +            "archaeological_operations.operation-archaeological_operations.ReportState" +        ) +        msg = str(_(f"{sheet_name} is not a correct sheet name.")) +        self.assertIn(msg, response) +      def test_query_transformation(self):          # POV: local          # change query terms from a source Ishtar to match distant Ishtar  | 
