tests: add unit tests for gbp.rpm.SrcRpmFile
authorMarkus Lehtonen <markus.lehtonen@linux.intel.com>
Thu, 13 Nov 2014 16:33:45 +0000 (18:33 +0200)
committerMarkus Lehtonen <markus.lehtonen@linux.intel.com>
Fri, 14 Nov 2014 12:45:07 +0000 (14:45 +0200)
Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
tests/20_test_rpm.py
tests/data/rpm/srpms/gbp-test-1.0-1.src.rpm [new file with mode: 0644]
tests/data/rpm/srpms/gbp-test-native-1.0-1.src.rpm [new file with mode: 0644]
tests/data/rpm/srpms/gbp-test-native2-2.0-0.src.rpm [new file with mode: 0644]
tests/data/rpm/srpms/gbp-test2-3.0-0.src.rpm [new file with mode: 0644]

index 227a1c681ed2244cef115f206f4a327281272610..7125b4c496c087b45330a31a7101cc8458772d31 100644 (file)
@@ -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 '\
+                                '<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']:
+            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 (file)
index 0000000..74afbd6
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 (file)
index 0000000..1002aae
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 (file)
index 0000000..880b310
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 (file)
index 0000000..1cf12c7
Binary files /dev/null and b/tests/data/rpm/srpms/gbp-test2-3.0-0.src.rpm differ