From eadc1561707efcdecd44ca1c203e7cbb63b4d680 Mon Sep 17 00:00:00 2001 From: Charles LeDoux Date: Wed, 27 Dec 2017 18:20:46 -0600 Subject: [PATCH] Add tests for nested compression Why: * To ensure we don't try and unrar a rar.gz file. This change addresses the need by: * Adds test file archive.rar.gz * Add mime check to ensure we get the mime of gzip, not rar. --- tests/data/t.rar.gz | Bin 0 -> 119 bytes tests/data/t.rar.gz.foo | Bin 0 -> 119 bytes tests/test_mime.py | 6 ++++++ 3 files changed, 6 insertions(+) create mode 100644 tests/data/t.rar.gz create mode 100644 tests/data/t.rar.gz.foo diff --git a/tests/data/t.rar.gz b/tests/data/t.rar.gz new file mode 100644 index 0000000000000000000000000000000000000000..ccde84c6d32876a93a138377541a6d10113a8e69 GIT binary patch literal 119 zcmV--0Eqt|iwFpiCPZ2Q19UEOVR8TqN-R>8VrMu%p_qYzmjMEDo|h;zs55W_nM^>; z+_6E$NY*acM%I{}VL>AULrF}DUP(oXAorIe^WN8+&HomaEMM}VL6HFlm_dXMP=|;C ZBf|?vppGN9)eH{o3;;zM3aV}Z004HtEl&Ud literal 0 HcmV?d00001 diff --git a/tests/data/t.rar.gz.foo b/tests/data/t.rar.gz.foo new file mode 100644 index 0000000000000000000000000000000000000000..ccde84c6d32876a93a138377541a6d10113a8e69 GIT binary patch literal 119 zcmV--0Eqt|iwFpiCPZ2Q19UEOVR8TqN-R>8VrMu%p_qYzmjMEDo|h;zs55W_nM^>; z+_6E$NY*acM%I{}VL>AULrF}DUP(oXAorIe^WN8+&HomaEMM}VL6HFlm_dXMP=|;C ZBf|?vppGN9)eH{o3;;zM3aV}Z004HtEl&Ud literal 0 HcmV?d00001 diff --git a/tests/test_mime.py b/tests/test_mime.py index 8b93ce0..a23c81e 100644 --- a/tests/test_mime.py +++ b/tests/test_mime.py @@ -150,6 +150,12 @@ class TestMime (unittest.TestCase): self.mime_test_file("t.tar.bz2.foo", "application/x-tar", "bzip2") self.mime_test_file("t.tbz2.foo", "application/x-tar", "bzip2") + @needs_program('file') + def test_nested_gzip (self): + # Ensure that a file that doesn't natively support encoding does not see the encoding + self.mime_test_file("t.rar.gz", "application/gzip") + self.mime_test_file("t.rar.gz.foo", "application/gzip") + @needs_program('file') @needs_program('gzip') def test_mime_file_gzip (self):