diff options
author | Étienne Loks <etienne.loks@iggdrasil.net> | 2022-07-18 09:27:52 +0200 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2022-12-12 12:17:32 +0100 |
commit | e52d253b24be78fbc2b475204e9955a5ba56e4ea (patch) | |
tree | 1c018305503b7135ec5dc82f0b8e1fcdd6608941 /ishtar_common/tests.py | |
parent | ee5e127669df7645577a66f96d1923ff2595d98a (diff) | |
download | Ishtar-e52d253b24be78fbc2b475204e9955a5ba56e4ea.tar.bz2 Ishtar-e52d253b24be78fbc2b475204e9955a5ba56e4ea.zip |
Tests - fix valid zip file test (refs #5330)
Diffstat (limited to 'ishtar_common/tests.py')
-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() |