Mercurial > treepkg
annotate test/test_notifications.py @ 557:9824e409388b
Refactor git branching
If a checkout is already available and the branch is changed in
the config git command would always fail because it doesn't know
the branch to track. Therefore always check if the branch is
locally available and if not checkout the remote branch
author | Bjoern Ricks <bricks@intevation.de> |
---|---|
date | Fri, 02 Sep 2011 08:45:28 +0000 |
parents | e5b66539f893 |
children |
rev | line source |
---|---|
242
351427b28b76
Add test for bin/listpendingnotifications.py
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
1 # Copyright (C) 2009 by Intevation GmbH |
351427b28b76
Add test for bin/listpendingnotifications.py
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
2 # Authors: |
351427b28b76
Add test for bin/listpendingnotifications.py
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
3 # Bernhard Herzog <bh@intevation.de> |
351427b28b76
Add test for bin/listpendingnotifications.py
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
4 # |
351427b28b76
Add test for bin/listpendingnotifications.py
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
5 # This program is free software under the GPL (>=v2) |
351427b28b76
Add test for bin/listpendingnotifications.py
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
6 # Read the file COPYING coming with the software for details. |
351427b28b76
Add test for bin/listpendingnotifications.py
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
7 |
351427b28b76
Add test for bin/listpendingnotifications.py
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
8 |
351427b28b76
Add test for bin/listpendingnotifications.py
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
9 import sys |
351427b28b76
Add test for bin/listpendingnotifications.py
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
10 import os |
351427b28b76
Add test for bin/listpendingnotifications.py
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
11 import unittest |
351427b28b76
Add test for bin/listpendingnotifications.py
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
12 |
351427b28b76
Add test for bin/listpendingnotifications.py
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
13 from filesupport import FileTestMixin |
351427b28b76
Add test for bin/listpendingnotifications.py
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
14 |
351427b28b76
Add test for bin/listpendingnotifications.py
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
15 from treepkg.run import call, capture_output, SubprocessError |
351427b28b76
Add test for bin/listpendingnotifications.py
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
16 |
351427b28b76
Add test for bin/listpendingnotifications.py
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
17 |
351427b28b76
Add test for bin/listpendingnotifications.py
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
18 class TestListNotifications(unittest.TestCase, FileTestMixin): |
351427b28b76
Add test for bin/listpendingnotifications.py
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
19 |
351427b28b76
Add test for bin/listpendingnotifications.py
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
20 treepkg_cfg_template = """\ |
351427b28b76
Add test for bin/listpendingnotifications.py
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
21 [DEFAULT] |
351427b28b76
Add test for bin/listpendingnotifications.py
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
22 tracks_dir: %(tracksdir)s |
351427b28b76
Add test for bin/listpendingnotifications.py
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
23 root_cmd: true |
344
f06f707d9fda
merged branches/scratchbox into trunk
Bjoern Ricks <bricks@intevation.de>
parents:
293
diff
changeset
|
24 builderconfig: |
242
351427b28b76
Add test for bin/listpendingnotifications.py
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
25 deb_email: packager@example.com |
351427b28b76
Add test for bin/listpendingnotifications.py
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
26 deb_fullname: Sample Packager |
293
faeeac2c4c71
Replace debrevision_prefix with pkg_revision_template. Their meaning is
Bernhard Herzog <bh@intevation.de>
parents:
242
diff
changeset
|
27 pkg_revision_template: treepkg%%%%(pkg_revision)d |
242
351427b28b76
Add test for bin/listpendingnotifications.py
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
28 handle_dependencies: False |
351427b28b76
Add test for bin/listpendingnotifications.py
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
29 |
351427b28b76
Add test for bin/listpendingnotifications.py
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
30 [treepkg] |
351427b28b76
Add test for bin/listpendingnotifications.py
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
31 check_interval: 3600 |
351427b28b76
Add test for bin/listpendingnotifications.py
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
32 instructions_file: |
351427b28b76
Add test for bin/listpendingnotifications.py
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
33 |
351427b28b76
Add test for bin/listpendingnotifications.py
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
34 [pkg_kdepim] |
511
e5b66539f893
new variable to set choose the scm for sources and debian dirs
Bjoern Ricks <bricks@intevation.de>
parents:
344
diff
changeset
|
35 url: svn://anonsvn.kde.org/home/kde/branches/kdepim/enterprise/kdepim |
242
351427b28b76
Add test for bin/listpendingnotifications.py
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
36 base_dir: %%(tracks_dir)s/kdepim |
351427b28b76
Add test for bin/listpendingnotifications.py
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
37 packager_class: recipes.kde_enterprise_3_5.kdepim |
351427b28b76
Add test for bin/listpendingnotifications.py
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
38 """ |
351427b28b76
Add test for bin/listpendingnotifications.py
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
39 |
351427b28b76
Add test for bin/listpendingnotifications.py
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
40 track_files = [("kdepim", |
351427b28b76
Add test for bin/listpendingnotifications.py
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
41 [("pkg", |
351427b28b76
Add test for bin/listpendingnotifications.py
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
42 [("704195-31", |
351427b28b76
Add test for bin/listpendingnotifications.py
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
43 [("status", "TreePackagerStatus 0.0\n"), |
351427b28b76
Add test for bin/listpendingnotifications.py
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
44 ("src", []), |
351427b28b76
Add test for bin/listpendingnotifications.py
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
45 ("binary", [])]), |
351427b28b76
Add test for bin/listpendingnotifications.py
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
46 ("702432-47", |
351427b28b76
Add test for bin/listpendingnotifications.py
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
47 [("status", |
351427b28b76
Add test for bin/listpendingnotifications.py
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
48 "\n".join(("TreePackagerStatus 0.0", |
351427b28b76
Add test for bin/listpendingnotifications.py
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
49 "status: error", |
351427b28b76
Add test for bin/listpendingnotifications.py
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
50 "notification_mail: notification_pending", |
351427b28b76
Add test for bin/listpendingnotifications.py
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
51 ""))), |
351427b28b76
Add test for bin/listpendingnotifications.py
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
52 ("src", []), |
351427b28b76
Add test for bin/listpendingnotifications.py
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
53 ("binary", [])])])])] |
351427b28b76
Add test for bin/listpendingnotifications.py
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
54 |
351427b28b76
Add test for bin/listpendingnotifications.py
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
55 def setUp(self): |
351427b28b76
Add test for bin/listpendingnotifications.py
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
56 self.bindir = os.path.join(os.path.dirname(__file__), |
351427b28b76
Add test for bin/listpendingnotifications.py
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
57 os.pardir, "bin") |
351427b28b76
Add test for bin/listpendingnotifications.py
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
58 self.listpendingnotifications \ |
351427b28b76
Add test for bin/listpendingnotifications.py
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
59 = os.path.join(self.bindir, |
351427b28b76
Add test for bin/listpendingnotifications.py
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
60 "listpendingnotifications.py") |
351427b28b76
Add test for bin/listpendingnotifications.py
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
61 self.tracksdir = self.create_files("tracks", self.track_files) |
351427b28b76
Add test for bin/listpendingnotifications.py
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
62 config = self.treepkg_cfg_template % dict(tracksdir=self.tracksdir) |
351427b28b76
Add test for bin/listpendingnotifications.py
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
63 self.config_file = self.create_temp_file("treepkg.cfg", config) |
351427b28b76
Add test for bin/listpendingnotifications.py
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
64 |
351427b28b76
Add test for bin/listpendingnotifications.py
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
65 def test_listpendingnotifications(self): |
351427b28b76
Add test for bin/listpendingnotifications.py
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
66 cmd = [sys.executable, self.listpendingnotifications, |
351427b28b76
Add test for bin/listpendingnotifications.py
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
67 "--config-file=" + self.config_file] |
351427b28b76
Add test for bin/listpendingnotifications.py
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
68 self.assertEquals(capture_output(cmd), "error kdepim 702432 47\n") |