import datetime import locale import tempfile import os from django.test import TestCase from functions import get_resource_path from web.docx_helper import process_file class TestDocxProcessor(TestCase): def test_process_file(self): template_path = get_resource_path('template.docx') locale.setlocale(locale.LC_TIME, "fr_FR") output_path = tempfile.mktemp() changes = { "##SIR##": "Mr", "##NAME##": "Jan", "##SURNAME##": "Weglarz", "##ADDRESS1##": "Piotrowo 23", "##ADDRESS2##": "61-234, Poznan", "##COUNTRY##": "POLAND", "##CONTENT##": "1", "##DATE##": datetime.datetime.now().date().strftime("%A %-d %B %Y"), } process_file(template_path, output_path, changes) self.assertTrue(os.path.isfile(output_path)) os.remove(output_path)