Matthew Treinish | 9cf0703 | 2017-10-26 17:46:55 -0400 | [diff] [blame] | 1 | # Copyright 2017 IBM Corp. |
| 2 | # |
| 3 | # Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 4 | # not use this file except in compliance with the License. You may obtain |
| 5 | # a copy of the License at |
| 6 | # |
| 7 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | # |
| 9 | # Unless required by applicable law or agreed to in writing, software |
| 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 12 | # License for the specific language governing permissions and limitations |
| 13 | # under the License. |
| 14 | |
| 15 | import mock |
| 16 | |
| 17 | from tempest.tests import base |
| 18 | |
| 19 | |
| 20 | class ConfCounter(object): |
| 21 | |
| 22 | def __init__(self, *args, **kwargs): |
| 23 | self.count = 0 |
| 24 | |
| 25 | def __getattr__(self, key): |
| 26 | self.count += 1 |
| 27 | return mock.MagicMock() |
| 28 | |
| 29 | def get_counts(self): |
| 30 | return self.count |
| 31 | |
| 32 | |
| 33 | class TestImports(base.TestCase): |
| 34 | def setUp(self): |
| 35 | super(TestImports, self).setUp() |
| 36 | self.conf_mock = self.patch('tempest.config.CONF', |
| 37 | new_callable=ConfCounter) |
| 38 | |
| 39 | def test_account_generator_command_import(self): |
| 40 | from tempest.cmd import account_generator # noqa |
| 41 | self.assertEqual(0, self.conf_mock.get_counts()) |
| 42 | |
| 43 | def test_cleanup_command_import(self): |
| 44 | from tempest.cmd import cleanup # noqa |
| 45 | self.assertEqual(0, self.conf_mock.get_counts()) |
| 46 | |
| 47 | def test_init_command_import(self): |
| 48 | from tempest.cmd import init # noqa |
| 49 | self.assertEqual(0, self.conf_mock.get_counts()) |
| 50 | |
| 51 | def test_list_plugins_command_import(self): |
| 52 | from tempest.cmd import list_plugins # noqa |
| 53 | self.assertEqual(0, self.conf_mock.get_counts()) |
| 54 | |
| 55 | def test_run_command_import(self): |
| 56 | from tempest.cmd import run # noqa |
| 57 | self.assertEqual(0, self.conf_mock.get_counts()) |
| 58 | |
| 59 | def test_subunit_descibe_command_import(self): |
| 60 | from tempest.cmd import subunit_describe_calls # noqa |
| 61 | self.assertEqual(0, self.conf_mock.get_counts()) |
| 62 | |
| 63 | def test_verify_tempest_config_command_import(self): |
| 64 | from tempest.cmd import verify_tempest_config # noqa |
| 65 | self.assertEqual(0, self.conf_mock.get_counts()) |
| 66 | |
| 67 | def test_workspace_command_import(self): |
| 68 | from tempest.cmd import workspace # noqa |
| 69 | self.assertEqual(0, self.conf_mock.get_counts()) |