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

Jérémy Bobbio lunar at moszumanska.debian.org
Tue Jun 23 10:55:06 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 d11db6145d7d0c52b120523adbab4be7ff2a4dfe
Author: Jérémy Bobbio <lunar at debian.org>
Date:   Tue Jun 23 10:54:58 2015 +0000

    Add tests for gzip comparator
---
 tests/comparators/test_gzip.py         |  61 +++++++++++++++++++++++++++++++++
 tests/data/gzip_metadata_expected_diff |   3 ++
 tests/data/test1.gz                    | Bin 0 -> 287 bytes
 tests/data/test2.gz                    | Bin 0 -> 430 bytes
 4 files changed, 64 insertions(+)

diff --git a/tests/comparators/test_gzip.py b/tests/comparators/test_gzip.py
new file mode 100644
index 0000000..de03052
--- /dev/null
+++ b/tests/comparators/test_gzip.py
@@ -0,0 +1,61 @@
+#!/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/>.
+
+from __future__ import print_function
+
+import os.path
+import shutil
+import pytest
+from debbindiff.comparators.gzip import compare_gzip_files
+from debbindiff.presenters.text import output_text
+
+TEST_FILE1_PATH = os.path.join(os.path.dirname(__file__), '../data/test1.gz') 
+TEST_FILE2_PATH = os.path.join(os.path.dirname(__file__), '../data/test2.gz') 
+
+def test_no_differences():
+    differences = compare_gzip_files(TEST_FILE1_PATH, TEST_FILE1_PATH)
+    assert len(differences) == 0
+
+ at pytest.fixture
+def differences():
+    return compare_gzip_files(TEST_FILE1_PATH, TEST_FILE2_PATH)[0].details # skip container with path
+
+def test_metadata(differences):
+    assert differences[0].source1 == 'metadata'
+    assert differences[0].source2 == 'metadata'
+    expected_diff = open(os.path.join(os.path.dirname(__file__), '../data/gzip_metadata_expected_diff')).read()
+    assert differences[0].unified_diff == expected_diff
+
+def test_content_source(differences):
+    assert differences[1].source1 == 'test1'
+    assert differences[1].source2 == 'test2'
+
+def test_content_source_without_extension(tmpdir):
+    path1 = str(tmpdir.join('test1'))
+    path2 = str(tmpdir.join('test2'))
+    shutil.copy(TEST_FILE1_PATH, path1)
+    shutil.copy(TEST_FILE2_PATH, path2)
+    differences = compare_gzip_files(path1, path2)[0].details # skip container
+    assert differences[1].source1 == 'test1-content'
+    assert differences[1].source2 == 'test2-content'
+
+def test_content_diff(differences):
+    expected_diff = open(os.path.join(os.path.dirname(__file__), '../data/text_ascii_expected_diff')).read()
+    assert differences[1].unified_diff == expected_diff
diff --git a/tests/data/gzip_metadata_expected_diff b/tests/data/gzip_metadata_expected_diff
new file mode 100644
index 0000000..cee768e
--- /dev/null
+++ b/tests/data/gzip_metadata_expected_diff
@@ -0,0 +1,3 @@
+@@ -1 +1 @@
+-gzip compressed data, last modified: Tue Jun 23 10:12:28 2015, max compression, from Unix
++gzip compressed data, last modified: Tue Jun 23 10:12:28 2015, from Unix
diff --git a/tests/data/test1.gz b/tests/data/test1.gz
new file mode 100644
index 0000000..79f5b9d
Binary files /dev/null and b/tests/data/test1.gz differ
diff --git a/tests/data/test2.gz b/tests/data/test2.gz
new file mode 100644
index 0000000..4947ff1
Binary files /dev/null and b/tests/data/test2.gz differ

-- 
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