diff options
-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() |