forked from Colin-b/keepachangelog
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_changelog_unreleased.py
254 lines (220 loc) · 6.5 KB
/
test_changelog_unreleased.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
import os
import os.path
import pytest
import keepachangelog
@pytest.fixture
def changelog(tmpdir):
changelog_file_path = os.path.join(tmpdir, "CHANGELOG.md")
with open(changelog_file_path, "wt") as file:
file.write(
"""# Changelog
All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [Unreleased]
- Release note 0.
### Changed
- Release note 1.
* Release note 2.
### Added
- Enhancement 1
- sub enhancement 1
* sub enhancement 2
- Enhancement 2
### Fixed
- Bug fix 1
- sub bug 1
* sub bug 2
- Bug fix 2
### Security
* Known issue 1
- Known issue 2
### Deprecated
- Deprecated feature 1
* Future removal 2
### Removed
- Deprecated feature 2
* Future removal 1
## [1.1.0] - 2018-05-31
### Changed
- Enhancement 1 (1.1.0)
- sub *enhancement 1*
- sub enhancement 2
- Enhancement 2 (1.1.0)
## [1.0.1] - 2018-05-31
### Fixed
- Bug fix 1 (1.0.1)
- sub bug 1
- sub bug 2
- Bug fix 2 (1.0.1)
## [1.0.0] - 2017-04-10
### Deprecated
- Known issue 1 (1.0.0)
- Known issue 2 (1.0.0)
## [0.0.1] - 2017-01-01
### Added
- First release
[Unreleased]: https://github.test_url/test_project/compare/v1.1.0...HEAD
[1.1.0]: https://github.test_url/test_project/compare/v1.0.2...v1.1.0
[1.0.2]: https://github.test_url/test_project/compare/v1.0.1...v1.0.2
[1.0.1]: https://github.test_url/test_project/compare/v1.0.0...v1.0.1
[1.0.0]: https://github.test_url/test_project/releases/tag/v1.0.0
"""
)
return changelog_file_path
def test_changelog_with_versions_and_all_categories(changelog):
assert keepachangelog.to_dict(changelog, show_unreleased=True) == {
"unreleased": {
"changed": ["Release note 1.", "Release note 2."],
"added": [
"Enhancement 1",
"sub enhancement 1",
"sub enhancement 2",
"Enhancement 2",
],
"fixed": ["Bug fix 1", "sub bug 1", "sub bug 2", "Bug fix 2"],
"security": ["Known issue 1", "Known issue 2"],
"uncategorized": ["Release note 0."],
"deprecated": ["Deprecated feature 1", "Future removal 2"],
"removed": ["Deprecated feature 2", "Future removal 1"],
"metadata": {
"version": "unreleased",
"release_date": None,
"url": "https://github.test_url/test_project/compare/v1.1.0...HEAD",
},
},
"1.1.0": {
"changed": [
"Enhancement 1 (1.1.0)",
"sub *enhancement 1*",
"sub enhancement 2",
"Enhancement 2 (1.1.0)",
],
"metadata": {
"version": "1.1.0",
"semantic_version": {
"buildmetadata": None,
"major": 1,
"minor": 1,
"patch": 0,
"prerelease": None,
},
"release_date": "2018-05-31",
"url": "https://github.test_url/test_project/compare/v1.0.2...v1.1.0",
},
},
"1.0.2": {
"metadata": {
"url": "https://github.test_url/test_project/compare/v1.0.1...v1.0.2",
"version": "1.0.2",
},
},
"1.0.1": {
"fixed": [
"Bug fix 1 (1.0.1)",
"sub bug 1",
"sub bug 2",
"Bug fix 2 (1.0.1)",
],
"metadata": {
"version": "1.0.1",
"semantic_version": {
"buildmetadata": None,
"major": 1,
"minor": 0,
"patch": 1,
"prerelease": None,
},
"release_date": "2018-05-31",
"url": "https://github.test_url/test_project/compare/v1.0.0...v1.0.1",
},
},
"1.0.0": {
"deprecated": ["Known issue 1 (1.0.0)", "Known issue 2 (1.0.0)"],
"metadata": {
"version": "1.0.0",
"semantic_version": {
"buildmetadata": None,
"major": 1,
"minor": 0,
"patch": 0,
"prerelease": None,
},
"release_date": "2017-04-10",
"url": "https://github.test_url/test_project/releases/tag/v1.0.0",
},
},
"0.0.1": {
"added": ["First release"],
"metadata": {
"release_date": "2017-01-01",
"semantic_version": {
"buildmetadata": None,
"major": 0,
"minor": 0,
"patch": 1,
"prerelease": None,
},
"version": "0.0.1",
},
},
}
def test_changelog_from_dict(changelog):
releases = keepachangelog.to_dict(changelog, show_unreleased=True)
assert (
keepachangelog.from_dict(releases)
== """# Changelog
All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [Unreleased]
* Release note 0.
### Changed
- Release note 1.
- Release note 2.
### Added
- Enhancement 1
- sub enhancement 1
- sub enhancement 2
- Enhancement 2
### Fixed
- Bug fix 1
- sub bug 1
- sub bug 2
- Bug fix 2
### Security
- Known issue 1
- Known issue 2
### Deprecated
- Deprecated feature 1
- Future removal 2
### Removed
- Deprecated feature 2
- Future removal 1
## [1.1.0] - 2018-05-31
### Changed
- Enhancement 1 (1.1.0)
- sub *enhancement 1*
- sub enhancement 2
- Enhancement 2 (1.1.0)
## [1.0.1] - 2018-05-31
### Fixed
- Bug fix 1 (1.0.1)
- sub bug 1
- sub bug 2
- Bug fix 2 (1.0.1)
## [1.0.0] - 2017-04-10
### Deprecated
- Known issue 1 (1.0.0)
- Known issue 2 (1.0.0)
## [0.0.1] - 2017-01-01
### Added
- First release
## [1.0.2]
[Unreleased]: https://github.test_url/test_project/compare/v1.1.0...HEAD
[1.1.0]: https://github.test_url/test_project/compare/v1.0.2...v1.1.0
[1.0.1]: https://github.test_url/test_project/compare/v1.0.0...v1.0.1
[1.0.0]: https://github.test_url/test_project/releases/tag/v1.0.0
[1.0.2]: https://github.test_url/test_project/compare/v1.0.1...v1.0.2
"""
)