diff test/test_info.py @ 413:94a6ae627b31 treepkg-status

implemented CacheDb to store copied Packages from build host
author Bjoern Ricks <bricks@intevation.de>
date Fri, 23 Jul 2010 16:40:38 +0000
parents e2afbd3c2bf1
children e0539b483b04
line wrap: on
line diff
--- a/test/test_info.py	Thu Jul 22 16:01:43 2010 +0000
+++ b/test/test_info.py	Fri Jul 23 16:40:38 2010 +0000
@@ -13,11 +13,16 @@
 
 test_dir = os.path.dirname(__file__)
 sys.path.append(os.path.join(test_dir, os.pardir))
+sys.path.append(os.path.join(test_dir, os.pardir, "bin"))
 
 from treepkg.info.status import *
 from treepkg.report import get_packager_group
 from filesupport import FileTestMixin
 
+from publishdebianpackages import get_binary_arch
+from publishdebianpackages import Package
+from publishdebianpackages import CacheDb
+
 class TreepkgInfoTest(unittest.TestCase, FileTestMixin):
     config_contents = """\
 [DEFAULT]
@@ -69,9 +74,8 @@
     def test_createinfo(self):
         config_file = os.path.join(self.directory, "treepkg.cfg")
         tpkginfo = TreepkgInfo(config_file)
-        print tpkginfo.toxml().toxml()
-        tpkgroot = tpkginfo.tpkgroot
-        self.assertEquals("testtreepkginfo", tpkgroot.name)
+        tpkgrootinfo = tpkginfo.tpkgroot.info
+        self.assertEquals("testtreepkginfo", tpkgrootinfo.name)
  
 
 class TreepkgRootInfoTest(unittest.TestCase):
@@ -80,7 +84,52 @@
         status = TreepkgRootInfo("testtreepkg")
         dom = status.toxml()
         xml = dom.toxml()
-        self.assertEquals("<status><name>testtreepkg</name></status>", xml)
+        self.assertEquals("<info><name>testtreepkg</name></info>", xml)
+
+class TestPublishDebianPackages(unittest.TestCase, FileTestMixin):
+
+    def test_get_binary_arch(self):
+        source = get_binary_arch("source")
+        self.assertEquals("source", source)
+        binary_armel = get_binary_arch("armel")
+        self.assertEquals("binary-armel", binary_armel)
+        binary_armel = get_binary_arch("binary-armel")
+        self.assertEquals("binary-armel", binary_armel)
+
+    def test_cache_db(self):
+        tmpdir = self.create_test_specific_temp_dir()
+        package = Package("/tmp/abc/abc_0.1_i386.deb", "abc",
+            "abc_0.1_i386.deb", "/source/abc/abc_0.1_i386.deb", 
+            "binary-i386", "1234567")
+#        tmpfile = self.create_temp_file("cachedb1", "abc")
+#        with self.assertRaises(Exception):
+#            db = CacheDb(tmpfile)
+
+        dbfile = os.path.join(tmpdir, "cachedb2")
+        db = CacheDb(dbfile)
+        db.add_package(package)
+
+        # test get_package and get_timestamp
+        package2 = db.get_package(package.filename)
+        self.assertNotEquals(None, package2)
+        self.assertEquals(package.filename, package2.filename)
+        self.assertEquals(package.name, package2.name)
+        self.assertEquals(package.sourcepath, package2.sourcepath)
+        self.assertEquals(package.arch, package2.arch)
+        self.assertEquals(package.md5sum, package2.md5sum)
+
+        # test get_old_packages
+        package3 = Package("/tmp/foo/foo_0.2.i386.deb", "foo",
+            "foo_0.2_i386.deb", "/tmp/foo/foo_0.2.i386.deb",
+            "binary-i386", "987654321")
+        db.add_package(package3)
+        oldpackages = db.get_old_packages([package.filename])
+        self.assertEquals(1, len(oldpackages))
+        packages = db.get_packages()
+        self.assertEquals(2, len(packages))
+        db.remove_packages([package.filename for package in oldpackages])
+        packages = db.get_packages()
+        self.assertEquals(1, len(packages))
 
 if __name__ == '__main__':
     unittest.main()
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)