diff --git a/tools/src/test/python/dlpx/virtualization/_internal/commands/test_build.py b/tools/src/test/python/dlpx/virtualization/_internal/commands/test_build.py index 1da6388a..e6467ccc 100644 --- a/tools/src/test/python/dlpx/virtualization/_internal/commands/test_build.py +++ b/tools/src/test/python/dlpx/virtualization/_internal/commands/test_build.py @@ -320,7 +320,8 @@ def test_zip_and_encode_source_files_invalid_dir(src_dir): @staticmethod @mock.patch('compileall.compile_dir') - def test_zip_and_encode_source_files_compileall_fail(mock_compile, src_dir): + def test_zip_and_encode_source_files_compileall_fail( + mock_compile, src_dir): mock_compile.return_value = 0 with pytest.raises(exceptions.UserError) as err_info: build.zip_and_encode_source_files(src_dir) @@ -442,7 +443,7 @@ def test_plugin_no_src_dir(mock_generate_python, mock_path_is_relative, message = err_info.value.message assert message == "The path '{}' does not exist.".format( - tmpdir.join(os.path.join('fake', 'dir')).strpath) + tmpdir.join(os.path.join('fake', 'dir')).strpath) assert not mock_generate_python.called @@ -501,12 +502,14 @@ def test_schema_file_bad_permission(mock_generate_python, schema_file): # Make it so we can't read the file if os.name == 'nt': - pytest.skip('skipping this test on windows as os.chmod has issues removing permissions on file') - # - # The schema_file can be made unreadable on windows using pypiwin32 but - # since it adds dependency on pypiwin32 for the sdk, skipping this test - # instead of potentially destabilizing the sdk by adding this dependency. - # + pytest.skip( + 'skipping this test on windows as os.chmod has issues removing' + ' permissions on file') + # + # The schema_file can be made unreadable on windows using pypiwin32 but + # since it adds dependency on pypiwin32 for the sdk, skipping this test + # instead of potentially destabilizing the sdk by adding this dependency. + # else: os.chmod(schema_file, 0000) with pytest.raises(exceptions.UserError) as err_info: @@ -666,8 +669,8 @@ def test_build_number_parameter(plugin_config_content, src_dir, pytest.param('lua-toolkit-1', 'lua-toolkit-1'), pytest.param(None, None) ]) - def test_lua_name_parameter(plugin_config_content, src_dir, - schema_content, expected): + def test_lua_name_parameter(plugin_config_content, src_dir, schema_content, + expected): upload_artifact = build.prepare_upload_artifact( plugin_config_content, src_dir, schema_content, {}) assert expected == upload_artifact.get('luaName') diff --git a/tools/src/test/python/dlpx/virtualization/_internal/commands/test_codegen.py b/tools/src/test/python/dlpx/virtualization/_internal/commands/test_codegen.py index ad5b8c0c..383e9189 100644 --- a/tools/src/test/python/dlpx/virtualization/_internal/commands/test_codegen.py +++ b/tools/src/test/python/dlpx/virtualization/_internal/commands/test_codegen.py @@ -371,7 +371,8 @@ def test_copy_generated_to_dir_fail(tmpdir): codegen._copy_generated_to_dir(src_dir, dst_dir) if os.name == 'nt': - assert err_info.value.strerror == 'The system cannot find the path specified' + assert err_info.value.strerror == 'The system cannot find the path' \ + ' specified' else: assert err_info.value.strerror == 'No such file or directory' diff --git a/tools/src/test/python/dlpx/virtualization/_internal/commands/test_delphix_client.py b/tools/src/test/python/dlpx/virtualization/_internal/commands/test_delphix_client.py index d663e7c3..6a9e158c 100644 --- a/tools/src/test/python/dlpx/virtualization/_internal/commands/test_delphix_client.py +++ b/tools/src/test/python/dlpx/virtualization/_internal/commands/test_delphix_client.py @@ -224,27 +224,27 @@ def httpretty_enabled(): JOB_RESP_FAIL = (('{"type": "OKResult", "status": "OK", "result": ' '{"jobState": "FAILED", "events": []}}'), { - 'X-Frame-Options': 'SAMEORIGIN', - 'X-Content-Type-Options': 'nosniff', - 'X-XSS-Protection': '1; mode=block', - 'Cache-Control': 'max-age=0', - 'Expires': 'Mon, 04 Feb 2019 23:12:00 GMT', - 'Content-Type': 'application/json', - 'Content-Length': '71', - 'Date': 'Mon, 09 Mar 2020 12:09:27 GMT' - }) + 'X-Frame-Options': 'SAMEORIGIN', + 'X-Content-Type-Options': 'nosniff', + 'X-XSS-Protection': '1; mode=block', + 'Cache-Control': 'max-age=0', + 'Expires': 'Mon, 04 Feb 2019 23:12:00 GMT', + 'Content-Type': 'application/json', + 'Content-Length': '71', + 'Date': 'Mon, 09 Mar 2020 12:09:27 GMT' + }) JOB_RESP_TIMED_OUT = (('{"type": "OKResult", "status": "OK", "result": ' '{"jobState": "RUNNING", "events": []}}'), { - 'X-Frame-Options': 'SAMEORIGIN', - 'X-Content-Type-Options': 'nosniff', - 'X-XSS-Protection': '1; mode=block', - 'Cache-Control': 'max-age=0', - 'Expires': 'Mon, 04 Feb 2019 23:12:00 GMT', - 'Content-Type': 'application/json', - 'Content-Length': '71', - 'Date': 'Mon, 09 Mar 2020 12:09:27 GMT' - }) + 'X-Frame-Options': 'SAMEORIGIN', + 'X-Content-Type-Options': 'nosniff', + 'X-XSS-Protection': '1; mode=block', + 'Cache-Control': 'max-age=0', + 'Expires': 'Mon, 04 Feb 2019 23:12:00 GMT', + 'Content-Type': 'application/json', + 'Content-Length': '71', + 'Date': 'Mon, 09 Mar 2020 12:09:27 GMT' + }) PLUGIN_RESP_SUCCESS = ( '{"type": "ListResult", "status": "OK", "result": [' diff --git a/tools/src/test/python/dlpx/virtualization/_internal/conftest.py b/tools/src/test/python/dlpx/virtualization/_internal/conftest.py index c3d89473..77df87ca 100644 --- a/tools/src/test/python/dlpx/virtualization/_internal/conftest.py +++ b/tools/src/test/python/dlpx/virtualization/_internal/conftest.py @@ -171,7 +171,8 @@ def artifact_file_created(): @pytest.fixture def plugin_config_content(plugin_id, plugin_name, external_version, language, host_types, plugin_type, entry_point, src_dir, - schema_file, manual_discovery, build_number, lua_name): + schema_file, manual_discovery, build_number, + lua_name): """ This fixutre creates the dict expected in the properties yaml file the customer must provide for the build and compile commands. diff --git a/tools/src/test/python/dlpx/virtualization/_internal/test_file_util.py b/tools/src/test/python/dlpx/virtualization/_internal/test_file_util.py index 70db38e7..117aaa94 100644 --- a/tools/src/test/python/dlpx/virtualization/_internal/test_file_util.py +++ b/tools/src/test/python/dlpx/virtualization/_internal/test_file_util.py @@ -35,8 +35,8 @@ def test_get_src_dir_path_relative(tmp_path): cwd = os.getcwd() try: os.chdir(str(tmp_path)) - actual = file_util.get_src_dir_path(os.path.join('plugin', 'plugin_config.yml'), - 'src') + actual = file_util.get_src_dir_path( + os.path.join('plugin', 'plugin_config.yml'), 'src') finally: os.chdir(cwd) @@ -78,15 +78,16 @@ def test_get_src_dir_path_is_dir_fail(mock_existing_path, @mock.patch('os.path.isdir', return_value=True) @mock.patch('os.path.exists', return_value=True) @mock.patch('os.path.isabs', return_value=False) - @pytest.mark.parametrize( - 'plugin_config_file_path, src_dir_path', - [('plugin/file_name', '.'), - ('/mongo/file_name', '/src'), ('/plugin/mongo/file_name', '/plugin'), - ('/plugin/file_name', '/plugin/src/../..')]) + @pytest.mark.parametrize('plugin_config_file_path, src_dir_path', + [('plugin/file_name', '.'), + ('/mongo/file_name', '/src'), + ('/plugin/mongo/file_name', '/plugin'), + ('/plugin/file_name', '/plugin/src/../..')]) def test_get_src_dir_path_fail(mock_relative_path, mock_existing_path, mock_directory_path, plugin_config_file_path, src_dir_path): - expected_plugin_root_dir = os.path.join(os.getcwd(), os.path.dirname(plugin_config_file_path)) + expected_plugin_root_dir = os.path.join( + os.getcwd(), os.path.dirname(plugin_config_file_path)) expected_plugin_root_dir = file_util.standardize_path( expected_plugin_root_dir) diff --git a/tools/src/test/python/dlpx/virtualization/_internal/test_plugin_dependency_util.py b/tools/src/test/python/dlpx/virtualization/_internal/test_plugin_dependency_util.py index f5d6db83..817a3ab9 100644 --- a/tools/src/test/python/dlpx/virtualization/_internal/test_plugin_dependency_util.py +++ b/tools/src/test/python/dlpx/virtualization/_internal/test_plugin_dependency_util.py @@ -61,8 +61,7 @@ def clean_up(a, b, c): mock_build_wheel.side_effect = build_wheel pdu.install_deps(str(build_dir), local_vsdk_root='vsdk') - mock_install_to_dir.assert_called_once_with(packages, - str(build_dir)) + mock_install_to_dir.assert_called_once_with(packages, str(build_dir)) @staticmethod @mock.patch.object(subprocess, 'Popen') diff --git a/tools/src/test/python/dlpx/virtualization/_internal/test_plugin_importer.py b/tools/src/test/python/dlpx/virtualization/_internal/test_plugin_importer.py index 26a3d4ba..7a1ce1ab 100644 --- a/tools/src/test/python/dlpx/virtualization/_internal/test_plugin_importer.py +++ b/tools/src/test/python/dlpx/virtualization/_internal/test_plugin_importer.py @@ -44,23 +44,22 @@ class TestPluginImporter: """ This class tests the plugin_importer module of sdk. Though some of these tests used mock initially to mock out the calls to subprocess, it was found - that the behaviour is different between windows and linux causing these tests + that the behaviour is different between windows and linux causing these tests to fail on windows. So, some refactoring is done in plugin_importer to facilitate testing without the mocks. - - The issue is described in detail here : + + The issue is described in detail here: https://rhodesmill.org/brandon/2010/python-multiprocessing-linux-windows/ """ @staticmethod - def test_get_plugin_manifest(src_dir, plugin_type, - entry_point_module, entry_point_object, - plugin_module_content, plugin_manifest): + def test_get_plugin_manifest(src_dir, plugin_type, entry_point_module, + entry_point_object, plugin_module_content, + plugin_manifest): queue = Queue() manifest = plugin_importer.get_manifest(src_dir, entry_point_module, entry_point_object, plugin_module_content, - plugin_type, - False, queue) + plugin_type, False, queue) assert manifest == plugin_manifest @@ -70,54 +69,45 @@ def test_plugin_module_content_none(src_dir, plugin_type, entry_point_object): queue = Queue() manifest = plugin_importer.get_manifest(src_dir, entry_point_module, - entry_point_object, - None, - plugin_type, - False, queue) + entry_point_object, None, + plugin_type, False, queue) assert manifest is None @staticmethod - def test_plugin_entry_object_none(src_dir, plugin_type, - entry_point_module, plugin_module_content): + def test_plugin_entry_object_none(src_dir, plugin_type, entry_point_module, + plugin_module_content): queue = Queue() - manifest = plugin_importer.get_manifest(src_dir, entry_point_module, - None, - plugin_module_content, - plugin_type, - False, queue) + plugin_importer.get_manifest(src_dir, entry_point_module, None, + plugin_module_content, plugin_type, False, + queue) message = str(queue.get('exception')) assert 'Plugin entry point object is None.' in message @staticmethod def test_plugin_entry_point_nonexistent(src_dir, plugin_type, - entry_point_module, - plugin_name, + entry_point_module, plugin_name, plugin_module_content): entry_point_name = "nonexistent entry point" queue = Queue() - manifest = plugin_importer.get_manifest(src_dir, entry_point_module, - entry_point_name, - plugin_module_content, - plugin_type, - False, queue) + plugin_importer.get_manifest(src_dir, entry_point_module, + entry_point_name, plugin_module_content, + plugin_type, False, queue) message = str(queue.get('exception')) - assert ("'{}' is not a symbol in module".format(entry_point_name) in - message) + assert ("'{}' is not a symbol in module".format(entry_point_name) + in message) @staticmethod - def test_plugin_object_none(src_dir, plugin_type, entry_point_module, plugin_name, - plugin_module_content): + def test_plugin_object_none(src_dir, plugin_type, entry_point_module, + plugin_name, plugin_module_content): none_entry_point = "none_entry_point" setattr(plugin_module_content, none_entry_point, None) queue = Queue() - manifest = plugin_importer.get_manifest(src_dir, entry_point_module, - none_entry_point, - plugin_module_content, - plugin_type, - False, queue) + plugin_importer.get_manifest(src_dir, entry_point_module, + none_entry_point, plugin_module_content, + plugin_type, False, queue) message = str(queue.get('exception')) assert ('Plugin object retrieved from the entry point {} is' diff --git a/tools/src/test/python/dlpx/virtualization/_internal/test_plugin_validator.py b/tools/src/test/python/dlpx/virtualization/_internal/test_plugin_validator.py index 1a7e8eeb..ab9e645e 100644 --- a/tools/src/test/python/dlpx/virtualization/_internal/test_plugin_validator.py +++ b/tools/src/test/python/dlpx/virtualization/_internal/test_plugin_validator.py @@ -174,11 +174,11 @@ def test_plugin_build_number_format(src_dir, plugin_config_file, @staticmethod @mock.patch('os.path.isabs', return_value=False) - @pytest.mark.parametrize('lua_name, expected', [ - ('lua toolkit', "'lua toolkit' does not match"), - ('!lua#toolkit', "'!lua#toolkit' does not match"), - (None, "should never get here") - ]) + @pytest.mark.parametrize( + 'lua_name, expected', + [('lua toolkit', "'lua toolkit' does not match"), + ('!lua#toolkit', "'!lua#toolkit' does not match"), + (None, "should never get here")]) def test_plugin_lua_name_format(src_dir, plugin_config_file, plugin_config_content, expected): try: diff --git a/tools/src/test/python/dlpx/virtualization/_internal/test_schema_validator.py b/tools/src/test/python/dlpx/virtualization/_internal/test_schema_validator.py index bdda9821..2901c0cf 100644 --- a/tools/src/test/python/dlpx/virtualization/_internal/test_schema_validator.py +++ b/tools/src/test/python/dlpx/virtualization/_internal/test_schema_validator.py @@ -354,5 +354,5 @@ def test_bad_type_in_array(schema_file): validator.validate() message = err_info.value.message - assert ( - "'strings' is not valid under any of the given schemas" in message) + assert ("'strings' is not valid under any of the given schemas" + in message)