-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Account for collections with no stable / final releases (#88)
* ignore runtime directory * add prerelase test fixtures * update units for prerelease * add helper to compare collection versions with prerelease awareness * use prerelease aware version comparison * add changelog fragment * removed commented out code
- Loading branch information
Showing
9 changed files
with
170 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
--- | ||
bugfixes: | ||
- A collection that had only prereleases would cause a 500 error when visiting certain endpoints due to a lack of a ``latest_version`` key. The latest version is now the latest stable (non-prerelease) version if any exist, which is the same behavior as before, but if only prereleases exist, then ``latest_version`` will refer to the latest prerelease (https://github.com/briantist/galactory/issues/87). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
* | ||
!.gitignore |
30 changes: 30 additions & 0 deletions
30
tests/fixtures/artifactory/virtual/subpath/briantist-devel-0.1.0-dev0.tar.gz/MANIFEST.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
{ | ||
"collection_info": { | ||
"namespace": "briantist", | ||
"name": "devel", | ||
"version": "0.1.0-dev0", | ||
"authors": [ | ||
"your name <[email protected]>" | ||
], | ||
"readme": "README.md", | ||
"tags": [], | ||
"description": "your collection description", | ||
"license": [ | ||
"GPL-2.0-or-later" | ||
], | ||
"license_file": null, | ||
"dependencies": {}, | ||
"repository": "http://example.com/repository", | ||
"documentation": "http://docs.example.com", | ||
"homepage": "http://example.com", | ||
"issues": "http://example.com/issue/tracker" | ||
}, | ||
"file_manifest_file": { | ||
"name": "FILES.json", | ||
"ftype": "file", | ||
"chksum_type": "sha256", | ||
"chksum_sha256": "58f8efd1f1e4f7e2afba0b773b1ec58cd3518c3c1d91bd29c54fc4187297a739", | ||
"format": 1 | ||
}, | ||
"format": 1 | ||
} |
30 changes: 30 additions & 0 deletions
30
tests/fixtures/artifactory/virtual/subpath/briantist-devel-0.1.0-dev1.tar.gz/MANIFEST.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
{ | ||
"collection_info": { | ||
"namespace": "briantist", | ||
"name": "devel", | ||
"version": "0.1.0-dev1", | ||
"authors": [ | ||
"your name <[email protected]>" | ||
], | ||
"readme": "README.md", | ||
"tags": [], | ||
"description": "your collection description", | ||
"license": [ | ||
"GPL-2.0-or-later" | ||
], | ||
"license_file": null, | ||
"dependencies": {}, | ||
"repository": "http://example.com/repository", | ||
"documentation": "http://docs.example.com", | ||
"homepage": "http://example.com", | ||
"issues": "http://example.com/issue/tracker" | ||
}, | ||
"file_manifest_file": { | ||
"name": "FILES.json", | ||
"ftype": "file", | ||
"chksum_type": "sha256", | ||
"chksum_sha256": "58f8efd1f1e4f7e2afba0b773b1ec58cd3518c3c1d91bd29c54fc4187297a739", | ||
"format": 1 | ||
}, | ||
"format": 1 | ||
} |
30 changes: 30 additions & 0 deletions
30
...s/fixtures/artifactory/virtual/subpath/briantist-whatever-0.2.0-dev0.tar.gz/MANIFEST.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
{ | ||
"collection_info": { | ||
"namespace": "briantist", | ||
"name": "whatever", | ||
"version": "0.2.0-dev0", | ||
"authors": [ | ||
"your name <[email protected]>" | ||
], | ||
"readme": "README.md", | ||
"tags": [], | ||
"description": "your collection description", | ||
"license": [ | ||
"GPL-2.0-or-later" | ||
], | ||
"license_file": null, | ||
"dependencies": {}, | ||
"repository": "http://example.com/repository", | ||
"documentation": "http://docs.example.com", | ||
"homepage": "http://example.com", | ||
"issues": "http://example.com/issue/tracker" | ||
}, | ||
"file_manifest_file": { | ||
"name": "FILES.json", | ||
"ftype": "file", | ||
"chksum_type": "sha256", | ||
"chksum_sha256": "58f8efd1f1e4f7e2afba0b773b1ec58cd3518c3c1d91bd29c54fc4187297a739", | ||
"format": 1 | ||
}, | ||
"format": 1 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# -*- coding: utf-8 -*- | ||
# (c) 2023 Brian Scholer (@briantist) | ||
|
||
import pytest | ||
from unittest import mock | ||
|
||
from datetime import datetime, timedelta | ||
from types import GeneratorType | ||
import semver | ||
|
||
from galactory.utilities import _latest_collection_version | ||
|
||
|
||
@pytest.mark.parametrize(["ref", "dif", "exp"], [ | ||
("0.0.0-dev0", "0.0.0-dev1", "0.0.0-dev1"), | ||
("0.0.0", "0.0.0-dev1", "0.0.0"), | ||
("1.2.3", "1.2.4", "1.2.4"), | ||
("0.0.0-dev0", "0.0.0-dev1", "0.0.0-dev1"), | ||
("0.0.0", "99.99.99-dev1", "0.0.0"), | ||
]) | ||
@pytest.mark.parametrize("prop", [None, "semver", "other"]) | ||
def test_latest_collection_version(ref, dif, exp, prop): | ||
reference = semver.VersionInfo.parse(ref) | ||
difference = semver.VersionInfo.parse(dif) | ||
expected = ref if exp == ref else dif | ||
|
||
opprop = {} | ||
if prop is None: | ||
expprop = "semver" | ||
else: | ||
opprop["property"] = expprop = prop | ||
|
||
# ensure we didn't mess up the test cases | ||
assert expected in [reference, difference] | ||
|
||
result = _latest_collection_version({expprop: reference}, {expprop: difference}, **opprop) | ||
|
||
assert result[expprop] == expected |