@@ -54,6 +54,48 @@ def test_download_artifact(gh, session, zip_bytes):
5454 session .register ("GET" , "/repos/foo/bar/actions/runs/123/artifacts" )(
5555 json = {"artifacts" : artifacts }
5656 )
57+ session .register (
58+ "GET" ,
59+ "/repos/foo/bar/actions/runs/123/artifacts" ,
60+ params = {"page" : "2" },
61+ )(json = {})
62+
63+ session .register ("GET" , "/repos/foo/bar/actions/artifacts/789/zip" )(
64+ content = zip_bytes (filename = "foo.txt" , content = "bar" )
65+ )
66+
67+ result = github .download_artifact (
68+ github = gh ,
69+ repository = "foo/bar" ,
70+ artifact_name = "foo" ,
71+ run_id = 123 ,
72+ filename = pathlib .Path ("foo.txt" ),
73+ )
74+
75+ assert result == "bar"
76+
77+
78+ def test_download_artifact_from_page_2 (gh , session , zip_bytes ):
79+ artifacts_page_1 = [
80+ {"name" : "test" , "id" : 000 },
81+ ]
82+ artifacts_page_2 = [
83+ {"name" : "bar" , "id" : 456 },
84+ {"name" : "foo" , "id" : 789 },
85+ ]
86+ session .register ("GET" , "/repos/foo/bar/actions/runs/123/artifacts" )(
87+ json = {"artifacts" : artifacts_page_1 }
88+ )
89+ session .register (
90+ "GET" ,
91+ "/repos/foo/bar/actions/runs/123/artifacts" ,
92+ params = {"page" : "2" },
93+ )(json = {"artifacts" : artifacts_page_2 })
94+ session .register (
95+ "GET" ,
96+ "/repos/foo/bar/actions/runs/123/artifacts" ,
97+ params = {"page" : "3" },
98+ )(json = {})
5799
58100 session .register ("GET" , "/repos/foo/bar/actions/artifacts/789/zip" )(
59101 content = zip_bytes (filename = "foo.txt" , content = "bar" )
@@ -77,6 +119,11 @@ def test_download_artifact__no_artifact(gh, session):
77119 session .register ("GET" , "/repos/foo/bar/actions/runs/123/artifacts" )(
78120 json = {"artifacts" : artifacts }
79121 )
122+ session .register (
123+ "GET" ,
124+ "/repos/foo/bar/actions/runs/123/artifacts" ,
125+ params = {"page" : "2" },
126+ )(json = {})
80127
81128 with pytest .raises (github .NoArtifact ):
82129 github .download_artifact (
@@ -95,6 +142,11 @@ def test_download_artifact__no_file(gh, session, zip_bytes):
95142 session .register ("GET" , "/repos/foo/bar/actions/runs/123/artifacts" )(
96143 json = {"artifacts" : artifacts }
97144 )
145+ session .register (
146+ "GET" ,
147+ "/repos/foo/bar/actions/runs/123/artifacts" ,
148+ params = {"page" : "2" },
149+ )(json = {})
98150
99151 session .register ("GET" , "/repos/foo/bar/actions/artifacts/789/zip" )(
100152 content = zip_bytes (filename = "foo.txt" , content = "bar" )
0 commit comments