comparison test/test_info_data.py @ 416:4980f8d5014a treepkg-status

first version of incremental copying debian packages to cachedir
author Bjoern Ricks <bricks@intevation.de>
date Mon, 26 Jul 2010 10:12:40 +0000
parents e0539b483b04
children c8268d40d35d
comparison
equal deleted inserted replaced
415:2d31eea39f70 416:4980f8d5014a
29 # with self.assertRaises(Exception): 29 # with self.assertRaises(Exception):
30 # db = CacheDb(tmpfile) 30 # db = CacheDb(tmpfile)
31 31
32 dbfile = os.path.join(tmpdir, "cachedb2") 32 dbfile = os.path.join(tmpdir, "cachedb2")
33 db = CacheDb(dbfile) 33 db = CacheDb(dbfile)
34 # insert
35 filename = package.filename
34 db.add_package(package) 36 db.add_package(package)
37 package = db.get_package(filename)
38 self.assertEquals("1234567", package.md5sum)
39 # update
40 package.md5sum = "01234567"
41 db.add_package(package)
42 package = db.get_package(filename)
43 self.assertEquals("01234567", package.md5sum)
35 44
36 # test get_package and get_timestamp 45 # test get_package
37 package2 = db.get_package(package.filename) 46 package2 = db.get_package(package.filename)
38 self.assertNotEquals(None, package2) 47 self.assertNotEquals(None, package2)
39 self.assertEquals(package.filename, package2.filename) 48 self.assertEquals(package.filename, package2.filename)
40 self.assertEquals(package.name, package2.name) 49 self.assertEquals(package.name, package2.name)
41 self.assertEquals(package.sourcepath, package2.sourcepath) 50 self.assertEquals(package.sourcepath, package2.sourcepath)
42 self.assertEquals(package.arch, package2.arch) 51 self.assertEquals(package.arch, package2.arch)
43 self.assertEquals(package.md5sum, package2.md5sum) 52 self.assertEquals(package.md5sum, package2.md5sum)
44 53
54 package3 = Package("/tmp/foo/foo_0.2.i386.deb", "foo",
55 "foo_0.2_i386.deb", "/tmp/source/foo/foo_0.2.i386.deb",
56 "binary-i386", "987654321")
57 package4 = Package("/tmp/john/doe_0.3.i386.deb", "john",
58 "doe_0.3.i386.deb", "/tmp/source/john/doe_0.3.i386.deb",
59 "binary-i386", "5671234")
60 db.add_package(package3)
61 db.add_package(package4)
62
45 # test get_old_packages 63 # test get_old_packages
46 package3 = Package("/tmp/foo/foo_0.2.i386.deb", "foo",
47 "foo_0.2_i386.deb", "/tmp/foo/foo_0.2.i386.deb",
48 "binary-i386", "987654321")
49 db.add_package(package3)
50 oldpackages = db.get_old_packages([package.filename]) 64 oldpackages = db.get_old_packages([package.filename])
51 self.assertEquals(1, len(oldpackages)) 65 self.assertEquals(2, len(oldpackages))
52 packages = db.get_packages() 66 packages = db.get_packages()
53 self.assertEquals(2, len(packages)) 67 self.assertEquals(3, len(packages))
54 db.remove_packages([package.filename for package in oldpackages]) 68 db.remove_packages(oldpackages)
55 packages = db.get_packages() 69 packages = db.get_packages()
56 self.assertEquals(1, len(packages)) 70 self.assertEquals(1, len(packages))
57 71
58 if __name__ == '__main__': 72 if __name__ == '__main__':
59 unittest.main() 73 unittest.main()
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)