forked from user-cont/release-bot
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest_changelog.py
63 lines (49 loc) · 2.3 KB
/
test_changelog.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# -*- coding: utf-8 -*-
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import pytest
from release_bot.utils import parse_changelog
class TestChangelog:
@pytest.fixture
def empty_changelog(self):
return ""
@pytest.fixture
def changelog_with_one_entry(self):
return "# 0.0.1\n* Test entry\n* Another test entry\n"
@pytest.fixture
def changelog_with_two_entries(self):
return ("# 0.0.2\n* New entry\n* Fixes\n"
"# 0.0.1\n* Test entry\n* Another test entry\n")
@pytest.fixture
def changelog_with_no_changes(self):
return ("# 0.0.2\n"
"# 0.0.1\n* Test entry\n* Another test entry\n")
def test_no_changelog(self):
changelog = parse_changelog("2.0.0", "nochangelogpath")
assert changelog == "No changelog provided"
def test_empty_changelog(self, empty_changelog):
changelog = parse_changelog("2.0.0", empty_changelog)
assert changelog == "No changelog provided"
def test_one_entry_changelog(self, changelog_with_one_entry):
changelog = parse_changelog("0.0.1", changelog_with_one_entry)
assert changelog == "# 0.0.1\n* Test entry\n* Another test entry\n"
def test_wrong_version(self, changelog_with_one_entry):
changelog = parse_changelog("0.0.2", changelog_with_one_entry)
assert changelog == "No changelog provided"
def test_normal_use_case(self, changelog_with_two_entries):
changelog = parse_changelog("0.0.2", changelog_with_two_entries)
assert changelog == "# 0.0.2\n* New entry\n* Fixes"
def test_no_changes(self, changelog_with_no_changes):
changelog = parse_changelog("0.0.2", changelog_with_no_changes)
assert changelog == "# 0.0.2"