comparison 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
comparison
equal deleted inserted replaced
412:58ecf7c0ecba 413:94a6ae627b31
11 import os.path 11 import os.path
12 import sys 12 import sys
13 13
14 test_dir = os.path.dirname(__file__) 14 test_dir = os.path.dirname(__file__)
15 sys.path.append(os.path.join(test_dir, os.pardir)) 15 sys.path.append(os.path.join(test_dir, os.pardir))
16 sys.path.append(os.path.join(test_dir, os.pardir, "bin"))
16 17
17 from treepkg.info.status import * 18 from treepkg.info.status import *
18 from treepkg.report import get_packager_group 19 from treepkg.report import get_packager_group
19 from filesupport import FileTestMixin 20 from filesupport import FileTestMixin
21
22 from publishdebianpackages import get_binary_arch
23 from publishdebianpackages import Package
24 from publishdebianpackages import CacheDb
20 25
21 class TreepkgInfoTest(unittest.TestCase, FileTestMixin): 26 class TreepkgInfoTest(unittest.TestCase, FileTestMixin):
22 config_contents = """\ 27 config_contents = """\
23 [DEFAULT] 28 [DEFAULT]
24 #treepkg_dir: /home/builder/mill 29 #treepkg_dir: /home/builder/mill
67 sys.path = self.old_path 72 sys.path = self.old_path
68 73
69 def test_createinfo(self): 74 def test_createinfo(self):
70 config_file = os.path.join(self.directory, "treepkg.cfg") 75 config_file = os.path.join(self.directory, "treepkg.cfg")
71 tpkginfo = TreepkgInfo(config_file) 76 tpkginfo = TreepkgInfo(config_file)
72 print tpkginfo.toxml().toxml() 77 tpkgrootinfo = tpkginfo.tpkgroot.info
73 tpkgroot = tpkginfo.tpkgroot 78 self.assertEquals("testtreepkginfo", tpkgrootinfo.name)
74 self.assertEquals("testtreepkginfo", tpkgroot.name)
75 79
76 80
77 class TreepkgRootInfoTest(unittest.TestCase): 81 class TreepkgRootInfoTest(unittest.TestCase):
78 82
79 def test_toxml(self): 83 def test_toxml(self):
80 status = TreepkgRootInfo("testtreepkg") 84 status = TreepkgRootInfo("testtreepkg")
81 dom = status.toxml() 85 dom = status.toxml()
82 xml = dom.toxml() 86 xml = dom.toxml()
83 self.assertEquals("<status><name>testtreepkg</name></status>", xml) 87 self.assertEquals("<info><name>testtreepkg</name></info>", xml)
88
89 class TestPublishDebianPackages(unittest.TestCase, FileTestMixin):
90
91 def test_get_binary_arch(self):
92 source = get_binary_arch("source")
93 self.assertEquals("source", source)
94 binary_armel = get_binary_arch("armel")
95 self.assertEquals("binary-armel", binary_armel)
96 binary_armel = get_binary_arch("binary-armel")
97 self.assertEquals("binary-armel", binary_armel)
98
99 def test_cache_db(self):
100 tmpdir = self.create_test_specific_temp_dir()
101 package = Package("/tmp/abc/abc_0.1_i386.deb", "abc",
102 "abc_0.1_i386.deb", "/source/abc/abc_0.1_i386.deb",
103 "binary-i386", "1234567")
104 # tmpfile = self.create_temp_file("cachedb1", "abc")
105 # with self.assertRaises(Exception):
106 # db = CacheDb(tmpfile)
107
108 dbfile = os.path.join(tmpdir, "cachedb2")
109 db = CacheDb(dbfile)
110 db.add_package(package)
111
112 # test get_package and get_timestamp
113 package2 = db.get_package(package.filename)
114 self.assertNotEquals(None, package2)
115 self.assertEquals(package.filename, package2.filename)
116 self.assertEquals(package.name, package2.name)
117 self.assertEquals(package.sourcepath, package2.sourcepath)
118 self.assertEquals(package.arch, package2.arch)
119 self.assertEquals(package.md5sum, package2.md5sum)
120
121 # test get_old_packages
122 package3 = Package("/tmp/foo/foo_0.2.i386.deb", "foo",
123 "foo_0.2_i386.deb", "/tmp/foo/foo_0.2.i386.deb",
124 "binary-i386", "987654321")
125 db.add_package(package3)
126 oldpackages = db.get_old_packages([package.filename])
127 self.assertEquals(1, len(oldpackages))
128 packages = db.get_packages()
129 self.assertEquals(2, len(packages))
130 db.remove_packages([package.filename for package in oldpackages])
131 packages = db.get_packages()
132 self.assertEquals(1, len(packages))
84 133
85 if __name__ == '__main__': 134 if __name__ == '__main__':
86 unittest.main() 135 unittest.main()
87 136
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)