<commit_before>import pytest
from bump_changelog import get_next_patch_version, transform_content


@pytest.mark.parametrize(
    "version,expected", [["2.6.1", "2.6.2"], ["2.6.1-dev0", "2.6.2-dev0"]]
)
def test_get_next_version(version, expected):
    assert get_next_patch_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")


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")
    assert new_content.startswith(expected_beginning)<commit_msg>Permit to test the version in script/test_bump_changelog.py<commit_after>import pytest
from bump_changelog import get_next_patch_version, transform_content


@pytest.mark.parametrize(
    "version,expected", [["2.6.1", "2.6.2"], ["2.6.1-dev0", "2.6.2-dev0"]]
)
def test_get_next_version(version, expected):
    assert get_next_patch_version(version) == expected


@pytest.mark.parametrize(
    "old_content,version,expected_error",
    [
        [
            """
What's New in astroid 2.7.0?
============================
Release Date: TBA

What's New in astroid 2.6.1?
============================
Release Date: TBA

What's New in astroid 2.6.0?
============================
Release Date: TBA
""",
            "2.6.1",
            "More than one release date 'TBA'",
        ],
        [
            """===================
astroid's ChangeLog
===================

What's New in astroid 2.6.0?
============================
Release Date: TBA
""",
            "2.6.1",
            "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
""",
            "2.6.1",
            "the next version '2.6.2' already exists",
        ],
    ],
)
def test_update_content_error(old_content, version, expected_error):
    with pytest.raises(AssertionError, match=expected_error):
        transform_content(old_content, version)


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")
    assert new_content.startswith(expected_beginning)
{'fraction_non_alphanumeric': 0.2871768620424878, 'fraction_numerical': 0.033017660609163044, 'mean_word_length': 3.646848989298454, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7123890', 'n_tokens_mistral': 1272, 'n_tokens_neox': 1200, 'n_words': 273}