summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2019-05-06 19:16:39 +0200
committerÉtienne Loks <etienne.loks@iggdrasil.net>2019-06-17 13:21:28 +0200
commit239ff277af07ba55ebc186296d0621b557eaefa5 (patch)
tree8b97e6febf4e51053c6ca3578bd6c2e6dc254169
parent8e44059bec779007f8aed357a8ddfb155bcd989b (diff)
downloadIshtar-239ff277af07ba55ebc186296d0621b557eaefa5.tar.bz2
Ishtar-239ff277af07ba55ebc186296d0621b557eaefa5.zip
Libreoffice templates generation: test
-rw-r--r--archaeological_operations/tests.py25
1 files changed, 25 insertions, 0 deletions
diff --git a/archaeological_operations/tests.py b/archaeological_operations/tests.py
index 71b912f89..10afc61f2 100644
--- a/archaeological_operations/tests.py
+++ b/archaeological_operations/tests.py
@@ -492,6 +492,31 @@ class ImportOperationTest(ImportTest, TestCase):
current_ope_nb = models.Operation.objects.count()
self.assertEqual(current_ope_nb, init_ope_number + 2)
+ def test_export_libreoffice_template(self):
+ if not settings.USE_LIBREOFFICE: # function not available
+ return
+ mcc_operation = ImporterType.objects.get(name=u"MCC - Opérations")
+ generated_file = mcc_operation.get_libreoffice_template()
+ zip_file = zipfile.ZipFile(generated_file)
+ self.assertIsNone(zip_file.testzip(), "Libreoffice template generated "
+ "is not a correct zip file.")
+
+ filename = None
+ for name in zip_file.namelist():
+ if name == 'content.xml':
+ filename = name
+ break
+ self.assertIsNotNone(filename)
+
+ # only check that all operation types are listed in the source file
+ with tempfile.TemporaryDirectory(prefix='tmp-ishtar-') as tmpdir:
+ imported_file = zip_file.extract(filename, tmpdir)
+ with open(imported_file) as content_file:
+ content = content_file.read()
+ for ope_type in models.OperationType.objects.all():
+ ope_type = str(ope_type).replace("'", '&apos;')
+ self.assertIn(ope_type, content)
+
def test_mcc_import_parcels(self):
old_nb = models.Parcel.objects.count()
mcc_parcel, form = self.init_parcel_import()