|
5 | 5 | from django.conf import settings |
6 | 6 | from django.core import mail |
7 | 7 | from django.http import HttpResponse |
| 8 | +from django.test import tag |
8 | 9 |
|
9 | 10 | # from geno.views import send_member_mail_process |
10 | 11 | from geno.documents import send_member_mail_process |
|
20 | 21 | Share, |
21 | 22 | ) |
22 | 23 | from geno.tests import data as geno_testdata |
| 24 | +from geno.utils import fill_template_pod, odt2pdf |
23 | 25 |
|
24 | 26 | from .base import DocumentCreationMockMixin, GenoAdminTestCase |
25 | 27 |
|
@@ -175,6 +177,31 @@ def test_send_member_bill(self): |
175 | 177 | self.form_action_send(formal=True) |
176 | 178 |
|
177 | 179 |
|
| 180 | +@tag("slow-test") |
| 181 | +class DocumentCreationTest(GenoAdminTestCase): |
| 182 | + def test_libreoffice_template_processing_and_odt2pdf(self): |
| 183 | + content_template = ContentTemplate.objects.get(name="Simple") |
| 184 | + ctx = self.members[1].name.get_context() |
| 185 | + |
| 186 | + output_odt_file = fill_template_pod(content_template.file.path, ctx, output_format="odt") |
| 187 | + self.assertRegex(output_odt_file, r"^/tmp/django_pod_Musterweg/django_pod_\w+\.odt$") |
| 188 | + |
| 189 | + output_pdf_file = odt2pdf(output_odt_file, "document_creation_test") |
| 190 | + self.assertRegex(output_pdf_file, r"^/tmp/django_pod_Musterweg/django_pod_\w+\.pdf$") |
| 191 | + |
| 192 | + current_year = datetime.datetime.now().year |
| 193 | + expected = f"""General: |
| 194 | +<adr-line1>: Anna Muster |
| 195 | +<adr-line2>: Beispielweg 1 |
| 196 | +<adr-line3>: 3000 Bern |
| 197 | +<anrede>: Liebe Anna |
| 198 | +Share context: |
| 199 | +Billing context: |
| 200 | +<jahr>: {current_year} |
| 201 | +""" |
| 202 | + self.assertInPDF(output_pdf_file, expected) |
| 203 | + |
| 204 | + |
178 | 205 | class DocumentFormFilterTest(GenoAdminTestCase): |
179 | 206 | @classmethod |
180 | 207 | def setUpTestData(cls): |
@@ -411,6 +438,7 @@ def test_invoice_filter_catA_range_inside(self): |
411 | 438 | ) |
412 | 439 |
|
413 | 440 |
|
| 441 | +@tag("slow-test") |
414 | 442 | class DocumentProcessTest(GenoAdminTestCase): |
415 | 443 | @classmethod |
416 | 444 | def setUpTestData(cls): |
|
0 commit comments