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

Subscribers

People subscribed via source and target branches