summaryrefslogtreecommitdiff
path: root/script
diff options
context:
space:
mode:
authorPierre Sassoulas <pierre.sassoulas@gmail.com>2021-06-15 16:47:25 +0200
committerPierre Sassoulas <pierre.sassoulas@gmail.com>2021-06-16 06:57:01 +0200
commit67b6f3ef59effc53e6d3f4c9e0082e882fc5d5c7 (patch)
tree467dffb381eee7729dca6d9fe998482cbcd3907f /script
parent256405dcfd7bc3702a72b1700ce571704596bf23 (diff)
downloadastroid-git-67b6f3ef59effc53e6d3f4c9e0082e882fc5d5c7.tar.gz
Add tests for bump_changelog
Diffstat (limited to 'script')
-rw-r--r--script/test_bump_changelog.py76
1 files changed, 75 insertions, 1 deletions
diff --git a/script/test_bump_changelog.py b/script/test_bump_changelog.py
index 4e70ab16..4b9a23cf 100644
--- a/script/test_bump_changelog.py
+++ b/script/test_bump_changelog.py
@@ -1,5 +1,5 @@
import pytest
-from bump_changelog import get_next_version
+from bump_changelog import get_next_version, transform_content
@pytest.mark.parametrize(
@@ -7,3 +7,77 @@ from bump_changelog import get_next_version
)
def test_get_next_version(version, expected):
assert get_next_version(version) == expected
+
+
+@pytest.mark.parametrize(
+ "old_content,expected_error",
+ [
+ [
+ """
+What's New in astroid 2.6.1?
+============================
+Release Date: TBA
+
+What's New in astroid 2.6.0?
+============================
+Release Date: TBA
+""",
+ "More than one release date 'TBA'",
+ ],
+ [
+ """===================
+astroid's ChangeLog
+===================
+
+What's New in astroid 2.6.0?
+============================
+Release Date: TBA
+""",
+ "text for this version '2.6.1' did not exists",
+ ],
+ [
+ """
+What's New in astroid 2.6.2?
+============================
+Release Date: TBA
+
+What's New in astroid 2.6.1?
+============================
+Release Date: 2012-02-05
+""",
+ "the next version '2.6.2' already exists",
+ ],
+ ],
+)
+def test_update_content_error(old_content, expected_error):
+ with pytest.raises(AssertionError, match=expected_error):
+ transform_content(old_content, "2.6.1", "2.6.2")
+
+
+def test_update_content():
+ old_content = """
+===================
+astroid's ChangeLog
+===================
+
+What's New in astroid 2.6.1?
+============================
+Release Date: TBA
+"""
+ expected_beginning = """
+===================
+astroid's ChangeLog
+===================
+
+What's New in astroid 2.6.2?
+============================
+Release Date: TBA
+
+
+
+What's New in astroid 2.6.1?
+============================
+Release Date: 20"""
+
+ new_content = transform_content(old_content, "2.6.1", "2.6.2")
+ assert new_content.startswith(expected_beginning)