[Reproducible-commits] [debbindiff] 01/03: Add tests for Zip comparator

Jérémy Bobbio lunar at moszumanska.debian.org
Wed Jun 24 14:19:03 UTC 2015


This is an automated email from the git hooks/post-receive script.

lunar pushed a commit to branch master
in repository debbindiff.

commit 96f601677d032efdd712beaa1066b01a0a6e357c
Author: Jérémy Bobbio <lunar at debian.org>
Date:   Wed Jun 24 13:48:22 2015 +0000

    Add tests for Zip comparator
---
 tests/comparators/test_zip.py        |  52 +++++++++++++++++++++++++++++++++++
 tests/data/test1.zip                 | Bin 0 -> 571 bytes
 tests/data/test2.zip                 | Bin 0 -> 714 bytes
 tests/data/zip_zipinfo_expected_diff |  10 +++++++
 4 files changed, 62 insertions(+)

diff --git a/tests/comparators/test_zip.py b/tests/comparators/test_zip.py
new file mode 100644
index 0000000..9713593
--- /dev/null
+++ b/tests/comparators/test_zip.py
@@ -0,0 +1,52 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+#
+# debbindiff: highlight differences between two builds of Debian packages
+#
+# Copyright © 2015 Jérémy Bobbio <lunar at debian.org>
+#
+# debbindiff is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# debbindiff is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with debbindiff.  If not, see <http://www.gnu.org/licenses/>.
+
+import codecs
+import os.path
+import shutil
+import pytest
+from debbindiff.comparators.zip import compare_zip_files
+
+TEST_FILE1_PATH = os.path.join(os.path.dirname(__file__), '../data/test1.zip') 
+TEST_FILE2_PATH = os.path.join(os.path.dirname(__file__), '../data/test2.zip') 
+
+def test_no_differences():
+    differences = compare_zip_files(TEST_FILE1_PATH, TEST_FILE1_PATH)
+    assert len(differences) == 0
+
+ at pytest.fixture
+def differences():
+    return compare_zip_files(TEST_FILE1_PATH, TEST_FILE2_PATH)[0].details # skip container with path
+
+def test_compressed_files(differences):
+    assert differences[0].source1 == 'dir/text'
+    assert differences[0].source2 == 'dir/text'
+    expected_diff = open(os.path.join(os.path.dirname(__file__), '../data/text_ascii_expected_diff')).read()
+    assert differences[0].unified_diff == expected_diff
+
+def test_metadata(differences):
+    expected_diff = open(os.path.join(os.path.dirname(__file__), '../data/zip_zipinfo_expected_diff')).read()
+    assert differences[-1].unified_diff == expected_diff
+
+def test_bad_zip():
+    differences = compare_zip_files(os.path.join(os.path.dirname(__file__), '../data/text_unicode1'),
+                                    os.path.join(os.path.dirname(__file__), '../data/text_unicode2'))
+    expected_diff = open(os.path.join(os.path.dirname(__file__), '../data/text_unicode_binary_fallback')).read()
+    assert differences[0].unified_diff == expected_diff
diff --git a/tests/data/test1.zip b/tests/data/test1.zip
new file mode 100644
index 0000000..ff852cf
Binary files /dev/null and b/tests/data/test1.zip differ
diff --git a/tests/data/test2.zip b/tests/data/test2.zip
new file mode 100644
index 0000000..5d7d5ac
Binary files /dev/null and b/tests/data/test2.zip differ
diff --git a/tests/data/zip_zipinfo_expected_diff b/tests/data/zip_zipinfo_expected_diff
new file mode 100644
index 0000000..411af85
--- /dev/null
+++ b/tests/data/zip_zipinfo_expected_diff
@@ -0,0 +1,10 @@
+@@ -1,5 +1,5 @@
+-Archive:  test1.zip
+-Zip file size: 571 bytes, number of entries: 2
++Archive:  test2.zip
++Zip file size: 714 bytes, number of entries: 2
+ drwxr-xr-x  3.0 unx        0 bx stor 15-Jun-24 13:44 dir/
+--rw-r--r--  3.0 unx      446 tx defN 15-Jun-24 13:44 dir/text
+-2 files, 446 bytes uncompressed, 269 bytes compressed:  39.7%
++-rw-r--r--  3.0 unx      671 tx defN 15-Jun-24 13:45 dir/text
++2 files, 671 bytes uncompressed, 412 bytes compressed:  38.6%

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reproducible/debbindiff.git



More information about the Reproducible-commits mailing list