[Reproducible-commits] [debbindiff] 07/07: Add tests for .changes comparator

Jérémy Bobbio lunar at moszumanska.debian.org
Sat Jun 27 08:59:11 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 72f2e9f0ac7f9417eb9c3f316724e7338c6ec830
Author: Jérémy Bobbio <lunar at debian.org>
Date:   Sat Jun 27 08:57:11 2015 +0000

    Add tests for .changes comparator
---
 tests/comparators/test_debian.py                 | 65 ++++++++++++++++++++++++
 tests/data/dot_changes_description_expected_diff |  4 ++
 tests/data/test1.changes                         | 22 ++++++++
 tests/data/test2.changes                         | 22 ++++++++
 4 files changed, 113 insertions(+)

diff --git a/tests/comparators/test_debian.py b/tests/comparators/test_debian.py
new file mode 100644
index 0000000..4fc4a83
--- /dev/null
+++ b/tests/comparators/test_debian.py
@@ -0,0 +1,65 @@
+#!/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
+import debbindiff.comparators.deb
+from debbindiff.comparators.debian import compare_dot_changes_files
+from debbindiff.presenters.text import output_text
+
+TEST_DOT_CHANGES_FILE1_PATH = os.path.join(os.path.dirname(__file__), '../data/test1.changes')
+TEST_DOT_CHANGES_FILE2_PATH = os.path.join(os.path.dirname(__file__), '../data/test2.changes')
+TEST_DEB_FILE1_PATH = os.path.join(os.path.dirname(__file__), '../data/test1.deb')
+TEST_DEB_FILE2_PATH = os.path.join(os.path.dirname(__file__), '../data/test2.deb')
+
+ at pytest.fixture
+def copydeb(tmpdir):
+    changes1_path = str(tmpdir.join('a/test_1.changes'))
+    changes2_path = str(tmpdir.join('b/test_1.changes'))
+    tmpdir.mkdir('a')
+    tmpdir.mkdir('b')
+    shutil.copy(TEST_DOT_CHANGES_FILE1_PATH, changes1_path)
+    shutil.copy(TEST_DOT_CHANGES_FILE2_PATH, changes2_path)
+    shutil.copy(TEST_DEB_FILE1_PATH, str(tmpdir.join('a/test_1_all.deb')))
+    shutil.copy(TEST_DEB_FILE2_PATH, str(tmpdir.join('b/test_1_all.deb')))
+    return (changes1_path, changes2_path)
+
+def test_no_differences(copydeb):
+    changes1_path, _ = copydeb
+    difference = compare_dot_changes_files(changes1_path, changes1_path)
+    assert difference is None
+
+ at pytest.fixture
+def differences(copydeb):
+    changes1_path, changes2_path = copydeb
+    difference = compare_dot_changes_files(changes1_path, changes2_path)
+    output_text(difference, print_func=print)
+    return difference.details
+
+def test_description(differences):
+    assert differences[0]
+    expected_diff = open(os.path.join(os.path.dirname(__file__), '../data/dot_changes_description_expected_diff')).read()
+    assert differences[0].unified_diff == expected_diff
+
+def test_internal_diff(differences):
+    assert differences[2].source1 == 'test_1_all.deb'
diff --git a/tests/data/dot_changes_description_expected_diff b/tests/data/dot_changes_description_expected_diff
new file mode 100644
index 0000000..abb0f92
--- /dev/null
+++ b/tests/data/dot_changes_description_expected_diff
@@ -0,0 +1,4 @@
+@@ -1,2 +1,2 @@
+ 
+- test - just a test package
++ test - just a simple test package
diff --git a/tests/data/test1.changes b/tests/data/test1.changes
new file mode 100644
index 0000000..b32e971
--- /dev/null
+++ b/tests/data/test1.changes
@@ -0,0 +1,22 @@
+Format: 1.8
+Date: Sat, 04 Apr 2015 18:30:48 +0200
+Source: test
+Binary: test
+Architecture: source all
+Version: 1
+Distribution: unstable
+Urgency: low
+Maintainer: Someone Else <user at example.org>
+Changed-By: Someone Else <user at example.org>
+Description:
+ test - just a test package
+Changes:
+ test (1) unstable; urgency=low
+ .
+   * Test package.
+Checksums-Sha1:
+ b21eeec5004853c4955d5b856a6546068c2d7dc9 2262 test_1_all.deb
+Checksums-Sha256:
+ d2b2ea8b9cf8ef645a328cdb882586ee465e141fc66a2dbe1ad29b29ac1e7920 2262 test_1_all.deb
+Files:
+ 660ad4713e5d8271df2e7e86bf246dc0 2262 devel optional test_1_all.deb
diff --git a/tests/data/test2.changes b/tests/data/test2.changes
new file mode 100644
index 0000000..3e33d3a
--- /dev/null
+++ b/tests/data/test2.changes
@@ -0,0 +1,22 @@
+Format: 1.8
+Date: Sat, 04 Apr 2015 18:30:48 +0200
+Source: test
+Binary: test
+Architecture: source all
+Version: 1
+Distribution: unstable
+Urgency: low
+Maintainer: Someone Else <user at example.org>
+Changed-By: Someone Else <user at example.org>
+Description:
+ test - just a simple test package
+Changes:
+ test (1) unstable; urgency=low
+ .
+   * Test package.
+Checksums-Sha1:
+ 70982664db2015334bff6441b429d7e3c58dbecb 2388 test_1_all.deb
+Checksums-Sha256:
+ 2f2e45ee3a5fdacd9b30133ec728121588bf9b97af3b947b3882b2b28a0555da 2388 test_1_all.deb
+Files:
+ d323c454462407fe3bfde31a74b23eba 2388 devel optional test_1_all.deb

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