Mercurial > treepkg
annotate test/test_info.py @ 391:89ecca5d262e treepkg-status
check if config file exists to get usefull error output
author | Bjoern Ricks <bricks@intevation.de> |
---|---|
date | Thu, 08 Jul 2010 16:08:39 +0000 |
parents | 1af04bfbb1d0 |
children | e2afbd3c2bf1 |
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 |
1af04bfbb1d0
moved test file to test main dir
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
17 from treepkg.info.status import TreepkgInfo |
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 |
1af04bfbb1d0
moved test file to test main dir
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
21 class TreepkgInfoExampleTest(unittest.TestCase, FileTestMixin): |
1af04bfbb1d0
moved test file to test main dir
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
22 config_contents = """\ |
1af04bfbb1d0
moved test file to test main dir
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
23 [DEFAULT] |
1af04bfbb1d0
moved test file to test main dir
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
24 treepkg_dir: /home/builder/mill |
1af04bfbb1d0
moved test file to test main dir
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
25 tracks_dir: %(treepkg_dir)s/tracks |
1af04bfbb1d0
moved test file to test main dir
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
26 root_cmd: sudo |
1af04bfbb1d0
moved test file to test main dir
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
27 pbuilder_dir: %(treepkg_dir)s/pbuilder |
1af04bfbb1d0
moved test file to test main dir
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
28 builderconfig: %(pbuilder_dir)s/pbuilderrc |
1af04bfbb1d0
moved test file to test main dir
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
29 deb_email: treepkg@example.com |
1af04bfbb1d0
moved test file to test main dir
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
30 deb_fullname: TreePKG |
1af04bfbb1d0
moved test file to test main dir
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
31 pkg_revision_template: treepkg%%(pkg_revision)s |
1af04bfbb1d0
moved test file to test main dir
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
32 handle_dependencies: False |
1af04bfbb1d0
moved test file to test main dir
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
33 |
1af04bfbb1d0
moved test file to test main dir
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
34 [treepkg] |
1af04bfbb1d0
moved test file to test main dir
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
35 instructions_file: %(treepkg_dir)s/instructions |
1af04bfbb1d0
moved test file to test main dir
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
36 check_interval: 3600 |
1af04bfbb1d0
moved test file to test main dir
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
37 name: testtreepkginfo |
1af04bfbb1d0
moved test file to test main dir
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
38 |
1af04bfbb1d0
moved test file to test main dir
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
39 [pkg_simple] |
1af04bfbb1d0
moved test file to test main dir
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
40 pkg_basename: simple1 |
1af04bfbb1d0
moved test file to test main dir
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
41 svn_url: svn://example.com/%(name)s/trunk |
1af04bfbb1d0
moved test file to test main dir
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
42 base_dir: %(tracks_dir)s/%(name)s |
1af04bfbb1d0
moved test file to test main dir
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
43 packager_class: treepkginfo_test.%(name)s |
1af04bfbb1d0
moved test file to test main dir
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
44 handle_dependencies: True |
1af04bfbb1d0
moved test file to test main dir
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
45 signing_key_id: abcd1234 |
1af04bfbb1d0
moved test file to test main dir
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
46 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
|
47 version_template: 1.0.svn%%(revision)s |
1af04bfbb1d0
moved test file to test main dir
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
48 |
1af04bfbb1d0
moved test file to test main dir
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
49 """ |
1af04bfbb1d0
moved test file to test main dir
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
50 |
1af04bfbb1d0
moved test file to test main dir
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
51 files = [("treepkg.cfg", config_contents), |
1af04bfbb1d0
moved test file to test main dir
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
52 ("treepkginfo_test", |
1af04bfbb1d0
moved test file to test main dir
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
53 [("__init__.py", ""), |
1af04bfbb1d0
moved test file to test main dir
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
54 ("simple.py", |
1af04bfbb1d0
moved test file to test main dir
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
55 "\n".join(["class SourcePackager:", |
1af04bfbb1d0
moved test file to test main dir
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
56 " pass", |
1af04bfbb1d0
moved test file to test main dir
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
57 ""])), |
1af04bfbb1d0
moved test file to test main dir
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
58 ])] |
1af04bfbb1d0
moved test file to test main dir
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
59 |
1af04bfbb1d0
moved test file to test main dir
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
60 def setUp(self): |
1af04bfbb1d0
moved test file to test main dir
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
61 self.directory = self.create_files("treepkg", self.files) |
1af04bfbb1d0
moved test file to test main dir
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
62 self.old_path = sys.path |
1af04bfbb1d0
moved test file to test main dir
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
63 sys.path = [self.directory] + sys.path |
1af04bfbb1d0
moved test file to test main dir
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
64 |
1af04bfbb1d0
moved test file to test main dir
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
65 def tearDown(self): |
1af04bfbb1d0
moved test file to test main dir
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
66 sys.path = self.old_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 test_createinfo(self): |
1af04bfbb1d0
moved test file to test main dir
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
69 config_file = os.path.join(self.directory, "treepkg.cfg") |
1af04bfbb1d0
moved test file to test main dir
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
70 group = get_packager_group(config_file) |
1af04bfbb1d0
moved test file to test main dir
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
71 tpginfo = TreepkgInfo(group.name) |
1af04bfbb1d0
moved test file to test main dir
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
72 print tpginfo.toxml().toxml() |
1af04bfbb1d0
moved test file to test main dir
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
73 self.assertEquals("testtreepkginfo", tpginfo.name) |
1af04bfbb1d0
moved test file to test main dir
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
74 |
1af04bfbb1d0
moved test file to test main dir
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
75 |
1af04bfbb1d0
moved test file to test main dir
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
76 class TreepkgInfoTest(unittest.TestCase): |
1af04bfbb1d0
moved test file to test main dir
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
77 |
1af04bfbb1d0
moved test file to test main dir
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
78 def test_toxml(self): |
1af04bfbb1d0
moved test file to test main dir
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
79 status = TreepkgInfo("testtreepkg") |
1af04bfbb1d0
moved test file to test main dir
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
80 dom = status.toxml() |
1af04bfbb1d0
moved test file to test main dir
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
81 xml = dom.toxml() |
1af04bfbb1d0
moved test file to test main dir
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
82 self.assertEquals("<status><name>testtreepkg</name></status>", xml) |
1af04bfbb1d0
moved test file to test main dir
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
83 |
1af04bfbb1d0
moved test file to test main dir
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
84 if __name__ == '__main__': |
1af04bfbb1d0
moved test file to test main dir
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
85 unittest.main() |
1af04bfbb1d0
moved test file to test main dir
Bjoern Ricks <bricks@intevation.de>
parents:
diff
changeset
|
86 |