|
1 | 1 | import pytest |
2 | | -from bump_changelog import get_next_version |
| 2 | +from bump_changelog import get_next_version, transform_content |
3 | 3 |
|
4 | 4 |
|
5 | 5 | @pytest.mark.parametrize( |
6 | 6 | "version,expected", [["2.6.1", "2.6.2"], ["2.6.1-dev0", "2.6.2-dev0"]] |
7 | 7 | ) |
8 | 8 | def test_get_next_version(version, expected): |
9 | 9 | assert get_next_version(version) == expected |
| 10 | + |
| 11 | + |
| 12 | +@pytest.mark.parametrize( |
| 13 | + "old_content,expected_error", |
| 14 | + [ |
| 15 | + [ |
| 16 | + """ |
| 17 | +What's New in astroid 2.6.1? |
| 18 | +============================ |
| 19 | +Release Date: TBA |
| 20 | +
|
| 21 | +What's New in astroid 2.6.0? |
| 22 | +============================ |
| 23 | +Release Date: TBA |
| 24 | +""", |
| 25 | + "More than one release date 'TBA'", |
| 26 | + ], |
| 27 | + [ |
| 28 | + """=================== |
| 29 | +astroid's ChangeLog |
| 30 | +=================== |
| 31 | +
|
| 32 | +What's New in astroid 2.6.0? |
| 33 | +============================ |
| 34 | +Release Date: TBA |
| 35 | +""", |
| 36 | + "text for this version '2.6.1' did not exists", |
| 37 | + ], |
| 38 | + [ |
| 39 | + """ |
| 40 | +What's New in astroid 2.6.2? |
| 41 | +============================ |
| 42 | +Release Date: TBA |
| 43 | +
|
| 44 | +What's New in astroid 2.6.1? |
| 45 | +============================ |
| 46 | +Release Date: 2012-02-05 |
| 47 | +""", |
| 48 | + "the next version '2.6.2' already exists", |
| 49 | + ], |
| 50 | + ], |
| 51 | +) |
| 52 | +def test_update_content_error(old_content, expected_error): |
| 53 | + with pytest.raises(AssertionError, match=expected_error): |
| 54 | + transform_content(old_content, "2.6.1", "2.6.2") |
| 55 | + |
| 56 | + |
| 57 | +def test_update_content(): |
| 58 | + old_content = """ |
| 59 | +=================== |
| 60 | +astroid's ChangeLog |
| 61 | +=================== |
| 62 | +
|
| 63 | +What's New in astroid 2.6.1? |
| 64 | +============================ |
| 65 | +Release Date: TBA |
| 66 | +""" |
| 67 | + expected_beginning = """ |
| 68 | +=================== |
| 69 | +astroid's ChangeLog |
| 70 | +=================== |
| 71 | +
|
| 72 | +What's New in astroid 2.6.2? |
| 73 | +============================ |
| 74 | +Release Date: TBA |
| 75 | +
|
| 76 | +
|
| 77 | +
|
| 78 | +What's New in astroid 2.6.1? |
| 79 | +============================ |
| 80 | +Release Date: 20""" |
| 81 | + |
| 82 | + new_content = transform_content(old_content, "2.6.1", "2.6.2") |
| 83 | + assert new_content.startswith(expected_beginning) |
0 commit comments