Mercurial > treepkg
comparison test/test_info.py @ 414:e0539b483b04 treepkg-status
moved data handling in publishdebianpackages into seperate module
author | Bjoern Ricks <bricks@intevation.de> |
---|---|
date | Mon, 26 Jul 2010 08:28:48 +0000 |
parents | 94a6ae627b31 |
children | 3a3cad8f6f60 |
comparison
equal
deleted
inserted
replaced
413:94a6ae627b31 | 414:e0539b483b04 |
---|---|
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")) | |
17 | 16 |
18 from treepkg.info.status import * | 17 from treepkg.info.status import * |
19 from treepkg.report import get_packager_group | 18 from treepkg.report import get_packager_group |
20 from filesupport import FileTestMixin | 19 from filesupport import FileTestMixin |
21 | 20 |
22 from publishdebianpackages import get_binary_arch | 21 from publishdebianpackages import get_binary_arch |
23 from publishdebianpackages import Package | |
24 from publishdebianpackages import CacheDb | |
25 | 22 |
26 class TreepkgInfoTest(unittest.TestCase, FileTestMixin): | 23 class TreepkgInfoTest(unittest.TestCase, FileTestMixin): |
27 config_contents = """\ | 24 config_contents = """\ |
28 [DEFAULT] | 25 [DEFAULT] |
29 #treepkg_dir: /home/builder/mill | 26 #treepkg_dir: /home/builder/mill |
94 binary_armel = get_binary_arch("armel") | 91 binary_armel = get_binary_arch("armel") |
95 self.assertEquals("binary-armel", binary_armel) | 92 self.assertEquals("binary-armel", binary_armel) |
96 binary_armel = get_binary_arch("binary-armel") | 93 binary_armel = get_binary_arch("binary-armel") |
97 self.assertEquals("binary-armel", binary_armel) | 94 self.assertEquals("binary-armel", binary_armel) |
98 | 95 |
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)) | |
133 | 96 |
134 if __name__ == '__main__': | 97 if __name__ == '__main__': |
135 unittest.main() | 98 unittest.main() |
136 | 99 |