diff options
author | Sloane Hertel <19572925+s-hertel@users.noreply.github.com> | 2022-07-06 11:28:16 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-06 10:28:16 -0500 |
commit | d4cd1853b059dccde828cfb2787606f82d77a479 (patch) | |
tree | d506719942c1c8f66f8f4f609ac70256702dc1df | |
parent | 27890cd659502ee0972cc25d230dbbb93326025e (diff) | |
download | ansible-d4cd1853b059dccde828cfb2787606f82d77a479.tar.gz |
Make unit test for missing git executable more generic (#78173) (#78174)
* Make unit test for missing git executable more generic
* use MagicMock side_effect to raise exception instead
(cherry picked from commit 1562672bd1d5a6bd300c09112e812ac040893ef6)
-rw-r--r-- | test/units/galaxy/test_collection_install.py | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/test/units/galaxy/test_collection_install.py b/test/units/galaxy/test_collection_install.py index 7525a194ca..d83fe42054 100644 --- a/test/units/galaxy/test_collection_install.py +++ b/test/units/galaxy/test_collection_install.py @@ -181,13 +181,14 @@ def test_concrete_artifact_manager_scm_no_executable(monkeypatch): monkeypatch.setattr(collection.concrete_artifact_manager.subprocess, 'check_call', mock_subprocess_check_call) mock_mkdtemp = MagicMock(return_value='') monkeypatch.setattr(collection.concrete_artifact_manager, 'mkdtemp', mock_mkdtemp) + mock_get_bin_path = MagicMock(side_effect=[ValueError('Failed to find required executable')]) + monkeypatch.setattr(collection.concrete_artifact_manager, 'get_bin_path', mock_get_bin_path) error = re.escape( "Could not find git executable to extract the collection from the Git repository `https://github.com/org/repo`" ) - with mock.patch.dict(os.environ, {"PATH": ""}): - with pytest.raises(AnsibleError, match=error): - collection.concrete_artifact_manager._extract_collection_from_git(url, version, b'path') + with pytest.raises(AnsibleError, match=error): + collection.concrete_artifact_manager._extract_collection_from_git(url, version, b'path') @pytest.mark.parametrize( |