summaryrefslogtreecommitdiff
path: root/archaeological_operations/tests.py
diff options
context:
space:
mode:
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 caadbc94f..d346b56e1 100644
--- a/archaeological_operations/tests.py
+++ b/archaeological_operations/tests.py
@@ -3753,7 +3753,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())
@@ -3791,6 +3791,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