add unittest test case
authorGuan Junchun <junchunx.guan@intel.com>
Mon, 26 Mar 2012 10:14:01 +0000 (18:14 +0800)
committerGuan Junchun <junchunx.guan@intel.com>
Mon, 26 Mar 2012 10:14:01 +0000 (18:14 +0800)
1. test UpstreamTarball class in utils.py
    test tarball format is supported or not, .tar.bz2, .tar.gz, .tar.tgz, .zip

Makefile
tests/test_gbs_utils.py [new file with mode: 0644]

index f495150..3e8c446 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -45,4 +45,4 @@ clean:
        rm -rf dist/
        rm -rf *.egg-info/
 test:
-       nosetests tests
+       nosetests tests -v
diff --git a/tests/test_gbs_utils.py b/tests/test_gbs_utils.py
new file mode 100644 (file)
index 0000000..9a7ac9c
--- /dev/null
@@ -0,0 +1,44 @@
+import unittest
+#import os
+from gitbuildsys import utils
+
+class TestUpsteramTarball(unittest.TestCase):
+    """test class UpstreamTarBall in utils"""
+
+    def setUp(self):
+        """Init a tarball base name"""
+        self.pkgname, self.version = ('osc-perm', '5.1.1')
+
+    def _testTarballFormat(self, postfix):
+        """test the sepecified tarball format is supported or not"""
+        obj = utils.UpstreamTarball(self.pkgname+'-'+self.version+postfix)
+        pkg, ver = obj.guess_version() or ('', '')
+        self.assertEqual(pkg, self.pkgname)
+        self.assertEqual(ver, self.version)
+
+    def testGZ(self):
+
+        self._testTarballFormat('.tar.gz')
+
+    def testBZ2(self):
+
+        self._testTarballFormat('.tar.bz2')
+
+    def testTizen(self):
+
+        self._testTarballFormat('-tizen.tar.bz2')
+        
+    def testZIP(self):
+
+        self._testTarballFormat('.zip')
+
+    def testTGZ(self):
+
+        self._testTarballFormat('.tgz')
+
+    def testNegative(self):
+
+        self._testTarballFormat('.src.rpm')
+        self._testTarballFormat('.orig.tar.gz')
+#if __name__ = '__main__'
+#    unittest.main()