Merge lp:~dobey/tarmac/command-tests into lp:tarmac

Proposed by dobey
Status: Merged
Approved by: Paul Hummer
Approved revision: 360
Merged at revision: 360
Proposed branch: lp:~dobey/tarmac/command-tests
Merge into: lp:tarmac
Diff against target: 63 lines (+59/-0)
1 file modified
tarmac/plugins/tests/test_command.py (+59/-0)
To merge this branch: bzr merge lp:~dobey/tarmac/command-tests
Reviewer Review Type Date Requested Status
Paul Hummer Approve
Review via email: mp+36185@code.launchpad.net

Commit message

Add tests for the Command plug-in

To post a comment you must log in.
Revision history for this message
Paul Hummer (rockstar) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file 'tarmac/plugins/tests/test_command.py'
2--- tarmac/plugins/tests/test_command.py 1970-01-01 00:00:00 +0000
3+++ tarmac/plugins/tests/test_command.py 2010-09-21 18:31:04 +0000
4@@ -0,0 +1,59 @@
5+# Copyright 2010 Canonical, Ltd.
6+#
7+# This file is part of Tarmac.
8+#
9+# Tarmac is free software: you can redistribute it and/or modify
10+# it under the terms of the GNU General Public License version 3 as
11+# published by the Free Software Foundation.
12+#
13+# Tarmac is distributed in the hope that it will be useful,
14+# but WITHOUT ANY WARRANTY; without even the implied warranty of
15+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16+# GNU General Public License for more details.
17+#
18+# You should have received a copy of the GNU General Public License
19+# along with Tarmac. If not, see <http://www.gnu.org/licenses/>.
20+"""Tests for the Command plug-in."""
21+
22+import os
23+
24+from tarmac.bin.registry import CommandRegistry
25+from tarmac.plugins import command
26+from tarmac.tests import TarmacTestCase
27+from tarmac.tests.test_commands import FakeCommand
28+from tarmac.tests.mock import Thing
29+
30+
31+class TestCommand(TarmacTestCase):
32+ """Test the Command plug-in."""
33+
34+ def setUp(self):
35+ """Set up additional data we need for all tests."""
36+ super(TestCommand, self).setUp()
37+ self.proposal = Thing(
38+ source_branch=Thing(
39+ display_name='lp:project/source'),
40+ target_branch=Thing(
41+ display_name='lp:project'))
42+ self.plugin = command.Command()
43+ registry = CommandRegistry(config=self.config)
44+ self.command = FakeCommand(registry)
45+
46+ def test_run(self):
47+ """Test that the plug-in runs without errors."""
48+ target = Thing(config=Thing(
49+ verify_command="/bin/true"),
50+ tree=Thing(abspath=os.path.abspath))
51+ self.plugin.run(
52+ command=self.command, target=target, source=None,
53+ proposal=self.proposal)
54+
55+ def test_run_failure(self):
56+ """Test that a failure raises the correct exception."""
57+ target = Thing(config=Thing(
58+ verify_command="/bin/false"),
59+ tree=Thing(abspath=os.path.abspath))
60+ self.assertRaises(command.VerifyCommandFailed,
61+ self.plugin.run,
62+ command=self.command, target=target, source=None,
63+ proposal=self.proposal)

Subscribers

People subscribed via source and target branches