1
# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
3
# Autopilot Functional Test Tool
4
# Copyright (C) 2014 Canonical
6
# This program is free software: you can redistribute it and/or modify
7
# it under the terms of the GNU General Public License as published by
8
# the Free Software Foundation, either version 3 of the License, or
9
# (at your option) any later version.
11
# This program is distributed in the hope that it will be useful,
12
# but WITHOUT ANY WARRANTY; without even the implied warranty of
13
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
# GNU General Public License for more details.
16
# You should have received a copy of the GNU General Public License
17
# along with this program. If not, see <http://www.gnu.org/licenses/>.
20
from testtools import TestCase
21
from unittest.mock import patch
23
from autopilot.testcase import AutopilotTestCase
26
class AutopilotTestCaseClassTests(TestCase):
28
"""Test functions of the AutopilotTestCase class."""
30
@patch('autopilot.testcase.NormalApplicationLauncher')
31
def test_launch_test_application(self, nal):
32
class LauncherTest(AutopilotTestCase):
36
def test_anything(self):
39
test_case = LauncherTest('test_anything')
40
with patch.object(test_case, 'useFixture') as uf:
41
result = test_case.launch_test_application('a', 'b', 'c')
42
uf.assert_called_once_with(nal.return_value)
43
uf.return_value.launch.assert_called_once_with('a', ('b', 'c'))
44
self.assertEqual(result, uf.return_value.launch.return_value)
46
@patch('autopilot.testcase.ClickApplicationLauncher')
47
def test_launch_click_package(self, cal):
48
class LauncherTest(AutopilotTestCase):
52
def test_anything(self):
55
test_case = LauncherTest('test_anything')
56
with patch.object(test_case, 'useFixture') as uf:
57
result = test_case.launch_click_package('a', 'b', ['c', 'd'])
58
uf.assert_called_once_with(cal.return_value)
59
uf.return_value.launch.assert_called_once_with(
62
self.assertEqual(result, uf.return_value.launch.return_value)
64
@patch('autopilot.testcase.UpstartApplicationLauncher')
65
def test_launch_upstart_application(self, ual):
66
class LauncherTest(AutopilotTestCase):
70
def test_anything(self):
73
test_case = LauncherTest('test_anything')
74
with patch.object(test_case, 'useFixture') as uf:
75
result = test_case.launch_upstart_application('a', ['b'])
76
uf.assert_called_once_with(ual.return_value)
77
uf.return_value.launch.assert_called_once_with('a', ['b'])
78
self.assertEqual(result, uf.return_value.launch.return_value)