Skip to content

Commit ddee6b2

Browse files
committed
refactored
1 parent 64bd7f3 commit ddee6b2

File tree

2 files changed

+29
-23
lines changed

2 files changed

+29
-23
lines changed

services/web/server/tests/unit/with_dbs/01/storage/conftest.py

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
from pathlib import Path
1010
from threading import Thread
1111
from typing import Annotated, Any
12+
from urllib.parse import quote
1213

1314
import pytest
1415
import uvicorn
@@ -190,23 +191,31 @@ async def upload_file(
190191
abort_url = (
191192
URL(f"{request.url}")
192193
.with_path(
193-
request.app.url_path_for(
194-
"abort_upload_file",
195-
location_id=f"{location_id}",
196-
file_id=file_id,
197-
)
194+
quote(
195+
request.app.url_path_for(
196+
"abort_upload_file",
197+
location_id=f"{location_id}",
198+
file_id=file_id,
199+
),
200+
safe=":/",
201+
),
202+
encoded=True,
198203
)
199204
.with_query(user_id=user_id)
200205
)
201206

202207
complete_url = (
203208
URL(f"{request.url}")
204209
.with_path(
205-
request.app.url_path_for(
206-
"complete_upload_file",
207-
location_id=f"{location_id}",
208-
file_id=file_id,
209-
)
210+
quote(
211+
request.app.url_path_for(
212+
"complete_upload_file",
213+
location_id=f"{location_id}",
214+
file_id=file_id,
215+
),
216+
safe=":/",
217+
),
218+
encoded=True,
210219
)
211220
.with_query(user_id=user_id)
212221
)

services/web/server/tests/unit/with_dbs/01/storage/test_storage.py

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ async def test_list_storage_locations(
5252
url = "/v0/storage/locations"
5353
assert url.startswith(PREFIX)
5454

55-
resp = await client.get(url, params={"user_id": logged_user["id"]})
55+
resp = await client.get(url)
5656
data, error = await assert_status(resp, expected)
5757

5858
if not error:
@@ -80,7 +80,7 @@ async def test_list_storage_paths(
8080
assert client.app
8181
url = client.app.router["list_storage_paths"].url_for(location_id=f"{location_id}")
8282

83-
resp = await client.get(f"{url}", params={"user_id": logged_user["id"]})
83+
resp = await client.get(f"{url}")
8484
data, error = await assert_status(resp, expected)
8585
if not error:
8686
TypeAdapter(CursorPage[PathMetaDataGet]).validate_python(data)
@@ -125,7 +125,7 @@ async def test_compute_path_size(
125125
path=quote(faker.file_path(absolute=False), safe=""),
126126
)
127127

128-
resp = await client.post(f"{url}", params={"user_id": logged_user["id"]})
128+
resp = await client.post(f"{url}")
129129
data, error = await assert_status(resp, expected)
130130
if not error:
131131
TypeAdapter(StorageAsyncJobGet).validate_python(data)
@@ -152,7 +152,7 @@ async def test_list_datasets_metadata(
152152

153153
assert url == str(_url)
154154

155-
resp = await client.get(url, params={"user_id": logged_user["id"]})
155+
resp = await client.get(url)
156156
data, error = await assert_status(resp, expected)
157157

158158
if not error:
@@ -185,7 +185,7 @@ async def test_list_dataset_files_metadata(
185185

186186
assert url == str(_url)
187187

188-
resp = await client.get(url, params={"user_id": logged_user["id"]})
188+
resp = await client.get(url)
189189
data, error = await assert_status(resp, expected)
190190

191191
if not error:
@@ -220,7 +220,7 @@ async def test_storage_file_meta(
220220

221221
assert url.startswith(PREFIX)
222222

223-
resp = await client.get(url, params={"user_id": logged_user["id"]})
223+
resp = await client.get(url)
224224
data, error = await assert_status(resp, expected)
225225

226226
if not error:
@@ -251,7 +251,7 @@ async def test_storage_list_filter(
251251

252252
assert url.startswith(PREFIX)
253253

254-
resp = await client.get(url, params={"user_id": logged_user["id"]})
254+
resp = await client.get(url)
255255
data, error = await assert_status(resp, expected)
256256

257257
if not error:
@@ -264,7 +264,7 @@ async def test_storage_list_filter(
264264
@pytest.fixture
265265
def file_id(faker: Faker) -> StorageFileID:
266266
return TypeAdapter(StorageFileID).validate_python(
267-
f"{faker.uuid4()}/{faker.uuid4()}/{faker.file_name()} with spaces.dat"
267+
f"{faker.uuid4()}/{faker.uuid4()}/{faker.file_name()} with spaces().dat"
268268
)
269269

270270

@@ -287,18 +287,15 @@ async def test_upload_file(
287287

288288
assert url.startswith(PREFIX)
289289

290-
resp = await client.put(url, params={"user_id": logged_user["id"]})
290+
resp = await client.put(url)
291291
data, error = await assert_status(resp, expected)
292292
if not error:
293293
assert not error
294294
assert data
295295
file_upload_schema = FileUploadSchema.model_validate(data)
296296

297297
# let's abort
298-
resp = await client.post(
299-
f"{file_upload_schema.links.abort_upload.path}",
300-
params={"user_id": logged_user["id"]},
301-
)
298+
resp = await client.post(f"{file_upload_schema.links.abort_upload.path}")
302299
data, error = await assert_status(resp, status.HTTP_204_NO_CONTENT)
303300
assert not error
304301
assert not data

0 commit comments

Comments
 (0)