forked from galaxyproject/galaxy-release-util
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
195 additions
and
79 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
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 |
---|---|---|
@@ -1,22 +1,65 @@ | ||
import datetime | ||
from packaging.version import Version | ||
|
||
import pytest | ||
|
||
from galaxy_release_util.bootstrap_history import get_release_date | ||
from galaxy_release_util import bootstrap_history | ||
from galaxy_release_util.bootstrap_history import ( | ||
#_get_release_date, | ||
_get_next_release_version, | ||
_get_previous_release_version, | ||
_get_next_release_version, | ||
_get_release_version_strings, | ||
) | ||
|
||
# test data tuples: freeze date, expected release date | ||
# (assumption: FREEZE_TO_RELEASE_DELTA_DAYS = 21) | ||
release_date_test_data = [ | ||
(datetime.datetime(2024, 11, 1), datetime.datetime(2024, 11, 22)), # expect Friday | ||
(datetime.datetime(2024, 11, 2), datetime.datetime(2024, 11, 25)), # expect Monday (not Saturday) | ||
(datetime.datetime(2024, 11, 3), datetime.datetime(2024, 11, 25)), # expect Monday (not Sunday) | ||
(datetime.datetime(2024, 11, 4), datetime.datetime(2024, 11, 25)), # expect Monday | ||
(datetime.datetime(2024, 11, 5), datetime.datetime(2024, 11, 26)), # expect Tuesday | ||
(datetime.datetime(2024, 11, 6), datetime.datetime(2024, 11, 27)), # expect Wednesday | ||
(datetime.datetime(2024, 11, 7), datetime.datetime(2024, 11, 28)), # expect Thursday | ||
] | ||
# TODO do we need this??? | ||
## test data tuples: freeze date, expected release date | ||
## (assumption: FREEZE_TO_RELEASE_DELTA_DAYS = 21) | ||
#release_date_test_data = [ | ||
# (datetime.datetime(2024, 11, 1), datetime.datetime(2024, 11, 22)), # expect Friday | ||
# (datetime.datetime(2024, 11, 2), datetime.datetime(2024, 11, 25)), # expect Monday (not Saturday) | ||
# (datetime.datetime(2024, 11, 3), datetime.datetime(2024, 11, 25)), # expect Monday (not Sunday) | ||
# (datetime.datetime(2024, 11, 4), datetime.datetime(2024, 11, 25)), # expect Monday | ||
# (datetime.datetime(2024, 11, 5), datetime.datetime(2024, 11, 26)), # expect Tuesday | ||
# (datetime.datetime(2024, 11, 6), datetime.datetime(2024, 11, 27)), # expect Wednesday | ||
# (datetime.datetime(2024, 11, 7), datetime.datetime(2024, 11, 28)), # expect Thursday | ||
#] | ||
# | ||
# | ||
#@pytest.mark.parametrize("freeze_date, expected_release_date", release_date_test_data) | ||
#def test_get_release_date(freeze_date, expected_release_date): | ||
# assert _get_release_date(freeze_date) == expected_release_date | ||
# | ||
|
||
|
||
def test_get_previous_release_version(monkeypatch): | ||
monkeypatch.setattr(bootstrap_history, "_get_release_version_strings", lambda x: sorted(["22.01", "22.05", "23.0", "23.1"])) | ||
|
||
assert _get_previous_release_version(None, Version("15.1")) == None | ||
assert _get_previous_release_version(None, Version("22.01")) == None | ||
assert _get_previous_release_version(None, Version("22.05")) == Version("22.01") | ||
assert _get_previous_release_version(None, Version("23.0")) == Version("22.05") | ||
assert _get_previous_release_version(None, Version("23.1")) == Version("23.0") | ||
assert _get_previous_release_version(None, Version("23.2")) == Version("23.1") | ||
assert _get_previous_release_version(None, Version("99.99")) == Version("23.1") | ||
|
||
|
||
def test_get_next_release_version(): | ||
assert _get_next_release_version(Version("25.0")) == Version("25.1") | ||
assert _get_next_release_version(Version("26.1")) == Version("26.2") | ||
|
||
|
||
def test_get_release_version_strings(monkeypatch): | ||
filenames = [ | ||
"15.0.not_rst", | ||
"22.01.rst", | ||
"22.05.rst", | ||
"23.0.rst", | ||
"23.1.rst", | ||
"23.not_a_release.rst", | ||
"not_a_release.23.rst", | ||
] | ||
monkeypatch.setattr(bootstrap_history, "_get_release_notes_filenames", lambda x: sorted(filenames)) | ||
assert _get_release_version_strings(None) == ["22.01", "22.05", "23.0", "23.1"] | ||
|
||
|
||
@pytest.mark.parametrize("freeze_date, expected_release_date", release_date_test_data) | ||
def test_get_release_date(freeze_date, expected_release_date): | ||
assert get_release_date(freeze_date) == expected_release_date |