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

Jérémy Bobbio lunar at moszumanska.debian.org
Wed Jun 24 18:26:17 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 2672815f8a467bb5bbec5f7161bd6af51d154458
Author: Jérémy Bobbio <lunar at debian.org>
Date:   Wed Jun 24 17:44:36 2015 +0000

    Add tests for .deb comparator
---
 tests/comparators/test_deb.py         |  45 ++++++++++++++++++++++++++++++++++
 tests/data/deb_metadata_expected_diff |   6 +++++
 tests/data/test1.deb                  | Bin 0 -> 2262 bytes
 tests/data/test2.deb                  | Bin 0 -> 2388 bytes
 4 files changed, 51 insertions(+)

diff --git a/tests/comparators/test_deb.py b/tests/comparators/test_deb.py
new file mode 100644
index 0000000..4f0d872
--- /dev/null
+++ b/tests/comparators/test_deb.py
@@ -0,0 +1,45 @@
+#!/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.deb import compare_deb_files
+
+TEST_FILE1_PATH = os.path.join(os.path.dirname(__file__), '../data/test1.deb')
+TEST_FILE2_PATH = os.path.join(os.path.dirname(__file__), '../data/test2.deb')
+
+def test_no_differences():
+    differences = compare_deb_files(TEST_FILE1_PATH, TEST_FILE1_PATH)
+    assert len(differences) == 0
+
+ at pytest.fixture
+def differences():
+    return compare_deb_files(TEST_FILE1_PATH, TEST_FILE2_PATH)[0].details # skip container with path
+
+def test_compressed_files(differences):
+    assert differences[0].source1 == 'control.tar.gz'
+    assert differences[1].source1 == 'data.tar.gz'
+
+def test_metadata(differences):
+    expected_diff = open(os.path.join(os.path.dirname(__file__), '../data/deb_metadata_expected_diff')).read()
+    assert differences[-1].unified_diff == expected_diff
+
diff --git a/tests/data/deb_metadata_expected_diff b/tests/data/deb_metadata_expected_diff
new file mode 100644
index 0000000..8c6c572
--- /dev/null
+++ b/tests/data/deb_metadata_expected_diff
@@ -0,0 +1,6 @@
+@@ -1,3 +1,3 @@
+ rw-r--r-- 0/0      4 Jun 24 17:40 2015 debian-binary
+-rw-r--r-- 0/0    444 Jun 24 17:40 2015 control.tar.gz
+-rw-r--r-- 0/0   1626 Jun 24 17:40 2015 data.tar.gz
++rw-r--r-- 0/0    442 Jun 24 17:40 2015 control.tar.gz
++rw-r--r-- 0/0   1754 Jun 24 17:40 2015 data.tar.gz
diff --git a/tests/data/test1.deb b/tests/data/test1.deb
new file mode 100644
index 0000000..0dd596f
Binary files /dev/null and b/tests/data/test1.deb differ
diff --git a/tests/data/test2.deb b/tests/data/test2.deb
new file mode 100644
index 0000000..c98c976
Binary files /dev/null and b/tests/data/test2.deb 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