Skip to content

Commit

Permalink
Test both runtimes in unit tests (#1155) (#1157)
Browse files Browse the repository at this point in the history
(cherry picked from commit 79b564d)
  • Loading branch information
Shrews committed Nov 4, 2022
1 parent 8f39752 commit 181614f
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions test/unit/config/test__base.py
Expand Up @@ -288,7 +288,7 @@ def test_container_volume_mounting_with_Z(tmp_path, mocker):
raise Exception('Could not find expected mount, args: {}'.format(new_args))


@pytest.mark.test_all_runtimes
@pytest.mark.parametrize('runtime', ('docker', 'podman'))
def test_containerization_settings(tmp_path, runtime, mocker):
mocker.patch.dict('os.environ', {'HOME': str(tmp_path)}, clear=True)
tmp_path.joinpath('.ssh').mkdir()
Expand Down Expand Up @@ -346,7 +346,7 @@ def test_containerization_settings(tmp_path, runtime, mocker):
assert expected_command_start == rc.command


@pytest.mark.test_all_runtimes
@pytest.mark.parametrize('runtime', ('docker', 'podman'))
def test_containerization_unsafe_write_setting(tmp_path, runtime, mocker):
mock_containerized = mocker.patch('ansible_runner.config._base.BaseConfig.containerized', new_callable=mocker.PropertyMock)

Expand Down
2 changes: 1 addition & 1 deletion test/unit/config/test_ansible_cfg.py
Expand Up @@ -52,7 +52,7 @@ def test_prepare_config_invalid_action():
assert "Invalid action test, valid value is one of either list, dump, view" == exc.value.args[0]


@pytest.mark.test_all_runtimes
@pytest.mark.parametrize('runtime', ('docker', 'podman'))
def test_prepare_config_command_with_containerization(tmp_path, runtime, mocker):
mocker.patch.dict('os.environ', {'HOME': str(tmp_path)}, clear=True)
tmp_path.joinpath('.ssh').mkdir()
Expand Down
2 changes: 1 addition & 1 deletion test/unit/config/test_command.py
Expand Up @@ -61,7 +61,7 @@ def test_prepare_run_command_generic():
assert rc.execution_mode == BaseExecutionMode.GENERIC_COMMANDS


@pytest.mark.test_all_runtimes
@pytest.mark.parametrize('runtime', ('docker', 'podman'))
def test_prepare_run_command_with_containerization(tmp_path, runtime, mocker):
mocker.patch.dict('os.environ', {'HOME': str(tmp_path)}, clear=True)
tmp_path.joinpath('.ssh').mkdir()
Expand Down
4 changes: 2 additions & 2 deletions test/unit/config/test_doc.py
Expand Up @@ -58,7 +58,7 @@ def test_prepare_plugin_docs_command():
assert rc.execution_mode == BaseExecutionMode.ANSIBLE_COMMANDS


@pytest.mark.test_all_runtimes
@pytest.mark.parametrize('runtime', ('docker', 'podman'))
def test_prepare_plugin_docs_command_with_containerization(tmp_path, runtime, mocker):
mocker.patch.dict('os.environ', {'HOME': str(tmp_path)}, clear=True)
tmp_path.joinpath('.ssh').mkdir()
Expand Down Expand Up @@ -129,7 +129,7 @@ def test_prepare_plugin_list_command():
assert rc.execution_mode == BaseExecutionMode.ANSIBLE_COMMANDS


@pytest.mark.test_all_runtimes
@pytest.mark.parametrize('runtime', ('docker', 'podman'))
def test_prepare_plugin_list_command_with_containerization(tmp_path, runtime, mocker):
mocker.patch.dict('os.environ', {'HOME': str(tmp_path)}, clear=True)
tmp_path.joinpath('.ssh').mkdir()
Expand Down
2 changes: 1 addition & 1 deletion test/unit/config/test_inventory.py
Expand Up @@ -84,7 +84,7 @@ def test_prepare_inventory_invalid_graph_response_format():
assert "'graph' action supports only 'json' response format" == exc.value.args[0]


@pytest.mark.test_all_runtimes
@pytest.mark.parametrize('runtime', ('docker', 'podman'))
def test_prepare_inventory_command_with_containerization(tmp_path, runtime, mocker):
mocker.patch.dict('os.environ', {'HOME': str(tmp_path)}, clear=True)
tmp_path.joinpath('.ssh').mkdir()
Expand Down
2 changes: 1 addition & 1 deletion test/unit/config/test_runner.py
Expand Up @@ -710,7 +710,7 @@ def test_container_volume_mounting_with_Z(mocker, tmp_path):
raise Exception('Could not find expected mount, args: {}'.format(new_args))


@pytest.mark.test_all_runtimes
@pytest.mark.parametrize('runtime', ('docker', 'podman'))
def test_containerization_settings(tmp_path, runtime, mocker):
mocker.patch('os.path.isdir', return_value=True)
mocker.patch('os.path.exists', return_value=True)
Expand Down
2 changes: 1 addition & 1 deletion test/unit/test_cleanup.py
Expand Up @@ -47,7 +47,7 @@ def test_cleanup_command_grace_period(tmp_path):
assert os.path.exists(new_dir)


@pytest.mark.test_all_runtimes
@pytest.mark.parametrize('runtime', ('docker', 'podman'))
def test_registry_auth_cleanup(tmp_path, runtime):
pdd_path = tmp_path / 'private_data_dir'
pdd_path.mkdir()
Expand Down

0 comments on commit 181614f

Please sign in to comment.