From f97ccb693bc893f0a0f1c6d15fe8db017aba7867 Mon Sep 17 00:00:00 2001 From: Roberto Rosario Date: Wed, 25 Sep 2019 23:00:51 -0400 Subject: [PATCH] Add test GitLab issue #653 Tests opening zip files containing a non English named member. Signed-off-by: Roberto Rosario --- ...ve_with_special_characters_filename_member.zip | Bin 0 -> 323 bytes .../tests/contrib/test_file_spé©íáø_©hárß.txt | 1 + mayan/apps/common/tests/literals.py | 5 +++++ mayan/apps/common/tests/test_compressed_files.py | 8 ++++++++ 4 files changed, 14 insertions(+) create mode 100644 mayan/apps/common/tests/contrib/test_archvive_with_special_characters_filename_member.zip create mode 100644 mayan/apps/common/tests/contrib/test_file_spé©íáø_©hárß.txt diff --git a/mayan/apps/common/tests/contrib/test_archvive_with_special_characters_filename_member.zip b/mayan/apps/common/tests/contrib/test_archvive_with_special_characters_filename_member.zip new file mode 100644 index 0000000000000000000000000000000000000000..8b151a6c491989226fbee72e665018dcd7ad4e64 GIT binary patch literal 323 zcmWIWW@Zs#VB+9lc)ZEd-%M(Mmns7TgBlRW0dY!dS!zyxL2hbZiGFTkWn!LgYD#Xg zuCbmGgsY!eP*AL&oS&PUpQm4vT3iC+>>&<*!{uj0^$Z kj7;{-xSa@eB^YdJ1W~kgaDX=}8^{($AnXCs3qc$P0R5?M>;M1& literal 0 HcmV?d00001 diff --git a/mayan/apps/common/tests/contrib/test_file_spé©íáø_©hárß.txt b/mayan/apps/common/tests/contrib/test_file_spé©íáø_©hárß.txt new file mode 100644 index 0000000000..82c5a3c804 --- /dev/null +++ b/mayan/apps/common/tests/contrib/test_file_spé©íáø_©hárß.txt @@ -0,0 +1 @@ +TEST FILE SPECIAL CHARACTERS FILENAME diff --git a/mayan/apps/common/tests/literals.py b/mayan/apps/common/tests/literals.py index 6a03f9b38d..3cfb7ca5fd 100644 --- a/mayan/apps/common/tests/literals.py +++ b/mayan/apps/common/tests/literals.py @@ -11,6 +11,7 @@ TEST_VIEW_NAME = 'test view name' TEST_VIEW_URL = 'test-view-url' # Filenames +TEST_ARCHIVE_ZIP_SPECIAL_CHARACTERS_FILENAME_MEMBER = 'test_archvive_with_special_characters_filename_member.zip' TEST_FILENAME1 = 'test_file1.txt' TEST_FILENAME2 = 'test_file2.txt' TEST_FILENAME3 = 'test_file3.txt' @@ -23,6 +24,10 @@ TEST_ZIP_FILE = 'test_file.zip' TEST_COMPRESSED_FILE_CONTENTS = [TEST_FILENAME1, TEST_FILENAME2] # File paths +TEST_ARCHIVE_ZIP_SPECIAL_CHARACTERS_FILENAME_MEMBER_PATH = os.path.join( + settings.BASE_DIR, 'apps', 'common', 'tests', 'contrib', + TEST_ARCHIVE_ZIP_SPECIAL_CHARACTERS_FILENAME_MEMBER +) TEST_FILE3_PATH = os.path.join( settings.BASE_DIR, 'apps', 'common', 'tests', 'contrib', TEST_FILENAME3 ) diff --git a/mayan/apps/common/tests/test_compressed_files.py b/mayan/apps/common/tests/test_compressed_files.py index 30e1634d87..e004514c28 100644 --- a/mayan/apps/common/tests/test_compressed_files.py +++ b/mayan/apps/common/tests/test_compressed_files.py @@ -5,6 +5,7 @@ from mayan.apps.common.tests import BaseTestCase from ..compressed_files import Archive, TarArchive, ZipArchive from .literals import ( + TEST_ARCHIVE_ZIP_SPECIAL_CHARACTERS_FILENAME_MEMBER_PATH, TEST_COMPRESSED_FILE_CONTENTS, TEST_FILE_CONTENTS_1, TEST_FILE3_PATH, TEST_FILENAME1, TEST_FILENAME3, TEST_TAR_BZ2_FILE_PATH, TEST_TAR_FILE_PATH, TEST_TAR_GZ_FILE_PATH, TEST_ZIP_FILE_PATH @@ -58,6 +59,11 @@ class ZipArchiveClassTestCase(TarArchiveClassTestCase): archive_path = TEST_ZIP_FILE_PATH cls = ZipArchive + def test_open_member_with_special_characters_filename(self): + with open(TEST_ARCHIVE_ZIP_SPECIAL_CHARACTERS_FILENAME_MEMBER_PATH, mode='rb') as file_object: + archive = Archive.open(file_object=file_object) + list(archive.get_members()) + class TarGzArchiveClassTestCase(TarArchiveClassTestCase): archive_path = TEST_TAR_GZ_FILE_PATH @@ -67,3 +73,5 @@ class TarGzArchiveClassTestCase(TarArchiveClassTestCase): class TarBz2ArchiveClassTestCase(TarArchiveClassTestCase): archive_path = TEST_TAR_BZ2_FILE_PATH cls = TarArchive + +