diff options
author | Étienne Loks <etienne.loks@iggdrasil.net> | 2025-06-18 11:27:30 +0200 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2025-06-18 11:27:30 +0200 |
commit | c228fdc8c6e498dc306f45f28c3475d8ca42f4a1 (patch) | |
tree | 5d03be9c09bb8130d59512d579cfcea132f9cd7d /archaeological_operations | |
parent | 93e14d0aeeb101d3595a21315b07871dda9c9db3 (diff) | |
download | Ishtar-c228fdc8c6e498dc306f45f28c3475d8ca42f4a1.tar.bz2 Ishtar-c228fdc8c6e498dc306f45f28c3475d8ca42f4a1.zip |
✨ Media exporter: manage cascade update
Diffstat (limited to 'archaeological_operations')
-rw-r--r-- | archaeological_operations/tests.py | 49 |
1 files changed, 46 insertions, 3 deletions
diff --git a/archaeological_operations/tests.py b/archaeological_operations/tests.py index 688af87ad..b8db7e2c7 100644 --- a/archaeological_operations/tests.py +++ b/archaeological_operations/tests.py @@ -4128,14 +4128,14 @@ class OperationExportMediaTest(TestCase, TestPermissionQuery, OperationInitTest) c.login(username=self.username, password=self.password) response = c.get(self.export_url) - self._test_files(response, [('image_00001.png', True)]) + self._test_files(response, [('operation_image_00001.png', True)]) self.exporter.files_to_export = 'A' self.exporter.save() response = c.get(self.export_url) self._test_files( response, - [('image_00001.png', True), ('file_00001.txt', False), ] + [('operation_image_00001.png', True), ('operation_file_00001.txt', False), ] ) self.exporter.thumbnail_for_images = True @@ -4143,7 +4143,50 @@ class OperationExportMediaTest(TestCase, TestPermissionQuery, OperationInitTest) response = c.get(self.export_url) self._test_files( response, - [('image_00001.jpg', True), ('file_00001.txt', False), ] + [('operation_image_00001.jpg', True), ('operation_file_00001.txt', False), ] + ) + + def _add_find(self): + cr_data = { + "label": "Context record", + "operation": self.operation, + "history_modifier": self.user, + } + ContextRecord = apps.get_model( + "archaeological_context_records", "ContextRecord" + ) + cr = ContextRecord.objects.create(**cr_data) + + BaseFind = apps.get_model("archaeological_finds", "BaseFind") + Find = apps.get_model("archaeological_finds", "Find") + + bf_data = { + "label": "Base find", + "history_modifier": self.get_default_user(), + "context_record": cr, + } + base_find = BaseFind.objects.create(**bf_data) + find = Find.objects.create( + history_modifier=self.get_default_user(), label="Find me" + ) + find.base_finds.add(base_find) + return cr, find + + def test_cascade_update(self): + self.exporter.cascade = True + self.exporter.save() + cr, find = self._add_find() + cr.documents.add(self.documents[0]) + find.documents.add(self.documents[0]) + c = Client() + c.login(username=self.username, password=self.password) + + response = c.get(self.export_url) + self._test_files( + response, + [('operation_image_00001.png', True), + ('contextrecord_image_00001.png', True), + ('find_image_00001.png', True),] ) |