From 85e742216d28b5afd0690c8d229ee49ec9c80c4d Mon Sep 17 00:00:00 2001 From: Markus Lehtonen Date: Thu, 13 Nov 2014 18:33:45 +0200 Subject: tests: add unit tests for gbp.rpm.SrcRpmFile Signed-off-by: Markus Lehtonen --- tests/20_test_rpm.py | 28 +++++++++++++++++++++ tests/data/rpm/srpms/gbp-test-1.0-1.src.rpm | Bin 0 -> 3427 bytes tests/data/rpm/srpms/gbp-test-native-1.0-1.src.rpm | Bin 0 -> 2187 bytes .../data/rpm/srpms/gbp-test-native2-2.0-0.src.rpm | Bin 0 -> 2008 bytes tests/data/rpm/srpms/gbp-test2-3.0-0.src.rpm | Bin 0 -> 3507 bytes 5 files changed, 28 insertions(+) create mode 100644 tests/data/rpm/srpms/gbp-test-1.0-1.src.rpm create mode 100644 tests/data/rpm/srpms/gbp-test-native-1.0-1.src.rpm create mode 100644 tests/data/rpm/srpms/gbp-test-native2-2.0-0.src.rpm create mode 100644 tests/data/rpm/srpms/gbp-test2-3.0-0.src.rpm (limited to 'tests') diff --git a/tests/20_test_rpm.py b/tests/20_test_rpm.py index 227a1c68..7125b4c4 100644 --- a/tests/20_test_rpm.py +++ b/tests/20_test_rpm.py @@ -58,6 +58,34 @@ class RpmTestBase(object): """Test case teardown""" shutil.rmtree(self.tmpdir) +class TestSrcRpmFile(RpmTestBase): + """Test L{gbp.rpm.SrcRpmFile}""" + + def test_srpm(self): + """Test parsing of a source rpm""" + srpm = SrcRpmFile(os.path.join(SRPM_DIR, 'gbp-test-1.0-1.src.rpm')) + assert srpm.version == {'release': '1', 'upstreamversion': '1.0'} + assert srpm.name == 'gbp-test' + assert srpm.upstreamversion == '1.0' + assert srpm.packager is None + + def test_srpm_2(self): + """Test parsing of another source rpm""" + srpm = SrcRpmFile(os.path.join(SRPM_DIR, 'gbp-test2-3.0-0.src.rpm')) + assert srpm.version == {'release': '0', 'upstreamversion': '3.0', + 'epoch': '2'} + assert srpm.packager == 'Markus Lehtonen '\ + '' + + def test_unpack_srpm(self): + """Test unpacking of a source rpm""" + srpm = SrcRpmFile(os.path.join(SRPM_DIR, 'gbp-test-1.0-1.src.rpm')) + srpm.unpack(self.tmpdir) + for fn in ['gbp-test-1.0.tar.bz2', 'foo.txt', 'bar.tar.gz', 'my.patch', + 'my2.patch', 'my3.patch']: + assert os.path.exists(os.path.join(self.tmpdir, fn)), \ + "%s not found" % fn + class TestSpecFile(RpmTestBase): """Test L{gbp.rpm.SpecFile}""" diff --git a/tests/data/rpm/srpms/gbp-test-1.0-1.src.rpm b/tests/data/rpm/srpms/gbp-test-1.0-1.src.rpm new file mode 100644 index 00000000..74afbd6c Binary files /dev/null and b/tests/data/rpm/srpms/gbp-test-1.0-1.src.rpm differ diff --git a/tests/data/rpm/srpms/gbp-test-native-1.0-1.src.rpm b/tests/data/rpm/srpms/gbp-test-native-1.0-1.src.rpm new file mode 100644 index 00000000..1002aaea Binary files /dev/null and b/tests/data/rpm/srpms/gbp-test-native-1.0-1.src.rpm differ diff --git a/tests/data/rpm/srpms/gbp-test-native2-2.0-0.src.rpm b/tests/data/rpm/srpms/gbp-test-native2-2.0-0.src.rpm new file mode 100644 index 00000000..880b3100 Binary files /dev/null and b/tests/data/rpm/srpms/gbp-test-native2-2.0-0.src.rpm differ diff --git a/tests/data/rpm/srpms/gbp-test2-3.0-0.src.rpm b/tests/data/rpm/srpms/gbp-test2-3.0-0.src.rpm new file mode 100644 index 00000000..1cf12c7a Binary files /dev/null and b/tests/data/rpm/srpms/gbp-test2-3.0-0.src.rpm differ -- cgit v1.2.3