Mercurial > treepkg
annotate test/test_info_data.py @ 541:8b49548aa8d4
provide stubs for short_revision number
author | Bjoern Ricks <bricks@intevation.de> |
---|---|
date | Tue, 11 Jan 2011 16:27:02 +0000 |
parents | c8268d40d35d |
children |
rev | line source |
---|---|
414
e0539b483b04
moved data handling in publishdebianpackages into seperate module
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
1 # Copyright (C) 2010 by Intevation GmbH |
e0539b483b04
moved data handling in publishdebianpackages into seperate module
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
2 # Authors: |
e0539b483b04
moved data handling in publishdebianpackages into seperate module
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
3 # Bjoern Ricks <bjoern.ricks@intevation.de> |
e0539b483b04
moved data handling in publishdebianpackages into seperate module
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
4 # |
e0539b483b04
moved data handling in publishdebianpackages into seperate module
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
5 # This program is free software under the GPL (>=v2) |
e0539b483b04
moved data handling in publishdebianpackages into seperate module
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
6 # Read the file COPYING coming with the software for details. |
e0539b483b04
moved data handling in publishdebianpackages into seperate module
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
7 |
e0539b483b04
moved data handling in publishdebianpackages into seperate module
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
8 """Tests for treepkg.info.data""" |
e0539b483b04
moved data handling in publishdebianpackages into seperate module
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
9 |
e0539b483b04
moved data handling in publishdebianpackages into seperate module
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
10 import unittest |
e0539b483b04
moved data handling in publishdebianpackages into seperate module
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
11 import os.path |
e0539b483b04
moved data handling in publishdebianpackages into seperate module
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
12 import sys |
e0539b483b04
moved data handling in publishdebianpackages into seperate module
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
13 |
e0539b483b04
moved data handling in publishdebianpackages into seperate module
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
14 test_dir = os.path.dirname(__file__) |
e0539b483b04
moved data handling in publishdebianpackages into seperate module
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
15 sys.path.append(os.path.join(test_dir, os.pardir)) |
e0539b483b04
moved data handling in publishdebianpackages into seperate module
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
16 |
e0539b483b04
moved data handling in publishdebianpackages into seperate module
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
17 from treepkg.info.data import Package |
e0539b483b04
moved data handling in publishdebianpackages into seperate module
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
18 from treepkg.info.data import CacheDb |
e0539b483b04
moved data handling in publishdebianpackages into seperate module
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
19 from filesupport import FileTestMixin |
e0539b483b04
moved data handling in publishdebianpackages into seperate module
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
20 |
e0539b483b04
moved data handling in publishdebianpackages into seperate module
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
21 class TestCacheDb(unittest.TestCase, FileTestMixin): |
e0539b483b04
moved data handling in publishdebianpackages into seperate module
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
22 |
e0539b483b04
moved data handling in publishdebianpackages into seperate module
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
23 def test_cache_db(self): |
e0539b483b04
moved data handling in publishdebianpackages into seperate module
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
24 tmpdir = self.create_test_specific_temp_dir() |
e0539b483b04
moved data handling in publishdebianpackages into seperate module
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
25 package = Package("/tmp/abc/abc_0.1_i386.deb", "abc", |
e0539b483b04
moved data handling in publishdebianpackages into seperate module
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
26 "abc_0.1_i386.deb", "/source/abc/abc_0.1_i386.deb", |
e0539b483b04
moved data handling in publishdebianpackages into seperate module
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
27 "binary-i386", "1234567") |
e0539b483b04
moved data handling in publishdebianpackages into seperate module
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
28 # tmpfile = self.create_temp_file("cachedb1", "abc") |
e0539b483b04
moved data handling in publishdebianpackages into seperate module
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
29 # with self.assertRaises(Exception): |
e0539b483b04
moved data handling in publishdebianpackages into seperate module
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
30 # db = CacheDb(tmpfile) |
e0539b483b04
moved data handling in publishdebianpackages into seperate module
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
31 |
e0539b483b04
moved data handling in publishdebianpackages into seperate module
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
32 dbfile = os.path.join(tmpdir, "cachedb2") |
e0539b483b04
moved data handling in publishdebianpackages into seperate module
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
33 db = CacheDb(dbfile) |
416
4980f8d5014a
first version of incremental copying debian packages to cachedir
Bjoern Ricks <bricks@intevation.de>
parents:
414
diff
changeset
|
34 # insert |
4980f8d5014a
first version of incremental copying debian packages to cachedir
Bjoern Ricks <bricks@intevation.de>
parents:
414
diff
changeset
|
35 filename = package.filename |
414
e0539b483b04
moved data handling in publishdebianpackages into seperate module
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
36 db.add_package(package) |
416
4980f8d5014a
first version of incremental copying debian packages to cachedir
Bjoern Ricks <bricks@intevation.de>
parents:
414
diff
changeset
|
37 package = db.get_package(filename) |
4980f8d5014a
first version of incremental copying debian packages to cachedir
Bjoern Ricks <bricks@intevation.de>
parents:
414
diff
changeset
|
38 self.assertEquals("1234567", package.md5sum) |
4980f8d5014a
first version of incremental copying debian packages to cachedir
Bjoern Ricks <bricks@intevation.de>
parents:
414
diff
changeset
|
39 # update |
4980f8d5014a
first version of incremental copying debian packages to cachedir
Bjoern Ricks <bricks@intevation.de>
parents:
414
diff
changeset
|
40 package.md5sum = "01234567" |
4980f8d5014a
first version of incremental copying debian packages to cachedir
Bjoern Ricks <bricks@intevation.de>
parents:
414
diff
changeset
|
41 db.add_package(package) |
4980f8d5014a
first version of incremental copying debian packages to cachedir
Bjoern Ricks <bricks@intevation.de>
parents:
414
diff
changeset
|
42 package = db.get_package(filename) |
4980f8d5014a
first version of incremental copying debian packages to cachedir
Bjoern Ricks <bricks@intevation.de>
parents:
414
diff
changeset
|
43 self.assertEquals("01234567", package.md5sum) |
414
e0539b483b04
moved data handling in publishdebianpackages into seperate module
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
44 |
416
4980f8d5014a
first version of incremental copying debian packages to cachedir
Bjoern Ricks <bricks@intevation.de>
parents:
414
diff
changeset
|
45 # test get_package |
414
e0539b483b04
moved data handling in publishdebianpackages into seperate module
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
46 package2 = db.get_package(package.filename) |
e0539b483b04
moved data handling in publishdebianpackages into seperate module
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
47 self.assertNotEquals(None, package2) |
e0539b483b04
moved data handling in publishdebianpackages into seperate module
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
48 self.assertEquals(package.filename, package2.filename) |
e0539b483b04
moved data handling in publishdebianpackages into seperate module
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
49 self.assertEquals(package.name, package2.name) |
e0539b483b04
moved data handling in publishdebianpackages into seperate module
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
50 self.assertEquals(package.sourcepath, package2.sourcepath) |
e0539b483b04
moved data handling in publishdebianpackages into seperate module
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
51 self.assertEquals(package.arch, package2.arch) |
e0539b483b04
moved data handling in publishdebianpackages into seperate module
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
52 self.assertEquals(package.md5sum, package2.md5sum) |
e0539b483b04
moved data handling in publishdebianpackages into seperate module
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
53 |
507
c8268d40d35d
fix test after changes to cachedb.get_old_packages
Bjoern Ricks <bricks@intevation.de>
parents:
416
diff
changeset
|
54 package3 = Package("/tmp/foo/foo_0.2.i386.deb", "abc", |
416
4980f8d5014a
first version of incremental copying debian packages to cachedir
Bjoern Ricks <bricks@intevation.de>
parents:
414
diff
changeset
|
55 "foo_0.2_i386.deb", "/tmp/source/foo/foo_0.2.i386.deb", |
414
e0539b483b04
moved data handling in publishdebianpackages into seperate module
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
56 "binary-i386", "987654321") |
507
c8268d40d35d
fix test after changes to cachedb.get_old_packages
Bjoern Ricks <bricks@intevation.de>
parents:
416
diff
changeset
|
57 package4 = Package("/tmp/john/doe_0.3.i386.deb", "abc", |
416
4980f8d5014a
first version of incremental copying debian packages to cachedir
Bjoern Ricks <bricks@intevation.de>
parents:
414
diff
changeset
|
58 "doe_0.3.i386.deb", "/tmp/source/john/doe_0.3.i386.deb", |
4980f8d5014a
first version of incremental copying debian packages to cachedir
Bjoern Ricks <bricks@intevation.de>
parents:
414
diff
changeset
|
59 "binary-i386", "5671234") |
414
e0539b483b04
moved data handling in publishdebianpackages into seperate module
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
60 db.add_package(package3) |
416
4980f8d5014a
first version of incremental copying debian packages to cachedir
Bjoern Ricks <bricks@intevation.de>
parents:
414
diff
changeset
|
61 db.add_package(package4) |
4980f8d5014a
first version of incremental copying debian packages to cachedir
Bjoern Ricks <bricks@intevation.de>
parents:
414
diff
changeset
|
62 |
4980f8d5014a
first version of incremental copying debian packages to cachedir
Bjoern Ricks <bricks@intevation.de>
parents:
414
diff
changeset
|
63 # test get_old_packages |
507
c8268d40d35d
fix test after changes to cachedb.get_old_packages
Bjoern Ricks <bricks@intevation.de>
parents:
416
diff
changeset
|
64 oldpackages = db.get_old_packages([package]) |
416
4980f8d5014a
first version of incremental copying debian packages to cachedir
Bjoern Ricks <bricks@intevation.de>
parents:
414
diff
changeset
|
65 self.assertEquals(2, len(oldpackages)) |
414
e0539b483b04
moved data handling in publishdebianpackages into seperate module
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
66 packages = db.get_packages() |
416
4980f8d5014a
first version of incremental copying debian packages to cachedir
Bjoern Ricks <bricks@intevation.de>
parents:
414
diff
changeset
|
67 self.assertEquals(3, len(packages)) |
4980f8d5014a
first version of incremental copying debian packages to cachedir
Bjoern Ricks <bricks@intevation.de>
parents:
414
diff
changeset
|
68 db.remove_packages(oldpackages) |
414
e0539b483b04
moved data handling in publishdebianpackages into seperate module
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
69 packages = db.get_packages() |
e0539b483b04
moved data handling in publishdebianpackages into seperate module
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
70 self.assertEquals(1, len(packages)) |
e0539b483b04
moved data handling in publishdebianpackages into seperate module
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
71 |
e0539b483b04
moved data handling in publishdebianpackages into seperate module
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
72 if __name__ == '__main__': |
e0539b483b04
moved data handling in publishdebianpackages into seperate module
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
73 unittest.main() |
e0539b483b04
moved data handling in publishdebianpackages into seperate module
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
74 |