summaryrefslogtreecommitdiff
path: root/archaeological_operations/tests.py
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2021-10-22 19:33:29 +0200
committerÉtienne Loks <etienne.loks@iggdrasil.net>2022-12-12 12:20:59 +0100
commit62e05e799962d810804d0cd5f8d377ac8b434a01 (patch)
tree2ad3d5f85dde8137c519f9c8e1c362df5ba49d7d /archaeological_operations/tests.py
parentfede10bc3ed5a9df9325d3c9d671a167760a9381 (diff)
downloadIshtar-62e05e799962d810804d0cd5f8d377ac8b434a01.tar.bz2
Ishtar-62e05e799962d810804d0cd5f8d377ac8b434a01.zip
Syndication - update keys from match document
Diffstat (limited to 'archaeological_operations/tests.py')
-rw-r--r--archaeological_operations/tests.py43
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("'", "&apos;")
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