diff options
author | Markus Lehtonen <markus.lehtonen@linux.intel.com> | 2014-11-13 18:33:45 +0200 |
---|---|---|
committer | Guido Günther <agx@sigxcpu.org> | 2015-04-01 08:47:06 +0200 |
commit | 5a74d4e2b683547a19827a0b7557e9f73b35fb25 (patch) | |
tree | 2a59d17e653d3b21f9f6a9456aeecc1059b73591 | |
parent | 9455ae3934366f7dcd2586c284d413d6756856a8 (diff) |
tests: add unit tests for gbp.rpm.SrcRpmFile
Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
-rw-r--r-- | tests/20_test_rpm.py | 33 | ||||
-rw-r--r-- | tests/data/rpm/srpms/gbp-test-1.0-1.src.rpm | bin | 0 -> 3427 bytes | |||
-rw-r--r-- | tests/data/rpm/srpms/gbp-test2-3.0-0.src.rpm | bin | 0 -> 3507 bytes |
3 files changed, 30 insertions, 3 deletions
diff --git a/tests/20_test_rpm.py b/tests/20_test_rpm.py index 026333e8..d01192db 100644 --- a/tests/20_test_rpm.py +++ b/tests/20_test_rpm.py @@ -20,11 +20,11 @@ import filecmp import os import shutil import tempfile -from nose.tools import assert_raises, eq_ # pylint: disable=E0611 +from nose.tools import assert_raises, eq_, ok_ # pylint: disable=E0611 from gbp.errors import GbpError -from gbp.rpm import (SpecFile, NoSpecError, guess_spec, guess_spec_repo, - spec_from_repo) +from gbp.rpm import (SpecFile, SrcRpmFile, NoSpecError, guess_spec, + guess_spec_repo, spec_from_repo) from gbp.git.repository import GitRepository # Disable "Method could be a function" @@ -58,6 +58,33 @@ 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')) + eq_(srpm.version, {'release': '1', 'upstreamversion': '1.0'}) + eq_(srpm.name, 'gbp-test') + eq_(srpm.upstreamversion, '1.0') + eq_(srpm.packager, 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')) + eq_(srpm.version, {'release': '0', 'upstreamversion': '3.0', + 'epoch': '2'}) + eq_(srpm.packager, 'Markus Lehtonen <markus.lehtonen@linux.intel.com>') + + 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']: + ok_(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 Binary files differnew file mode 100644 index 00000000..74afbd6c --- /dev/null +++ b/tests/data/rpm/srpms/gbp-test-1.0-1.src.rpm 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 Binary files differnew file mode 100644 index 00000000..1cf12c7a --- /dev/null +++ b/tests/data/rpm/srpms/gbp-test2-3.0-0.src.rpm |