~veebers/autopilot/move-testing-process-run-fixture

« back to all changes in this revision

Viewing changes to autopilot/tests/functional/test_application_launcher.py

  • Committer: Tarmac
  • Author(s): Christopher Lee
  • Date: 2014-07-09 00:01:19 UTC
  • mfrom: (497.1.6 fix_non-unit_unit_tests)
  • Revision ID: tarmac-20140709000119-fu9zk8dl7qjh2epo
Remove use of AutopilotTestCase in unit tests. Made some 'unit' tests functional tests.

Approved by Thomi Richards, PS Jenkins bot.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
 
2
#
 
3
# Autopilot Functional Test Tool
 
4
# Copyright (C) 2014 Canonical
 
5
#
 
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.
 
10
#
 
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.
 
15
#
 
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/>.
 
18
#
 
19
 
 
20
from testtools import TestCase
 
21
from unittest.mock import patch
 
22
 
 
23
from autopilot.testcase import AutopilotTestCase
 
24
 
 
25
 
 
26
class AutopilotTestCaseClassTests(TestCase):
 
27
 
 
28
    """Test functions of the AutopilotTestCase class."""
 
29
 
 
30
    @patch('autopilot.testcase.NormalApplicationLauncher')
 
31
    def test_launch_test_application(self, nal):
 
32
        class LauncherTest(AutopilotTestCase):
 
33
 
 
34
            """Test launchers."""
 
35
 
 
36
            def test_anything(self):
 
37
                pass
 
38
 
 
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)
 
45
 
 
46
    @patch('autopilot.testcase.ClickApplicationLauncher')
 
47
    def test_launch_click_package(self, cal):
 
48
        class LauncherTest(AutopilotTestCase):
 
49
 
 
50
            """Test launchers."""
 
51
 
 
52
            def test_anything(self):
 
53
                pass
 
54
 
 
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(
 
60
                'a', 'b', ['c', 'd']
 
61
            )
 
62
            self.assertEqual(result, uf.return_value.launch.return_value)
 
63
 
 
64
    @patch('autopilot.testcase.UpstartApplicationLauncher')
 
65
    def test_launch_upstart_application(self, ual):
 
66
        class LauncherTest(AutopilotTestCase):
 
67
 
 
68
            """Test launchers."""
 
69
 
 
70
            def test_anything(self):
 
71
                pass
 
72
 
 
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)