Skip to content

Commit cb7bdd5

Browse files
committed
Add tests
1 parent 470f9cb commit cb7bdd5

File tree

1 file changed

+85
-1
lines changed

1 file changed

+85
-1
lines changed

tests/test_run_release.py

Lines changed: 85 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ def test_check_doc_unreleased_version_no_file_alpha(tmp_path: Path) -> None:
8888
run_release.check_doc_unreleased_version(cast(ReleaseShelf, db))
8989

9090

91-
def test_check_doc_unreleased_version_ok(monkeypatch, tmp_path: Path) -> None:
91+
def test_check_doc_unreleased_version_ok(tmp_path: Path) -> None:
9292
prepare_fake_docs(
9393
tmp_path,
9494
"<div>New in 3.13</div>",
@@ -124,3 +124,87 @@ def test_check_doc_unreleased_version_waived(monkeypatch, tmp_path: Path) -> Non
124124
}
125125
with fake_answers(monkeypatch, ["yes"]):
126126
run_release.check_doc_unreleased_version(cast(ReleaseShelf, db))
127+
128+
129+
@pytest.mark.parametrize(
130+
["tag", "expected"],
131+
[
132+
("3.14.0a7", "Have you already added the release to "),
133+
("3.13.3", "Have you already removed the release from "),
134+
],
135+
)
136+
def test_modify_the_prerelease_page_yes(
137+
capsys, monkeypatch, tag: str, expected: str
138+
) -> None:
139+
# Arrange
140+
db = {"release": Tag(tag)}
141+
142+
# Act
143+
with fake_answers(monkeypatch, ["yes"]):
144+
run_release.modify_the_prereleases_page(cast(ReleaseShelf, db))
145+
146+
# Assert
147+
assert expected in capsys.readouterr().out
148+
149+
150+
@pytest.mark.parametrize(
151+
["tag", "expected"],
152+
[
153+
("3.14.0a7", "The release has not been added to the pre-releases page"),
154+
("3.13.3", "The release has not been removed from the pre-releases page"),
155+
],
156+
)
157+
def test_modify_the_prerelease_page_no(monkeypatch, tag: str, expected: str) -> None:
158+
# Arrange
159+
db = {"release": Tag(tag)}
160+
161+
# Act
162+
with (
163+
fake_answers(monkeypatch, ["no"]),
164+
pytest.raises(run_release.ReleaseException, match=expected),
165+
):
166+
run_release.modify_the_prereleases_page(cast(ReleaseShelf, db))
167+
168+
169+
def test_modify_the_docs_by_version_page_prerelease(capsys) -> None:
170+
# Arrange
171+
db = {"release": Tag("3.14.0a7")}
172+
173+
# Act
174+
run_release.modify_the_docs_by_version_page(cast(ReleaseShelf, db))
175+
176+
# Assert
177+
assert capsys.readouterr().out == ""
178+
179+
180+
def test_modify_the_docs_by_version_page_final_no(capsys, monkeypatch) -> None:
181+
# Arrange
182+
db = {"release": Tag("3.13.3")}
183+
184+
# Act
185+
with (
186+
fake_answers(monkeypatch, ["no"]),
187+
pytest.raises(run_release.ReleaseException),
188+
):
189+
run_release.modify_the_docs_by_version_page(cast(ReleaseShelf, db))
190+
191+
# Assert
192+
assert (
193+
"* `Python 3.13.3 <https://docs.python.org/release/3.13.3/>`_, documentation released on"
194+
in capsys.readouterr().out
195+
)
196+
197+
198+
def test_modify_the_docs_by_version_page_final_yes(capsys, monkeypatch) -> None:
199+
# Arrange
200+
db = {"release": Tag("3.13.3")}
201+
202+
# Act
203+
with fake_answers(monkeypatch, ["yes"]):
204+
run_release.modify_the_docs_by_version_page(cast(ReleaseShelf, db))
205+
206+
# Assert
207+
assert (
208+
"* `Python 3.13.3 <https://docs.python.org/release/3.13.3/>`_, documentation released on"
209+
in capsys.readouterr().out
210+
)

0 commit comments

Comments
 (0)