summaryrefslogtreecommitdiff
path: root/archaeological_operations/tests.py
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2025-08-13 16:18:15 +0200
committerÉtienne Loks <etienne.loks@iggdrasil.net>2025-08-20 10:17:24 +0200
commit38bc2f4f1ceb17f41fc7a5c6c0b4fb9b3043e6cb (patch)
tree064845c67d4cc4d7259babd0818de167a9e714b8 /archaeological_operations/tests.py
parent9460842a9c367f5a7a95292c80766eadaf9792fd (diff)
downloadIshtar-38bc2f4f1ceb17f41fc7a5c6c0b4fb9b3043e6cb.tar.bz2
Ishtar-38bc2f4f1ceb17f41fc7a5c6c0b4fb9b3043e6cb.zip
✅ fix test for template generation
Diffstat (limited to 'archaeological_operations/tests.py')
-rw-r--r--archaeological_operations/tests.py36
1 files changed, 35 insertions, 1 deletions
diff --git a/archaeological_operations/tests.py b/archaeological_operations/tests.py
index 31b7c6f3b..1d4ade439 100644
--- a/archaeological_operations/tests.py
+++ b/archaeological_operations/tests.py
@@ -4420,7 +4420,7 @@ class RegisterTest(TestCase, OperationInitTest):
def test_document_generation(self):
tpl = open(
settings.LIB_BASE_PATH +
- "archaeological_operations/tests/document_reference.odt",
+ "archaeological_operations/tests/template_adminact.odt",
"rb",
)
template = SimpleUploadedFile(tpl.name, tpl.read())
@@ -4458,6 +4458,40 @@ class RegisterTest(TestCase, OperationInitTest):
if f:
f.close()
+ def test_document_ref_generation(self):
+ tpl = open(
+ settings.LIB_BASE_PATH +
+ "archaeological_operations/tests/document_reference.odt",
+ "rb",
+ )
+ template = SimpleUploadedFile(tpl.name, tpl.read())
+ model, __ = ImporterModel.objects.get_or_create(
+ klass="archaeological_operations.models.AdministrativeAct"
+ )
+ doc = DocumentTemplate.objects.create(
+ name="Test",
+ slug=True,
+ associated_model=model,
+ available=True,
+ template=template,
+ )
+ self.act_types[0].associated_template.add(doc)
+
+ c = Client()
+ data = {"pk": self.admin_acts[0].pk, "document_template": doc.pk}
+ response = c.post(reverse("operation-administrativeact-document"), data)
+ # no result when no authentication
+ self.assertEqual(response.content, b"")
+ c.login(username=self.username, password=self.password)
+ response = c.post(reverse("operation-administrativeact-document"), data)
+ f = None
+ try:
+ f = BytesIO(response.content)
+ self.assertIn(b"2014-05-12", f.read())
+ finally:
+ if f:
+ f.close()
+
class OperationWizardCreationTest(WizardTest, OperationInitTest, TestCase):
fixtures = FILE_FIXTURES