1
# Copyright 2010 Canonical, Ltd.
3
# This file is part of Tarmac.
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.
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.
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."""
20
from tarmac.bin.registry import CommandRegistry
21
from tarmac.plugins import command
22
from tarmac.tests import TarmacTestCase
23
from tarmac.tests.test_commands import FakeCommand
24
from tarmac.tests.mock import Thing
27
class TestCommand(TarmacTestCase):
28
"""Test the Command plug-in."""
31
"""Set up additional data we need for all tests."""
32
super(TestCommand, self).setUp()
33
self.proposal = Thing(
35
display_name='lp:project/source'),
37
display_name='lp:project'))
38
self.plugin = command.Command()
39
registry = CommandRegistry(config=self.config)
40
self.command = FakeCommand(registry)
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))
48
command=self.command, target=target, source=None,
49
proposal=self.proposal)
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,
58
command=self.command, target=target, source=None,
59
proposal=self.proposal)