diff options
author | Étienne Loks <etienne.loks@iggdrasil.net> | 2022-07-18 09:27:52 +0200 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2022-11-04 18:47:36 +0100 |
commit | 1a2314c5ad96160cd640ade8db90ad1b39b01187 (patch) | |
tree | 6d6f5bee8e662d5563c29c2f02db741cb297937b /ishtar_common | |
parent | fbf9364f6958344b284806e2a1603ef45c543370 (diff) | |
download | Ishtar-1a2314c5ad96160cd640ade8db90ad1b39b01187.tar.bz2 Ishtar-1a2314c5ad96160cd640ade8db90ad1b39b01187.zip |
Tests - fix valid zip file test (refs #5330)
Diffstat (limited to 'ishtar_common')
-rw-r--r-- | ishtar_common/tests.py | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/ishtar_common/tests.py b/ishtar_common/tests.py index e3e796482..50aec88b3 100644 --- a/ishtar_common/tests.py +++ b/ishtar_common/tests.py @@ -52,6 +52,7 @@ from django.template.defaultfilters import slugify from django.test import tag, TestCase as BaseTestCase from django.test.client import Client from django.test.runner import DiscoverRunner +from django.utils.translation import ugettext_lazy as _ from ishtar_common import models, models_common from ishtar_common import views @@ -2508,7 +2509,7 @@ class ImportTest(TestCase): imp_model = self.create_importer_model() importer_type = self.create_importer_type(imp_model) - test_file_image = os.path.join(settings.MEDIA_ROOT, "images_not_zip.png") + image_path = os.path.join("..", "ishtar_common", "tests", "test.png") data = { "name": "Import Zip Not Valid Must Fail", @@ -2516,15 +2517,16 @@ class ImportTest(TestCase): "encoding": "utf-8", "csv_sep": "|", "skip_lines": 1, - } - file_data = { "imported_images": SimpleUploadedFile( - "imported_images", test_file_image.read() - ) + name="test.png", + content=open(image_path, "rb").read(), + content_type="image/png", + ), } - response = c.post(reverse("new_import"), data, file_data) - self.assertContains(response.content, "Associated images must be zip file.") - self.assertRedirects(response, reverse("new_import")) + response = c.post(reverse("new_import"), data) + self.assertIn(str(_('"Associated images" field must be a valid zip file.')), + response.content.decode("utf-8")) + self.assertEqual(response.status_code, 200) def test_archive_import(self): imprt = self.create_import() |