Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test version handling functions #36

Merged
merged 1 commit into from
Nov 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 73 additions & 0 deletions tests/test_blurb.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,63 @@ def test_unsanitize_section_changed(section, expected):
assert unsanitized == expected


@pytest.mark.parametrize(
"version1, version2",
(
("2", "3"),
("3.5.0a1", "3.5.0b1"),
("3.5.0a1", "3.5.0rc1"),
("3.5.0a1", "3.5.0"),
("3.6.0b1", "3.6.0b2"),
("3.6.0b1", "3.6.0rc1"),
("3.6.0b1", "3.6.0"),
("3.7.0rc1", "3.7.0rc2"),
("3.7.0rc1", "3.7.0"),
("3.8", "3.8.1"),
),
)
def test_version_key(version1, version2):
# Act
key1 = blurb.version_key(version1)
key2 = blurb.version_key(version2)

# Assert
assert key1 < key2


def test_glob_versions(fs):
# Arrange
fake_version_blurbs = (
"Misc/NEWS.d/3.7.0.rst",
"Misc/NEWS.d/3.7.0a1.rst",
"Misc/NEWS.d/3.7.0a2.rst",
"Misc/NEWS.d/3.7.0b1.rst",
"Misc/NEWS.d/3.7.0b2.rst",
"Misc/NEWS.d/3.7.0rc1.rst",
"Misc/NEWS.d/3.7.0rc2.rst",
"Misc/NEWS.d/3.9.0b1.rst",
"Misc/NEWS.d/3.12.0a1.rst",
)
for fn in fake_version_blurbs:
fs.create_file(fn)

# Act
versions = blurb.glob_versions()

# Assert
assert versions == [
"3.12.0a1",
"3.9.0b1",
"3.7.0",
"3.7.0rc2",
"3.7.0rc1",
"3.7.0b2",
"3.7.0b1",
"3.7.0a2",
"3.7.0a1",
]


def test_glob_blurbs_next(fs):
# Arrange
fake_news_entries = (
Expand Down Expand Up @@ -104,6 +161,22 @@ def test_glob_blurbs_sort_order(fs):
assert filenames == expected


@pytest.mark.parametrize(
"version, expected",
(
("next", "next"),
("3.12.0a1", "3.12.0 alpha 1"),
("3.12.0b2", "3.12.0 beta 2"),
("3.12.0rc2", "3.12.0 release candidate 2"),
("3.12.0", "3.12.0 final"),
("3.12.1", "3.12.1 final"),
),
)
def test_printable_version(version, expected):
# Act / Assert
assert blurb.printable_version(version) == expected


@pytest.mark.parametrize(
"news_entry, expected_section",
(
Expand Down