diff --git a/pulp_ansible/app/tasks/collections.py b/pulp_ansible/app/tasks/collections.py index c7393ed93..e688ea63b 100644 --- a/pulp_ansible/app/tasks/collections.py +++ b/pulp_ansible/app/tasks/collections.py @@ -437,6 +437,8 @@ def is_new_highest(new, old): return True if new.prerelease and not old.prerelease: return False + if not new.prerelease and old.prerelease: + return True return new > old # did we have one set previously for this collection? diff --git a/pulp_ansible/tests/unit/test_tasks.py b/pulp_ansible/tests/unit/test_tasks.py index b2c8a6f8b..c2d512ea4 100644 --- a/pulp_ansible/tests/unit/test_tasks.py +++ b/pulp_ansible/tests/unit/test_tasks.py @@ -178,6 +178,32 @@ def test_is_highest_set(self): is True ) + def test_is_highest_set_on_multple_stable_releases(self): + namespace = randstr() + name = randstr() + specs = [ + (namespace, name, "1.0.1"), + (namespace, name, "2.0.1"), + ] + + collection_versions = build_cvs_from_specs(specs) + for cv in collection_versions: + _update_highest_version(cv, save=True) + + assert ( + CollectionVersion.objects.filter(namespace=namespace, name=name, version="1.0.1") + .first() + .is_highest + is False + ) + + assert ( + CollectionVersion.objects.filter(namespace=namespace, name=name, version="2.0.1") + .first() + .is_highest + is True + ) + def test_is_highest_set_on_single_prerelease(self): namespace = randstr() name = randstr()