Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitd7ee6f8

Browse files
committed
test(packages): add tests for streaming downloads
Tests for the functionality implemented in4f9807f
1 parent63fa05b commitd7ee6f8

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

‎tests/functional/api/test_packages.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
https://docs.gitlab.com/ce/api/packages.html
44
https://docs.gitlab.com/ee/user/packages/generic_packages
55
"""
6+
fromcollections.abcimportIterator
7+
68
fromgitlab.v4.objectsimportGenericPackage
79

810
package_name="hello-world"
@@ -46,6 +48,25 @@ def test_download_generic_package(project):
4648
assertpackage.decode("utf-8")==file_content
4749

4850

51+
deftest_stream_generic_package(project):
52+
bytes_iterator=project.generic_packages.download(
53+
package_name=package_name,
54+
package_version=package_version,
55+
file_name=file_name,
56+
streamed=True,
57+
action="iterator",
58+
)
59+
60+
assertisinstance(bytes_iterator,Iterator)
61+
62+
package=bytes()
63+
forchunkinbytes_iterator:
64+
package+=chunk
65+
66+
assertisinstance(package,bytes)
67+
assertpackage.decode("utf-8")==file_content
68+
69+
4970
deftest_download_generic_package_to_file(tmp_path,project):
5071
path=tmp_path/file_name
5172

@@ -60,3 +81,22 @@ def test_download_generic_package_to_file(tmp_path, project):
6081

6182
withopen(path,"r")asf:
6283
assertf.read()==file_content
84+
85+
86+
deftest_stream_generic_package_to_file(tmp_path,project):
87+
path=tmp_path/file_name
88+
89+
bytes_iterator=project.generic_packages.download(
90+
package_name=package_name,
91+
package_version=package_version,
92+
file_name=file_name,
93+
streamed=True,
94+
action="iterator",
95+
)
96+
97+
withopen(path,"wb")asf:
98+
forchunkinbytes_iterator:
99+
f.write(chunk)
100+
101+
withopen(path,"r")asf:
102+
assertf.read()==file_content

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp