Mercurial > treepkg
annotate test/test_info.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 | 3a3cad8f6f60 |
rev | line source |
---|---|
388
1af04bfbb1d0
moved test file to test main dir
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
1 # Copyright (C) 2010 by Intevation GmbH |
1af04bfbb1d0
moved test file to test main dir
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
2 # Authors: |
1af04bfbb1d0
moved test file to test main dir
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
3 # Bjoern Ricks <bjoern.ricks@intevation.de> |
1af04bfbb1d0
moved test file to test main dir
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
4 # |
1af04bfbb1d0
moved test file to test main dir
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
5 # This program is free software under the GPL (>=v2) |
1af04bfbb1d0
moved test file to test main dir
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
6 # Read the file COPYING coming with the software for details. |
1af04bfbb1d0
moved test file to test main dir
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
7 |
1af04bfbb1d0
moved test file to test main dir
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
8 """Tests for treepkg.status.status""" |
1af04bfbb1d0
moved test file to test main dir
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
9 |
1af04bfbb1d0
moved test file to test main dir
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
10 import unittest |
1af04bfbb1d0
moved test file to test main dir
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
11 import os.path |
1af04bfbb1d0
moved test file to test main dir
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
12 import sys |
1af04bfbb1d0
moved test file to test main dir
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
13 |
1af04bfbb1d0
moved test file to test main dir
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
14 test_dir = os.path.dirname(__file__) |
1af04bfbb1d0
moved test file to test main dir
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
15 sys.path.append(os.path.join(test_dir, os.pardir)) |
1af04bfbb1d0
moved test file to test main dir
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
16 |
392
e2afbd3c2bf1
write first info about tracks
Bjoern Ricks <bricks@intevation.de>
parents:
388
diff
changeset
|
17 from treepkg.info.status import * |
388
1af04bfbb1d0
moved test file to test main dir
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
18 from treepkg.report import get_packager_group |
1af04bfbb1d0
moved test file to test main dir
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
19 from filesupport import FileTestMixin |
1af04bfbb1d0
moved test file to test main dir
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
20 |
413
94a6ae627b31
implemented CacheDb to store copied Packages from build host
Bjoern Ricks <bricks@intevation.de>
parents:
392
diff
changeset
|
21 from publishdebianpackages import get_binary_arch |
94a6ae627b31
implemented CacheDb to store copied Packages from build host
Bjoern Ricks <bricks@intevation.de>
parents:
392
diff
changeset
|
22 |
392
e2afbd3c2bf1
write first info about tracks
Bjoern Ricks <bricks@intevation.de>
parents:
388
diff
changeset
|
23 class TreepkgInfoTest(unittest.TestCase, FileTestMixin): |
388
1af04bfbb1d0
moved test file to test main dir
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
24 config_contents = """\ |
1af04bfbb1d0
moved test file to test main dir
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
25 [DEFAULT] |
392
e2afbd3c2bf1
write first info about tracks
Bjoern Ricks <bricks@intevation.de>
parents:
388
diff
changeset
|
26 #treepkg_dir: /home/builder/mill |
e2afbd3c2bf1
write first info about tracks
Bjoern Ricks <bricks@intevation.de>
parents:
388
diff
changeset
|
27 #tracks_dir: %(treepkg_dir)s/tracks |
e2afbd3c2bf1
write first info about tracks
Bjoern Ricks <bricks@intevation.de>
parents:
388
diff
changeset
|
28 tracks_dir: /home/builder/mill/tracks |
388
1af04bfbb1d0
moved test file to test main dir
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
29 root_cmd: sudo |
392
e2afbd3c2bf1
write first info about tracks
Bjoern Ricks <bricks@intevation.de>
parents:
388
diff
changeset
|
30 pbuilder_dir: %(tracks_dir)s/pbuilder |
388
1af04bfbb1d0
moved test file to test main dir
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
31 builderconfig: %(pbuilder_dir)s/pbuilderrc |
1af04bfbb1d0
moved test file to test main dir
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
32 deb_email: treepkg@example.com |
1af04bfbb1d0
moved test file to test main dir
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
33 deb_fullname: TreePKG |
1af04bfbb1d0
moved test file to test main dir
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
34 pkg_revision_template: treepkg%%(pkg_revision)s |
1af04bfbb1d0
moved test file to test main dir
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
35 handle_dependencies: False |
1af04bfbb1d0
moved test file to test main dir
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
36 |
1af04bfbb1d0
moved test file to test main dir
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
37 [treepkg] |
392
e2afbd3c2bf1
write first info about tracks
Bjoern Ricks <bricks@intevation.de>
parents:
388
diff
changeset
|
38 instructions_file: %(tracks_dir)s/instructions |
388
1af04bfbb1d0
moved test file to test main dir
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
39 check_interval: 3600 |
1af04bfbb1d0
moved test file to test main dir
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
40 name: testtreepkginfo |
1af04bfbb1d0
moved test file to test main dir
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
41 |
1af04bfbb1d0
moved test file to test main dir
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
42 [pkg_simple] |
1af04bfbb1d0
moved test file to test main dir
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
43 pkg_basename: simple1 |
1af04bfbb1d0
moved test file to test main dir
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
44 svn_url: svn://example.com/%(name)s/trunk |
1af04bfbb1d0
moved test file to test main dir
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
45 base_dir: %(tracks_dir)s/%(name)s |
1af04bfbb1d0
moved test file to test main dir
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
46 packager_class: treepkginfo_test.%(name)s |
1af04bfbb1d0
moved test file to test main dir
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
47 handle_dependencies: True |
1af04bfbb1d0
moved test file to test main dir
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
48 signing_key_id: abcd1234 |
1af04bfbb1d0
moved test file to test main dir
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
49 changelog_msg_template: Update to feature branch r%%(revision)s |
1af04bfbb1d0
moved test file to test main dir
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
50 version_template: 1.0.svn%%(revision)s |
1af04bfbb1d0
moved test file to test main dir
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
51 |
1af04bfbb1d0
moved test file to test main dir
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
52 """ |
1af04bfbb1d0
moved test file to test main dir
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
53 |
1af04bfbb1d0
moved test file to test main dir
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
54 files = [("treepkg.cfg", config_contents), |
1af04bfbb1d0
moved test file to test main dir
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
55 ("treepkginfo_test", |
1af04bfbb1d0
moved test file to test main dir
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
56 [("__init__.py", ""), |
1af04bfbb1d0
moved test file to test main dir
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
57 ("simple.py", |
1af04bfbb1d0
moved test file to test main dir
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
58 "\n".join(["class SourcePackager:", |
1af04bfbb1d0
moved test file to test main dir
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
59 " pass", |
1af04bfbb1d0
moved test file to test main dir
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
60 ""])), |
1af04bfbb1d0
moved test file to test main dir
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
61 ])] |
1af04bfbb1d0
moved test file to test main dir
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
62 |
1af04bfbb1d0
moved test file to test main dir
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
63 def setUp(self): |
1af04bfbb1d0
moved test file to test main dir
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
64 self.directory = self.create_files("treepkg", self.files) |
1af04bfbb1d0
moved test file to test main dir
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
65 self.old_path = sys.path |
1af04bfbb1d0
moved test file to test main dir
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
66 sys.path = [self.directory] + sys.path |
1af04bfbb1d0
moved test file to test main dir
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
67 |
1af04bfbb1d0
moved test file to test main dir
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
68 def tearDown(self): |
1af04bfbb1d0
moved test file to test main dir
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
69 sys.path = self.old_path |
1af04bfbb1d0
moved test file to test main dir
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
70 |
1af04bfbb1d0
moved test file to test main dir
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
71 def test_createinfo(self): |
1af04bfbb1d0
moved test file to test main dir
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
72 config_file = os.path.join(self.directory, "treepkg.cfg") |
392
e2afbd3c2bf1
write first info about tracks
Bjoern Ricks <bricks@intevation.de>
parents:
388
diff
changeset
|
73 tpkginfo = TreepkgInfo(config_file) |
413
94a6ae627b31
implemented CacheDb to store copied Packages from build host
Bjoern Ricks <bricks@intevation.de>
parents:
392
diff
changeset
|
74 tpkgrootinfo = tpkginfo.tpkgroot.info |
94a6ae627b31
implemented CacheDb to store copied Packages from build host
Bjoern Ricks <bricks@intevation.de>
parents:
392
diff
changeset
|
75 self.assertEquals("testtreepkginfo", tpkgrootinfo.name) |
388
1af04bfbb1d0
moved test file to test main dir
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
76 |
1af04bfbb1d0
moved test file to test main dir
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
77 |
392
e2afbd3c2bf1
write first info about tracks
Bjoern Ricks <bricks@intevation.de>
parents:
388
diff
changeset
|
78 class TreepkgRootInfoTest(unittest.TestCase): |
388
1af04bfbb1d0
moved test file to test main dir
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
79 |
1af04bfbb1d0
moved test file to test main dir
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
80 def test_toxml(self): |
392
e2afbd3c2bf1
write first info about tracks
Bjoern Ricks <bricks@intevation.de>
parents:
388
diff
changeset
|
81 status = TreepkgRootInfo("testtreepkg") |
388
1af04bfbb1d0
moved test file to test main dir
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
82 dom = status.toxml() |
1af04bfbb1d0
moved test file to test main dir
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
83 xml = dom.toxml() |
413
94a6ae627b31
implemented CacheDb to store copied Packages from build host
Bjoern Ricks <bricks@intevation.de>
parents:
392
diff
changeset
|
84 self.assertEquals("<info><name>testtreepkg</name></info>", xml) |
94a6ae627b31
implemented CacheDb to store copied Packages from build host
Bjoern Ricks <bricks@intevation.de>
parents:
392
diff
changeset
|
85 |
94a6ae627b31
implemented CacheDb to store copied Packages from build host
Bjoern Ricks <bricks@intevation.de>
parents:
392
diff
changeset
|
86 class TestPublishDebianPackages(unittest.TestCase, FileTestMixin): |
94a6ae627b31
implemented CacheDb to store copied Packages from build host
Bjoern Ricks <bricks@intevation.de>
parents:
392
diff
changeset
|
87 |
94a6ae627b31
implemented CacheDb to store copied Packages from build host
Bjoern Ricks <bricks@intevation.de>
parents:
392
diff
changeset
|
88 def test_get_binary_arch(self): |
94a6ae627b31
implemented CacheDb to store copied Packages from build host
Bjoern Ricks <bricks@intevation.de>
parents:
392
diff
changeset
|
89 source = get_binary_arch("source") |
94a6ae627b31
implemented CacheDb to store copied Packages from build host
Bjoern Ricks <bricks@intevation.de>
parents:
392
diff
changeset
|
90 self.assertEquals("source", source) |
94a6ae627b31
implemented CacheDb to store copied Packages from build host
Bjoern Ricks <bricks@intevation.de>
parents:
392
diff
changeset
|
91 binary_armel = get_binary_arch("armel") |
94a6ae627b31
implemented CacheDb to store copied Packages from build host
Bjoern Ricks <bricks@intevation.de>
parents:
392
diff
changeset
|
92 self.assertEquals("binary-armel", binary_armel) |
94a6ae627b31
implemented CacheDb to store copied Packages from build host
Bjoern Ricks <bricks@intevation.de>
parents:
392
diff
changeset
|
93 binary_armel = get_binary_arch("binary-armel") |
94a6ae627b31
implemented CacheDb to store copied Packages from build host
Bjoern Ricks <bricks@intevation.de>
parents:
392
diff
changeset
|
94 self.assertEquals("binary-armel", binary_armel) |
94a6ae627b31
implemented CacheDb to store copied Packages from build host
Bjoern Ricks <bricks@intevation.de>
parents:
392
diff
changeset
|
95 |
388
1af04bfbb1d0
moved test file to test main dir
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
96 |
1af04bfbb1d0
moved test file to test main dir
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
97 if __name__ == '__main__': |
1af04bfbb1d0
moved test file to test main dir
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
98 unittest.main() |
1af04bfbb1d0
moved test file to test main dir
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
99 |