diff options
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 |
commit | 20280d6aa4cecacc788cc0f2819180bdba42d62d (patch) | |
tree | 8b97e6febf4e51053c6ca3578bd6c2e6dc254169 /archaeological_operations | |
parent | 0e14ea23407a6b99fba0fce091b31567979311f9 (diff) | |
download | Ishtar-20280d6aa4cecacc788cc0f2819180bdba42d62d.tar.bz2 Ishtar-20280d6aa4cecacc788cc0f2819180bdba42d62d.zip |
Libreoffice templates generation: test
Diffstat (limited to 'archaeological_operations')
-rw-r--r-- | archaeological_operations/tests.py | 25 |
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("'", ''') + self.assertIn(ope_type, content) + def test_mcc_import_parcels(self): old_nb = models.Parcel.objects.count() mcc_parcel, form = self.init_parcel_import() |