From 3e013d7f3b403de865f0ae612d272099dda3004c Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Tue, 11 Jul 2017 12:34:27 +0200 Subject: Simple migration script for old ODT templates (refs #3602) --- archaeological_operations/tests.py | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'archaeological_operations') diff --git a/archaeological_operations/tests.py b/archaeological_operations/tests.py index f2bb390bd..8ca14179f 100644 --- a/archaeological_operations/tests.py +++ b/archaeological_operations/tests.py @@ -1124,6 +1124,38 @@ class RegisterTest(TestCase, OperationInitTest): z.close() f.close() + def test_document_migration(self): + fe = FileInit() + fe.create_file() + + from archaeological_files.tests import create_administrativact as ca_fle + ca_fle(self.user, fe.item) + + tpl = open( + settings.ROOT_PATH + + '../ishtar_common/tests/old.odt', + 'rb') + template = SimpleUploadedFile(tpl.name, tpl.read()) + doc = DocumentTemplate.objects.create( + name="Old", + associated_object_name=DocumentTemplate.CLASSNAMES[0][0], + available=True, + template=template + ) + self.act_types[0].associated_template.add(doc) + + doc.convert_from_v1() + with open(doc.template.path) as f: + try: + z = zipfile.ZipFile(f) + self.assertIsNone(z.testzip()) + c = z.open('content.xml') + content = c.read() + self.assertIn('{{ adminact_operator_id }}', content) + finally: + c.close() + z.close() + class OperationWizardCreationTest(WizardTest, OperationInitTest, TestCase): fixtures = [settings.ROOT_PATH + -- cgit v1.2.3