diff options
author | Sam Doran <sdoran@redhat.com> | 2020-05-19 11:31:49 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-19 10:31:49 -0500 |
commit | f01de15d25e81b0a2709e6a94ed1ec72d95b8f6f (patch) | |
tree | 2656b36b491dbd70405a395fc87ee8f138920afa /test/units/galaxy | |
parent | dd4219184bda029c8d667b33c9813e77397a0a05 (diff) | |
download | ansible-f01de15d25e81b0a2709e6a94ed1ec72d95b8f6f.tar.gz |
ansible-galaxy - remove warning during collection install (#69541)
* ansible-galaxy - remove warning during collection install
If existing collections do not contain a MANIFEST.json, which is common
for collections under development that were not installed from Ansible
Galaxy, fall back to inspecting galaxy.yml rather than displaying a
warning.
A warning will still be displayed in neither a MANIFEST.json nor
galaxy.yml are present.
* Update unit tests
Diffstat (limited to 'test/units/galaxy')
-rw-r--r-- | test/units/galaxy/test_collection_install.py | 34 |
1 files changed, 28 insertions, 6 deletions
diff --git a/test/units/galaxy/test_collection_install.py b/test/units/galaxy/test_collection_install.py index 8c821d7423..a1526ad0ea 100644 --- a/test/units/galaxy/test_collection_install.py +++ b/test/units/galaxy/test_collection_install.py @@ -746,12 +746,34 @@ def test_install_collections_existing_without_force(collection_artifact, monkeyp # Filter out the progress cursor display calls. display_msgs = [m[1][0] for m in mock_display.mock_calls if 'newline' not in m[2] and len(m[1]) == 1] - assert len(display_msgs) == 4 - # Msg1 is the warning about not MANIFEST.json, cannot really check message as it has line breaks which varies based - # on the path size - assert display_msgs[1] == "Process install dependency map" - assert display_msgs[2] == "Starting collection install process" - assert display_msgs[3] == "Skipping 'ansible_namespace.collection' as it is already installed" + assert len(display_msgs) == 3 + + assert display_msgs[0] == "Process install dependency map" + assert display_msgs[1] == "Starting collection install process" + assert display_msgs[2] == "Skipping 'ansible_namespace.collection' as it is already installed" + + for msg in display_msgs: + assert 'WARNING' not in msg + + +def test_install_missing_metadata_warning(collection_artifact, monkeypatch): + collection_path, collection_tar = collection_artifact + temp_path = os.path.split(collection_tar)[0] + + mock_display = MagicMock() + monkeypatch.setattr(Display, 'display', mock_display) + + for file in [b'MANIFEST.json', b'galaxy.yml']: + b_path = os.path.join(collection_path, file) + if os.path.isfile(b_path): + os.unlink(b_path) + + collection.install_collections([(to_text(collection_tar), '*', None,)], to_text(temp_path), + [u'https://galaxy.ansible.com'], True, False, False, False, False) + + display_msgs = [m[1][0] for m in mock_display.mock_calls if 'newline' not in m[2] and len(m[1]) == 1] + + assert 'WARNING' in display_msgs[0] # Makes sure we don't get stuck in some recursive loop |