Disable all missing-docstring warnings in unit tests
[functest.git] / functest / tests / unit / cli / commands / test_cli_testcase.py
1 #!/usr/bin/env python
2
3 # All rights reserved. This program and the accompanying materials
4 # are made available under the terms of the Apache License, Version 2.0
5 # which accompanies this distribution, and is available at
6 # http://www.apache.org/licenses/LICENSE-2.0
7
8 # pylint: disable=missing-docstring
9
10 import logging
11 import unittest
12
13 import mock
14
15 from functest.cli.commands import cli_testcase
16
17
18 class CliTestCasesTesting(unittest.TestCase):
19
20     def setUp(self):
21         self.testname = 'testname'
22         with mock.patch('functest.cli.commands.cli_testcase.tb'):
23             self.cli_tests = cli_testcase.CliTestcase()
24
25     @mock.patch('functest.cli.commands.cli_testcase.vacation.main')
26     def test_run_vacation(self, mock_method):
27         self.cli_tests.run('vacation')
28         self.assertTrue(mock_method.called)
29
30     @mock.patch('functest.cli.commands.cli_testcase.ft_utils.execute_command')
31     def test_run_default(self, mock_ft_utils):
32         cmd = "run_tests -n -r -t {}".format(self.testname)
33         self.cli_tests.run(self.testname, noclean=True, report=True)
34         mock_ft_utils.assert_called_with(cmd)
35
36     @mock.patch('functest.cli.commands.cli_testcase.ft_utils.execute_command')
37     def test_run_noclean_missing_report(self, mock_ft_utils):
38         cmd = "run_tests -n -t {}".format(self.testname)
39         self.cli_tests.run(self.testname, noclean=True, report=False)
40         mock_ft_utils.assert_called_with(cmd)
41
42     @mock.patch('functest.cli.commands.cli_testcase.ft_utils.execute_command')
43     def test_run_report_missing_noclean(self, mock_ft_utils):
44         cmd = "run_tests -r -t {}".format(self.testname)
45         self.cli_tests.run(self.testname, noclean=False, report=True)
46         mock_ft_utils.assert_called_with(cmd)
47
48     @mock.patch('functest.cli.commands.cli_testcase.ft_utils.execute_command')
49     def test_run_missing_noclean_report(self, mock_ft_utils):
50         cmd = "run_tests -t {}".format(self.testname)
51         self.cli_tests.run(self.testname, noclean=False, report=False)
52         mock_ft_utils.assert_called_with(cmd)
53
54     @mock.patch('functest.cli.commands.cli_testcase.click.echo')
55     def test_list(self, mock_click_echo):
56         with mock.patch.object(self.cli_tests.tiers, 'get_tiers',
57                                return_value=[]):
58             self.cli_tests.list()
59             mock_click_echo.assert_called_with("")
60
61     @mock.patch('functest.cli.commands.cli_testcase.click.echo')
62     def test_show_default_desc_none(self, mock_click_echo):
63         with mock.patch.object(self.cli_tests.tiers, 'get_test',
64                                return_value=None):
65             self.cli_tests.show(self.testname)
66             mock_click_echo.assert_any_call("The test case '%s' "
67                                             "does not exist or is"
68                                             " not supported."
69                                             % self.testname)
70
71     @mock.patch('functest.cli.commands.cli_testcase.click.echo')
72     def test_show_default(self, mock_click_echo):
73         mock_obj = mock.Mock()
74         with mock.patch.object(self.cli_tests.tiers, 'get_test',
75                                return_value=mock_obj):
76             self.cli_tests.show(self.testname)
77             mock_click_echo.assert_called_with(mock_obj)
78
79
80 if __name__ == "__main__":
81     logging.disable(logging.CRITICAL)
82     unittest.main(verbosity=2)