6
6
import pytest
7
7
import responses
8
8
9
- from gitlab .v4 .objects import GroupPackage , ProjectPackage
9
+ from gitlab .v4 .objects import GroupPackage , ProjectPackage , ProjectPackageFile
10
10
11
11
12
12
package_content = {
54
54
],
55
55
}
56
56
57
+ package_file_content = [
58
+ {
59
+ "id" : 25 ,
60
+ "package_id" : 1 ,
61
+ "created_at" : "2018-11-07T15:25:52.199Z" ,
62
+ "file_name" : "my-app-1.5-20181107.152550-1.jar" ,
63
+ "size" : 2421 ,
64
+ "file_md5" : "58e6a45a629910c6ff99145a688971ac" ,
65
+ "file_sha1" : "ebd193463d3915d7e22219f52740056dfd26cbfe" ,
66
+ "pipelines" : [
67
+ {
68
+ "id" : 123 ,
69
+ "status" : "pending" ,
70
+ "ref" : "new-pipeline" ,
71
+ "sha" : "a91957a858320c0e17f3a0eca7cfacbff50ea29a" ,
72
+ "web_url" : "https://example.com/foo/bar/pipelines/47" ,
73
+ "created_at" : "2016-08-11T11:28:34.085Z" ,
74
+ "updated_at" : "2016-08-11T11:32:35.169Z" ,
75
+ "user" : {
76
+ "name" : "Administrator" ,
77
+ "avatar_url" : "https://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon" ,
78
+ },
79
+ }
80
+ ],
81
+ },
82
+ {
83
+ "id" : 26 ,
84
+ "package_id" : 1 ,
85
+ "created_at" : "2018-11-07T15:25:56.776Z" ,
86
+ "file_name" : "my-app-1.5-20181107.152550-1.pom" ,
87
+ "size" : 1122 ,
88
+ "file_md5" : "d90f11d851e17c5513586b4a7e98f1b2" ,
89
+ "file_sha1" : "9608d068fe88aff85781811a42f32d97feb440b5" ,
90
+ },
91
+ {
92
+ "id" : 27 ,
93
+ "package_id" : 1 ,
94
+ "created_at" : "2018-11-07T15:26:00.556Z" ,
95
+ "file_name" : "maven-metadata.xml" ,
96
+ "size" : 767 ,
97
+ "file_md5" : "6dfd0cce1203145a927fef5e3a1c650c" ,
98
+ "file_sha1" : "d25932de56052d320a8ac156f745ece73f6a8cd2" ,
99
+ },
100
+ ]
101
+
57
102
58
103
@pytest .fixture
59
104
def resp_list_packages ():
@@ -94,6 +139,21 @@ def resp_delete_package(no_content):
94
139
yield rsps
95
140
96
141
142
+ @pytest .fixture
143
+ def resp_list_package_files ():
144
+ with responses .RequestsMock () as rsps :
145
+ rsps .add (
146
+ method = responses .GET ,
147
+ url = re .compile (
148
+ r"http://localhost/api/v4/projects/1/packages/1/package_files"
149
+ ),
150
+ json = package_file_content ,
151
+ content_type = "application/json" ,
152
+ status = 200 ,
153
+ )
154
+ yield rsps
155
+
156
+
97
157
def test_list_project_packages (project , resp_list_packages ):
98
158
packages = project .packages .list ()
99
159
assert isinstance (packages , list )
@@ -117,3 +177,11 @@ def test_get_project_package(project, resp_get_package):
117
177
def test_delete_project_package (project , resp_delete_package ):
118
178
package = project .packages .get (1 , lazy = True )
119
179
package .delete ()
180
+
181
+
182
+ def test_list_project_packages (project , resp_list_package_files ):
183
+ package = project .packages .get (1 , lazy = True )
184
+ package_files = package .package_files .list ()
185
+ assert isinstance (package_files , list )
186
+ assert isinstance (package_files [0 ], ProjectPackageFile )
187
+ assert package_files [0 ].id == 25
0 commit comments