diff options
author | Cefin <kevon@tuta.io> | 2022-07-11 09:34:33 +0200 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2022-11-04 18:47:35 +0100 |
commit | fbf9364f6958344b284806e2a1603ef45c543370 (patch) | |
tree | 6f9de05519a8dd23c849c80db4b0fbdb20a8b3ad | |
parent | e7ffc153bb3c6cc38667426ba9b01b9dfdbae263 (diff) | |
download | Ishtar-fbf9364f6958344b284806e2a1603ef45c543370.tar.bz2 Ishtar-fbf9364f6958344b284806e2a1603ef45c543370.zip |
Zip - Test validation : writing tests #5330
Signed-off-by: Étienne Loks <etienne.loks@iggdrasil.net>
-rw-r--r-- | ishtar_common/tests.py | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/ishtar_common/tests.py b/ishtar_common/tests.py index b80c91c26..e3e796482 100644 --- a/ishtar_common/tests.py +++ b/ishtar_common/tests.py @@ -2501,6 +2501,30 @@ class ImportTest(TestCase): self.assertEqual(imprt.encoding, "utf-8") self.assertEqual(imprt.csv_sep, '|') + def test_validation_zip_import_image(self): + username, password, user = create_superuser() + c = Client() + c.login(username=username, password=password) + + 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") + + data = { + "name": "Import Zip Not Valid Must Fail", + "importer_type": importer_type.pk, + "encoding": "utf-8", + "csv_sep": "|", + "skip_lines": 1, + } + file_data = { + "imported_images": SimpleUploadedFile( + "imported_images", test_file_image.read() + ) + } + 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")) def test_archive_import(self): imprt = self.create_import() |