From d579e62b431a31856a03098dc5323948ccfa4fdb Mon Sep 17 00:00:00 2001 From: Emma Foley Date: Wed, 29 Nov 2017 23:34:15 +0000 Subject: [PATCH] Move tests: unit/common * Fix pylint errors * Add TODOs Some errors are ignored locally, as they were a symptom of other problems. These issues have been flagged with a TODO, and should be fixed later. JIRA: YARDSTICK-837 Change-Id: I2847c380556985fae2c92bb8a7da9c47e91e1338 Signed-off-by: Emma Foley --- {tests => yardstick/tests}/unit/common/__init__.py | 0 {tests => yardstick/tests}/unit/common/config_sample.yaml | 0 .../tests}/unit/common/test_ansible_common.py | 12 ++++++------ {tests => yardstick/tests}/unit/common/test_httpClient.py | 0 .../tests}/unit/common/test_openstack_utils.py | 2 +- {tests => yardstick/tests}/unit/common/test_process.py | 0 .../tests}/unit/common/test_template_format.py | 3 +++ {tests => yardstick/tests}/unit/common/test_utils.py | 0 {tests => yardstick/tests}/unit/common/test_yaml_loader.py | 0 9 files changed, 10 insertions(+), 7 deletions(-) rename {tests => yardstick/tests}/unit/common/__init__.py (100%) rename {tests => yardstick/tests}/unit/common/config_sample.yaml (100%) rename {tests => yardstick/tests}/unit/common/test_ansible_common.py (95%) rename {tests => yardstick/tests}/unit/common/test_httpClient.py (100%) rename {tests => yardstick/tests}/unit/common/test_openstack_utils.py (96%) rename {tests => yardstick/tests}/unit/common/test_process.py (100%) rename {tests => yardstick/tests}/unit/common/test_template_format.py (91%) rename {tests => yardstick/tests}/unit/common/test_utils.py (100%) rename {tests => yardstick/tests}/unit/common/test_yaml_loader.py (100%) diff --git a/tests/unit/common/__init__.py b/yardstick/tests/unit/common/__init__.py similarity index 100% rename from tests/unit/common/__init__.py rename to yardstick/tests/unit/common/__init__.py diff --git a/tests/unit/common/config_sample.yaml b/yardstick/tests/unit/common/config_sample.yaml similarity index 100% rename from tests/unit/common/config_sample.yaml rename to yardstick/tests/unit/common/config_sample.yaml diff --git a/tests/unit/common/test_ansible_common.py b/yardstick/tests/unit/common/test_ansible_common.py similarity index 95% rename from tests/unit/common/test_ansible_common.py rename to yardstick/tests/unit/common/test_ansible_common.py index 1ef8eee5f..89ea128af 100644 --- a/tests/unit/common/test_ansible_common.py +++ b/yardstick/tests/unit/common/test_ansible_common.py @@ -49,7 +49,7 @@ class OverwriteDictTestCase(unittest.TestCase): class FilenameGeneratorTestCase(unittest.TestCase): @mock.patch('{}.NamedTemporaryFile'.format(PREFIX)) - def test__handle_existing_file(self, mock_tmp): + def test__handle_existing_file(self, _): ansible_common.FileNameGenerator._handle_existing_file("/dev/null") def test_get_generator_from_file(self): @@ -184,7 +184,7 @@ class AnsibleCommonTestCase(unittest.TestCase): self.assertEqual(a.deploy_dir, "d") @mock.patch('{}.open'.format(PREFIX)) - def test__gen_ansible_playbook_file_list(self, mock_open): + def test__gen_ansible_playbook_file_list(self, _): d = tempfile.mkdtemp() try: a = ansible_common.AnsibleCommon({}) @@ -194,7 +194,7 @@ class AnsibleCommonTestCase(unittest.TestCase): @mock.patch('{}.NamedTemporaryFile'.format(PREFIX)) @mock.patch('{}.open'.format(PREFIX)) - def test__gen_ansible_inventory_file(self, mock_open, mock_tmp): + def test__gen_ansible_inventory_file(self, _, __): nodes = [{ "name": "name", "user": "user", "password": "PASS", "role": "role", @@ -213,7 +213,7 @@ class AnsibleCommonTestCase(unittest.TestCase): @mock.patch('{}.NamedTemporaryFile'.format(PREFIX)) @mock.patch('{}.open'.format(PREFIX)) - def test__gen_ansible_playbook_file_list_multiple(self, mock_open, mock_tmp): + def test__gen_ansible_playbook_file_list_multiple(self, _, __): d = tempfile.mkdtemp() try: a = ansible_common.AnsibleCommon({}) @@ -224,7 +224,7 @@ class AnsibleCommonTestCase(unittest.TestCase): @mock.patch('{}.NamedTemporaryFile'.format(PREFIX)) @mock.patch('{}.Popen'.format(PREFIX)) @mock.patch('{}.open'.format(PREFIX)) - def test_do_install_tmp_dir(self, mock_open, mock_popen, mock_tmp): + def test_do_install_tmp_dir(self, _, mock_popen, __): mock_popen.return_value.communicate.return_value = "", "" mock_popen.return_value.wait.return_value = 0 d = tempfile.mkdtemp() @@ -237,7 +237,7 @@ class AnsibleCommonTestCase(unittest.TestCase): @mock.patch('{}.NamedTemporaryFile'.format(PREFIX)) @mock.patch('{}.Popen'.format(PREFIX)) @mock.patch('{}.open'.format(PREFIX)) - def test_execute_ansible_check(self, mock_open, mock_popen, mock_tmp): + def test_execute_ansible_check(self, _, mock_popen, __): mock_popen.return_value.communicate.return_value = "", "" mock_popen.return_value.wait.return_value = 0 d = tempfile.mkdtemp() diff --git a/tests/unit/common/test_httpClient.py b/yardstick/tests/unit/common/test_httpClient.py similarity index 100% rename from tests/unit/common/test_httpClient.py rename to yardstick/tests/unit/common/test_httpClient.py diff --git a/tests/unit/common/test_openstack_utils.py b/yardstick/tests/unit/common/test_openstack_utils.py similarity index 96% rename from tests/unit/common/test_openstack_utils.py rename to yardstick/tests/unit/common/test_openstack_utils.py index b3dc2d9c4..bf468489e 100644 --- a/tests/unit/common/test_openstack_utils.py +++ b/yardstick/tests/unit/common/test_openstack_utils.py @@ -21,7 +21,7 @@ from yardstick.common import openstack_utils class GetCredentialsTestCase(unittest.TestCase): @mock.patch('yardstick.common.openstack_utils.os') - def test_get_credentials(self, mock_os): + def test_get_credentials(self, _): with mock.patch.dict('os.environ', {'OS_IDENTITY_API_VERSION': '2'}, clear=True): openstack_utils.get_credentials() diff --git a/tests/unit/common/test_process.py b/yardstick/tests/unit/common/test_process.py similarity index 100% rename from tests/unit/common/test_process.py rename to yardstick/tests/unit/common/test_process.py diff --git a/tests/unit/common/test_template_format.py b/yardstick/tests/unit/common/test_template_format.py similarity index 91% rename from tests/unit/common/test_template_format.py rename to yardstick/tests/unit/common/test_template_format.py index 2a7d80b4d..44aa80333 100644 --- a/tests/unit/common/test_template_format.py +++ b/yardstick/tests/unit/common/test_template_format.py @@ -24,6 +24,9 @@ class TemplateFormatTestCase(unittest.TestCase): def test_parse_to_value_exception(self): + # TODO(elfoley): Don't hide the error that occurs in + # template_format.parse + # TODO(elfoley): Separate these tests; one per error type with mock.patch.object(yaml, 'load') as yaml_loader: yaml_loader.side_effect = yaml.scanner.ScannerError() self.assertRaises(ValueError, template_format.parse, 'FOOBAR') diff --git a/tests/unit/common/test_utils.py b/yardstick/tests/unit/common/test_utils.py similarity index 100% rename from tests/unit/common/test_utils.py rename to yardstick/tests/unit/common/test_utils.py diff --git a/tests/unit/common/test_yaml_loader.py b/yardstick/tests/unit/common/test_yaml_loader.py similarity index 100% rename from tests/unit/common/test_yaml_loader.py rename to yardstick/tests/unit/common/test_yaml_loader.py -- 2.16.6