From 9a4b0424071ecb602e2e58879b87a531a28ff267 Mon Sep 17 00:00:00 2001 From: Lia Date: Thu, 5 Nov 2020 18:59:09 -0500 Subject: [PATCH 1/3] added testing for archive MIME types --- tests/test_match.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/tests/test_match.py b/tests/test_match.py index dd5b027..0e1a3eb 100644 --- a/tests/test_match.py +++ b/tests/test_match.py @@ -76,3 +76,26 @@ def test_match_video_audio_type_pattern(self, expected_type, resource): def test_match_font_type_pattern(self, expected_type, resource): computed_type = match.match_font_type_pattern(resource) assert computed_type == expected_type + +class TestArchiveMatching: + """ Class to test pattern matching of archive Mimetypes""" + + mime_types = ['application/x-gzip', 'application/zip', 'application/x-rar-compressed'] + content = [ + b'\x1F\x8B\x08', + b'\x50\x4B\x03\x04', + b'\x52\x61\x72\x20\x1A\x07\x00' + ] + + @pytest.mark.parametrize('mime, resource', list(zip(mime_types, content))) + def test_match_archive_pattern(self, mime, resource): + computed_type = match.match_archive_type_pattern(resource) + actual_type = parse_mime_type(mime) + assert computed_type == actual_type + + @pytest.mark.parametrize('expected_type, resource', get_resource_test_list(["archive"])) + def test_match_archive_pattern_wfile(self, expected_type, resource): + computed_type = match.match_archive_type_pattern(resource) + assert computed_type == expected_type + + \ No newline at end of file From 6a00d39f276ebdec947c59e499c7ec4e88d0d62c Mon Sep 17 00:00:00 2001 From: Lia Date: Thu, 5 Nov 2020 20:18:12 -0500 Subject: [PATCH 2/3] added test for archive MIME types --- tests/test_match.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_match.py b/tests/test_match.py index 0e1a3eb..7e1154f 100644 --- a/tests/test_match.py +++ b/tests/test_match.py @@ -94,8 +94,8 @@ def test_match_archive_pattern(self, mime, resource): assert computed_type == actual_type @pytest.mark.parametrize('expected_type, resource', get_resource_test_list(["archive"])) - def test_match_archive_pattern_wfile(self, expected_type, resource): + def test_match_archive_pattern(self, expected_type, resource): computed_type = match.match_archive_type_pattern(resource) assert computed_type == expected_type - \ No newline at end of file + From 6fc8939c1cdc7fe02daf2f5ea7935022ee7cfbef Mon Sep 17 00:00:00 2001 From: Lia Date: Thu, 5 Nov 2020 20:27:15 -0500 Subject: [PATCH 3/3] added test for archive MIME types --- tests/test_match.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tests/test_match.py b/tests/test_match.py index 7e1154f..63e55ab 100644 --- a/tests/test_match.py +++ b/tests/test_match.py @@ -94,8 +94,7 @@ def test_match_archive_pattern(self, mime, resource): assert computed_type == actual_type @pytest.mark.parametrize('expected_type, resource', get_resource_test_list(["archive"])) - def test_match_archive_pattern(self, expected_type, resource): + def test_match_archive_pattern_file(self, expected_type, resource): computed_type = match.match_archive_type_pattern(resource) assert computed_type == expected_type - - + \ No newline at end of file