Mercurial > treepkg
comparison test/test_info_data.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 | |
children | 4980f8d5014a |
comparison
equal
deleted
inserted
replaced
413:94a6ae627b31 | 414:e0539b483b04 |
---|---|
1 # Copyright (C) 2010 by Intevation GmbH | |
2 # Authors: | |
3 # Bjoern Ricks <bjoern.ricks@intevation.de> | |
4 # | |
5 # This program is free software under the GPL (>=v2) | |
6 # Read the file COPYING coming with the software for details. | |
7 | |
8 """Tests for treepkg.info.data""" | |
9 | |
10 import unittest | |
11 import os.path | |
12 import sys | |
13 | |
14 test_dir = os.path.dirname(__file__) | |
15 sys.path.append(os.path.join(test_dir, os.pardir)) | |
16 | |
17 from treepkg.info.data import Package | |
18 from treepkg.info.data import CacheDb | |
19 from filesupport import FileTestMixin | |
20 | |
21 class TestCacheDb(unittest.TestCase, FileTestMixin): | |
22 | |
23 def test_cache_db(self): | |
24 tmpdir = self.create_test_specific_temp_dir() | |
25 package = Package("/tmp/abc/abc_0.1_i386.deb", "abc", | |
26 "abc_0.1_i386.deb", "/source/abc/abc_0.1_i386.deb", | |
27 "binary-i386", "1234567") | |
28 # tmpfile = self.create_temp_file("cachedb1", "abc") | |
29 # with self.assertRaises(Exception): | |
30 # db = CacheDb(tmpfile) | |
31 | |
32 dbfile = os.path.join(tmpdir, "cachedb2") | |
33 db = CacheDb(dbfile) | |
34 db.add_package(package) | |
35 | |
36 # test get_package and get_timestamp | |
37 package2 = db.get_package(package.filename) | |
38 self.assertNotEquals(None, package2) | |
39 self.assertEquals(package.filename, package2.filename) | |
40 self.assertEquals(package.name, package2.name) | |
41 self.assertEquals(package.sourcepath, package2.sourcepath) | |
42 self.assertEquals(package.arch, package2.arch) | |
43 self.assertEquals(package.md5sum, package2.md5sum) | |
44 | |
45 # 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]) | |
51 self.assertEquals(1, len(oldpackages)) | |
52 packages = db.get_packages() | |
53 self.assertEquals(2, len(packages)) | |
54 db.remove_packages([package.filename for package in oldpackages]) | |
55 packages = db.get_packages() | |
56 self.assertEquals(1, len(packages)) | |
57 | |
58 if __name__ == '__main__': | |
59 unittest.main() | |
60 |