@@ -15,14 +15,6 @@ def extract_releases(mocker, release_dict):
15
15
)
16
16
17
17
18
- @pytest .fixture
19
- def options ():
20
- def _ (kwargs ):
21
- return {"changelog-url" : None , "github" : None , "pypi" : None , ** kwargs }
22
-
23
- return _
24
-
25
-
26
18
def node_to_string (node ):
27
19
if isinstance (node , list ):
28
20
return canonicalize (
@@ -49,16 +41,16 @@ def canonicalize(value):
49
41
)
50
42
51
43
52
- def test_compute_changelog_no_token (options ):
53
- nodes = changelog .compute_changelog (token = None , options = options ({}) )
44
+ def test_compute_changelog_no_token ():
45
+ nodes = changelog .compute_changelog (token = None , options = {} )
54
46
assert len (nodes ) == 1
55
47
56
48
assert "Changelog was not built" in node_to_string (nodes [0 ])
57
49
58
50
59
- def test_compute_changelog_token (options , extract_releases ):
51
+ def test_compute_changelog_token (extract_releases ):
60
52
nodes = changelog .compute_changelog (
61
- token = "token" , options = options ( {"github" : "https://github.com/a/b/releases" })
53
+ token = "token" , options = {"github" : "https://github.com/a/b/releases" }
62
54
)
63
55
assert "1.0.0: A new hope" in node_to_string (nodes [0 ])
64
56
@@ -156,6 +148,13 @@ def test_node_for_release_title_tag(release_dict):
156
148
)
157
149
158
150
151
+ def test_node_for_release_none_title (release_dict ):
152
+ release_dict ["name" ] = None
153
+ assert "<title>1.0.0</title>" in node_to_string (
154
+ changelog .node_for_release (release = release_dict , pypi_name = None )
155
+ )
156
+
157
+
159
158
def test_node_for_release_title_pypy (release_dict ):
160
159
value = node_to_string (
161
160
changelog .node_for_release (release = release_dict , pypi_name = "foo" )
@@ -239,3 +238,16 @@ def test_github_call_http_error_connection(requests_mock):
239
238
changelog .github_call (url = url , token = "token" , query = "" )
240
239
241
240
assert str (exc_info .value ) == "Could not retrieve changelog from github: bar"
241
+
242
+
243
+ @pytest .mark .parametrize (
244
+ "title, tag, expected" ,
245
+ [
246
+ ("Foo" , "1.0.0" , "1.0.0: Foo" ),
247
+ ("1.0.0: Foo" , "1.0.0" , "1.0.0: Foo" ),
248
+ ("Fix 1.0.0" , "1.0.1" , "1.0.1: Fix 1.0.0" ),
249
+ (None , "1.0.0" , "1.0.0" ),
250
+ ],
251
+ )
252
+ def test_get_release_title (title , tag , expected ):
253
+ assert changelog .get_release_title (title = title , tag = tag ) == expected
0 commit comments