Disable all missing-docstring warnings in unit tests
[functest.git] / functest / tests / unit / cli / commands / test_cli_env.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_env
16 from functest.utils.constants import CONST
17 from functest.tests.unit import test_utils
18
19
20 class CliEnvTesting(unittest.TestCase):
21
22     def setUp(self):
23         self.cli_environ = cli_env.CliEnv()
24
25     def _test_show_missing_env_var(self, var, *args):
26         if var == 'INSTALLER_TYPE':
27             CONST.__setattr__('INSTALLER_TYPE', None)
28             reg_string = "|  INSTALLER: Unknown, \S+\s*|"
29         elif var == 'INSTALLER_IP':
30             CONST.__setattr__('INSTALLER_IP', None)
31             reg_string = "|  INSTALLER: \S+, Unknown\s*|"
32         elif var == 'SCENARIO':
33             CONST.__setattr__('DEPLOY_SCENARIO', None)
34             reg_string = "|   SCENARIO: Unknown\s*|"
35         elif var == 'NODE':
36             CONST.__setattr__('NODE_NAME', None)
37             reg_string = "|        POD: Unknown\s*|"
38         elif var == 'BUILD_TAG':
39             CONST.__setattr__('BUILD_TAG', None)
40             reg_string = "|  BUILD TAG: None|"
41         elif var == 'DEBUG':
42             CONST.__setattr__('CI_DEBUG', None)
43             reg_string = "| DEBUG FLAG: false\s*|"
44
45         with mock.patch('functest.cli.commands.cli_env.click.echo') \
46                 as mock_click_echo:
47             self.cli_environ.show()
48             mock_click_echo.assert_called_with(test_utils.
49                                                RegexMatch(reg_string))
50
51     def test_show_missing_ci_installer_type(self, *args):
52         self._test_show_missing_env_var('INSTALLER_TYPE', *args)
53
54     def test_show_missing_ci_installer_ip(self, *args):
55         self._test_show_missing_env_var('INSTALLER_IP', *args)
56
57     def test_show_missing_ci_scenario(self, *args):
58         self._test_show_missing_env_var('SCENARIO', *args)
59
60     def test_show_missing_ci_node(self, *args):
61         self._test_show_missing_env_var('NODE', *args)
62
63     def test_show_missing_ci_build_tag(self, *args):
64         self._test_show_missing_env_var('BUILD_TAG', *args)
65
66     def test_show_missing_ci_debug(self, *args):
67         self._test_show_missing_env_var('DEBUG', *args)
68
69
70 if __name__ == "__main__":
71     logging.disable(logging.CRITICAL)
72     unittest.main(verbosity=2)