Do not error if collection specified null dependencies (#67575)

pull/67626/head
Alan Rominger 5 years ago committed by GitHub
parent 2de4e55650
commit cffead4631
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -0,0 +1,2 @@
bugfixes:
- Fix collection install error that happened if a dependency specified dependencies to be null (https://github.com/ansible/ansible/issues/67574).

@ -110,13 +110,17 @@ class CollectionRequirement:
@property @property
def dependencies(self): def dependencies(self):
if self._metadata: if not self._metadata:
return self._metadata.dependencies if len(self.versions) > 1:
elif len(self.versions) > 1: return {}
return None
self._get_metadata() self._get_metadata()
return self._metadata.dependencies
dependencies = self._metadata.dependencies
if dependencies is None:
return {}
return dependencies
def add_requirement(self, parent, requirement): def add_requirement(self, parent, requirement):
self.required_by.append((parent, requirement)) self.required_by.append((parent, requirement))

@ -341,7 +341,7 @@ def test_build_requirement_from_name(galaxy_server, monkeypatch):
assert actual.skip is False assert actual.skip is False
assert actual.versions == set([u'2.1.9', u'2.1.10']) assert actual.versions == set([u'2.1.9', u'2.1.10'])
assert actual.latest_version == u'2.1.10' assert actual.latest_version == u'2.1.10'
assert actual.dependencies is None assert actual.dependencies == {}
assert mock_get_versions.call_count == 1 assert mock_get_versions.call_count == 1
assert mock_get_versions.mock_calls[0][1] == ('namespace', 'collection') assert mock_get_versions.mock_calls[0][1] == ('namespace', 'collection')
@ -361,7 +361,7 @@ def test_build_requirement_from_name_with_prerelease(galaxy_server, monkeypatch)
assert actual.skip is False assert actual.skip is False
assert actual.versions == set([u'1.0.1', u'2.0.1']) assert actual.versions == set([u'1.0.1', u'2.0.1'])
assert actual.latest_version == u'2.0.1' assert actual.latest_version == u'2.0.1'
assert actual.dependencies is None assert actual.dependencies == {}
assert mock_get_versions.call_count == 1 assert mock_get_versions.call_count == 1
assert mock_get_versions.mock_calls[0][1] == ('namespace', 'collection') assert mock_get_versions.mock_calls[0][1] == ('namespace', 'collection')
@ -411,7 +411,7 @@ def test_build_requirement_from_name_second_server(galaxy_server, monkeypatch):
assert actual.skip is False assert actual.skip is False
assert actual.versions == set([u'1.0.2', u'1.0.3']) assert actual.versions == set([u'1.0.2', u'1.0.3'])
assert actual.latest_version == u'1.0.3' assert actual.latest_version == u'1.0.3'
assert actual.dependencies is None assert actual.dependencies == {}
assert mock_404.call_count == 1 assert mock_404.call_count == 1
assert mock_404.mock_calls[0][1] == ('namespace', 'collection') assert mock_404.mock_calls[0][1] == ('namespace', 'collection')
@ -511,7 +511,7 @@ def test_build_requirement_from_name_multiple_version_results(galaxy_server, mon
assert actual.skip is False assert actual.skip is False
assert actual.versions == set([u'2.0.0', u'2.0.1', u'2.0.3', u'2.0.4', u'2.0.5']) assert actual.versions == set([u'2.0.0', u'2.0.1', u'2.0.3', u'2.0.4', u'2.0.5'])
assert actual.latest_version == u'2.0.5' assert actual.latest_version == u'2.0.5'
assert actual.dependencies is None assert actual.dependencies == {}
assert mock_get_versions.call_count == 1 assert mock_get_versions.call_count == 1
assert mock_get_versions.mock_calls[0][1] == ('namespace', 'collection') assert mock_get_versions.mock_calls[0][1] == ('namespace', 'collection')

Loading…
Cancel
Save