@@ -16,6 +16,9 @@ def mocked_paginated(requests_mock):
16
16
json = [{"id" : 3 , "title" : "Item 3" }, {"id" : 4 , "title" : "Item 4" }],
17
17
headers = {"link" : '<https://api.github.com/paginated>; rel="prev"' },
18
18
)
19
+ requests_mock .get (
20
+ "https://api.github.com/single" , json = {"id" : 1 , "title" : "Item 1" }
21
+ )
19
22
20
23
21
24
@pytest .mark .parametrize ("url" , ["https://api.github.com/paginated" , "/paginated" ])
@@ -41,6 +44,37 @@ def test_get(mocked_paginated, url):
41
44
assert result .output .strip () == expected
42
45
43
46
47
+ @pytest .mark .parametrize (
48
+ "nl,expected" ,
49
+ [
50
+ (True , '{"id": 1, "title": "Item 1"}' ),
51
+ (
52
+ False ,
53
+ textwrap .dedent (
54
+ """
55
+ {
56
+ "id": 1,
57
+ "title": "Item 1"
58
+ }
59
+ """
60
+ ),
61
+ ),
62
+ ],
63
+ )
64
+ @pytest .mark .parametrize ("paginate" , [True , False ])
65
+ def test_get_single (mocked_paginated , nl , expected , paginate ):
66
+ runner = CliRunner ()
67
+ with runner .isolated_filesystem ():
68
+ args = ["get" , "/single" ]
69
+ if nl :
70
+ args .append ("--nl" )
71
+ if paginate :
72
+ args .append ("--paginate" )
73
+ result = runner .invoke (cli .cli , args )
74
+ assert 0 == result .exit_code
75
+ assert result .output .strip () == expected .strip ()
76
+
77
+
44
78
@pytest .mark .parametrize (
45
79
"nl,expected" ,
46
80
(
0 commit comments