Skip to content

Commit ec45fde

Browse files
committed
Test file uploads
The upload branch of _generic_request_generator was not covered.
1 parent a112272 commit ec45fde

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

tests/test_spacetrack.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,16 @@ def test_generic_request(httpx2_mock, client, mock_auth, mock_gp_predicates):
153153
assert "".join(result) == "abcdef"
154154

155155

156+
def test_upload(client, httpx2_mock, mock_auth):
157+
url = api_url("fileshare/query/class/upload/folder_id/123")
158+
httpx2_mock.add_response(method="POST", url=url, json="ok")
159+
160+
assert client.upload(folder_id=123, file=io.BytesIO(b"file contents")) == "ok"
161+
162+
request = httpx2_mock.get_request(method="POST", url=url)
163+
assert b"file contents" in request.content
164+
165+
156166
def test_predicate_error(client, mock_auth, mock_predicates_empty):
157167
with pytest.raises(TypeError, match=r"unexpected argument 'banana'"):
158168
client.gp(banana=4)

0 commit comments

Comments
 (0)