Skip to content

Commit d561894

Browse files
committed
unit test changes
1 parent 475b1d2 commit d561894

File tree

4 files changed

+38
-34
lines changed

4 files changed

+38
-34
lines changed

tests/sdk/test_async_clients.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ async def test_list(self, mock_async_client: AsyncMock, object_view: MockObjectV
237237
name="test",
238238
search="query",
239239
starting_after="obj_000",
240-
state="ready",
240+
state="READ_ONLY",
241241
)
242242

243243
assert len(objects) == 1
@@ -282,14 +282,15 @@ async def test_upload_from_text(self, mock_async_client: AsyncMock, object_view:
282282
mock_async_client._client = http_client
283283

284284
client = AsyncStorageObjectOps(mock_async_client)
285-
obj = await client.upload_from_text("test content", "test.txt", metadata={"key": "value"})
285+
obj = await client.upload_from_text("test content", name="test.txt", metadata={"key": "value"})
286286

287287
assert isinstance(obj, AsyncStorageObject)
288288
assert obj.id == "obj_123"
289289
mock_async_client.objects.create.assert_awaited_once_with(
290290
name="test.txt",
291291
content_type="text",
292292
metadata={"key": "value"},
293+
ttl_ms=None,
293294
)
294295
http_client.put.assert_awaited_once_with(object_view.upload_url, content="test content")
295296
mock_async_client.objects.complete.assert_awaited_once()
@@ -306,14 +307,15 @@ async def test_upload_from_bytes(self, mock_async_client: AsyncMock, object_view
306307
mock_async_client._client = http_client
307308

308309
client = AsyncStorageObjectOps(mock_async_client)
309-
obj = await client.upload_from_bytes(b"test content", "test.bin", content_type="binary")
310+
obj = await client.upload_from_bytes(b"test content", name="test.bin", content_type="binary")
310311

311312
assert isinstance(obj, AsyncStorageObject)
312313
assert obj.id == "obj_123"
313314
mock_async_client.objects.create.assert_awaited_once_with(
314315
name="test.bin",
315316
content_type="binary",
316317
metadata=None,
318+
ttl_ms=None,
317319
)
318320
http_client.put.assert_awaited_once_with(object_view.upload_url, content=b"test content")
319321
mock_async_client.objects.complete.assert_awaited_once()

tests/sdk/test_clients.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ def test_list(self, mock_client: Mock, object_view: MockObjectView) -> None:
225225
name="test",
226226
search="query",
227227
starting_after="obj_000",
228-
state="ready",
228+
state="READ_ONLY",
229229
)
230230

231231
assert len(objects) == 1
@@ -264,14 +264,15 @@ def test_upload_from_text(self, mock_client: Mock, object_view: MockObjectView)
264264
mock_client._client = http_client
265265

266266
client = StorageObjectOps(mock_client)
267-
obj = client.upload_from_text("test content", "test.txt", metadata={"key": "value"})
267+
obj = client.upload_from_text("test content", name="test.txt", metadata={"key": "value"})
268268

269269
assert isinstance(obj, StorageObject)
270270
assert obj.id == "obj_123"
271271
mock_client.objects.create.assert_called_once_with(
272272
name="test.txt",
273273
content_type="text",
274274
metadata={"key": "value"},
275+
ttl_ms=None,
275276
)
276277
http_client.put.assert_called_once_with(object_view.upload_url, content="test content")
277278
mock_client.objects.complete.assert_called_once()
@@ -286,14 +287,15 @@ def test_upload_from_bytes(self, mock_client: Mock, object_view: MockObjectView)
286287
mock_client._client = http_client
287288

288289
client = StorageObjectOps(mock_client)
289-
obj = client.upload_from_bytes(b"test content", "test.bin", content_type="binary")
290+
obj = client.upload_from_bytes(b"test content", name="test.bin", content_type="binary")
290291

291292
assert isinstance(obj, StorageObject)
292293
assert obj.id == "obj_123"
293294
mock_client.objects.create.assert_called_once_with(
294295
name="test.bin",
295296
content_type="binary",
296297
metadata=None,
298+
ttl_ms=None,
297299
)
298300
http_client.put.assert_called_once_with(object_view.upload_url, content=b"test content")
299301
mock_client.objects.complete.assert_called_once()

tests/smoketests/sdk/test_async_storage_object.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ async def test_upload_from_text(self, async_sdk_client: AsyncRunloopSDK) -> None
9898
text_content = "Hello from async upload_from_text!"
9999
obj = await async_sdk_client.storage_object.upload_from_text(
100100
text_content,
101-
unique_name("sdk-async-text-upload"),
101+
name=unique_name("sdk-async-text-upload"),
102102
metadata={"source": "upload_from_text"},
103103
)
104104

@@ -117,7 +117,7 @@ async def test_upload_from_bytes(self, async_sdk_client: AsyncRunloopSDK) -> Non
117117
bytes_content = b"Binary content from async SDK"
118118
obj = await async_sdk_client.storage_object.upload_from_bytes(
119119
bytes_content,
120-
unique_name("sdk-async-bytes-upload"),
120+
name=unique_name("sdk-async-bytes-upload"),
121121
content_type="text",
122122
metadata={"source": "upload_from_bytes"},
123123
)
@@ -142,7 +142,7 @@ async def test_upload_from_file(self, async_sdk_client: AsyncRunloopSDK) -> None
142142
try:
143143
obj = await async_sdk_client.storage_object.upload_from_file(
144144
tmp_path,
145-
unique_name("sdk-async-file-upload"),
145+
name=unique_name("sdk-async-file-upload"),
146146
metadata={"source": "upload_from_file"},
147147
)
148148

@@ -171,7 +171,7 @@ async def test_upload_from_dir(self, async_sdk_client: AsyncRunloopSDK) -> None:
171171

172172
obj = await async_sdk_client.storage_object.upload_from_dir(
173173
tmp_path,
174-
unique_name("sdk-async-dir-upload"),
174+
name=unique_name("sdk-async-dir-upload"),
175175
metadata={"source": "upload_from_dir"},
176176
)
177177

@@ -206,7 +206,7 @@ async def test_download_as_text(self, async_sdk_client: AsyncRunloopSDK) -> None
206206
content = "Async text content to download"
207207
obj = await async_sdk_client.storage_object.upload_from_text(
208208
content,
209-
unique_name("sdk-async-download-text"),
209+
name=unique_name("sdk-async-download-text"),
210210
)
211211

212212
try:
@@ -221,7 +221,7 @@ async def test_download_as_bytes(self, async_sdk_client: AsyncRunloopSDK) -> Non
221221
content = b"Async bytes content to download"
222222
obj = await async_sdk_client.storage_object.upload_from_bytes(
223223
content,
224-
unique_name("sdk-async-download-bytes"),
224+
name=unique_name("sdk-async-download-bytes"),
225225
content_type="text",
226226
)
227227

@@ -237,7 +237,7 @@ async def test_get_download_url(self, async_sdk_client: AsyncRunloopSDK) -> None
237237
"""Test getting download URL."""
238238
obj = await async_sdk_client.storage_object.upload_from_text(
239239
"Content for async URL",
240-
unique_name("sdk-async-download-url"),
240+
name=unique_name("sdk-async-download-url"),
241241
)
242242

243243
try:
@@ -266,7 +266,7 @@ async def test_get_storage_object_by_id(self, async_sdk_client: AsyncRunloopSDK)
266266
# Create an object
267267
created = await async_sdk_client.storage_object.upload_from_text(
268268
"Content for async retrieval",
269-
unique_name("sdk-async-storage-retrieve"),
269+
name=unique_name("sdk-async-storage-retrieve"),
270270
)
271271

272272
try:
@@ -286,7 +286,7 @@ async def test_list_storage_objects_by_content_type(self, async_sdk_client: Asyn
286286
# Create object with specific content type
287287
obj = await async_sdk_client.storage_object.upload_from_text(
288288
"Text content",
289-
unique_name("sdk-async-storage-list-type"),
289+
name=unique_name("sdk-async-storage-list-type"),
290290
)
291291

292292
try:
@@ -310,7 +310,7 @@ async def test_mount_storage_object_to_devbox(self, async_sdk_client: AsyncRunlo
310310
# Create storage object with content
311311
obj = await async_sdk_client.storage_object.upload_from_text(
312312
"Async mounted content from SDK",
313-
unique_name("sdk-async-mount-object"),
313+
name=unique_name("sdk-async-mount-object"),
314314
)
315315

316316
try:
@@ -342,7 +342,7 @@ async def test_access_mounted_storage_object(self, async_sdk_client: AsyncRunloo
342342
# Create storage object
343343
obj = await async_sdk_client.storage_object.upload_from_text(
344344
"Async content to mount and access",
345-
unique_name("sdk-async-mount-access"),
345+
name=unique_name("sdk-async-mount-access"),
346346
)
347347

348348
try:
@@ -385,7 +385,7 @@ async def test_storage_object_large_content(self, async_sdk_client: AsyncRunloop
385385

386386
obj = await async_sdk_client.storage_object.upload_from_text(
387387
large_content,
388-
unique_name("sdk-async-storage-large"),
388+
name=unique_name("sdk-async-storage-large"),
389389
)
390390

391391
try:
@@ -404,7 +404,7 @@ async def test_storage_object_binary_content(self, async_sdk_client: AsyncRunloo
404404

405405
obj = await async_sdk_client.storage_object.upload_from_bytes(
406406
binary_content,
407-
unique_name("sdk-async-storage-binary"),
407+
name=unique_name("sdk-async-storage-binary"),
408408
content_type="binary",
409409
)
410410

@@ -420,7 +420,7 @@ async def test_storage_object_empty_content(self, async_sdk_client: AsyncRunloop
420420
"""Test uploading empty content."""
421421
obj = await async_sdk_client.storage_object.upload_from_text(
422422
"",
423-
unique_name("sdk-async-storage-empty"),
423+
name=unique_name("sdk-async-storage-empty"),
424424
)
425425

426426
try:

tests/smoketests/sdk/test_storage_object.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ def test_upload_from_text(self, sdk_client: RunloopSDK) -> None:
9898
text_content = "Hello from upload_from_text!"
9999
obj = sdk_client.storage_object.upload_from_text(
100100
text_content,
101-
unique_name("sdk-text-upload"),
101+
name=unique_name("sdk-text-upload"),
102102
metadata={"source": "upload_from_text"},
103103
)
104104

@@ -117,7 +117,7 @@ def test_upload_from_bytes(self, sdk_client: RunloopSDK) -> None:
117117
bytes_content = b"Binary content from SDK"
118118
obj = sdk_client.storage_object.upload_from_bytes(
119119
bytes_content,
120-
unique_name("sdk-bytes-upload"),
120+
name=unique_name("sdk-bytes-upload"),
121121
content_type="text",
122122
metadata={"source": "upload_from_bytes"},
123123
)
@@ -142,7 +142,7 @@ def test_upload_from_file(self, sdk_client: RunloopSDK) -> None:
142142
try:
143143
obj = sdk_client.storage_object.upload_from_file(
144144
tmp_path,
145-
unique_name("sdk-file-upload"),
145+
name=unique_name("sdk-file-upload"),
146146
metadata={"source": "upload_from_file"},
147147
)
148148

@@ -171,7 +171,7 @@ def test_upload_from_dir(self, sdk_client: RunloopSDK) -> None:
171171

172172
obj = sdk_client.storage_object.upload_from_dir(
173173
tmp_path,
174-
unique_name("sdk-dir-upload"),
174+
name=unique_name("sdk-dir-upload"),
175175
metadata={"source": "upload_from_dir"},
176176
)
177177

@@ -206,7 +206,7 @@ def test_download_as_text(self, sdk_client: RunloopSDK) -> None:
206206
content = "Text content to download"
207207
obj = sdk_client.storage_object.upload_from_text(
208208
content,
209-
unique_name("sdk-download-text"),
209+
name=unique_name("sdk-download-text"),
210210
)
211211

212212
try:
@@ -221,7 +221,7 @@ def test_download_as_bytes(self, sdk_client: RunloopSDK) -> None:
221221
content = b"Bytes content to download"
222222
obj = sdk_client.storage_object.upload_from_bytes(
223223
content,
224-
unique_name("sdk-download-bytes"),
224+
name=unique_name("sdk-download-bytes"),
225225
content_type="text",
226226
)
227227

@@ -237,7 +237,7 @@ def test_get_download_url(self, sdk_client: RunloopSDK) -> None:
237237
"""Test getting download URL."""
238238
obj = sdk_client.storage_object.upload_from_text(
239239
"Content for URL",
240-
unique_name("sdk-download-url"),
240+
name=unique_name("sdk-download-url"),
241241
)
242242

243243
try:
@@ -266,7 +266,7 @@ def test_get_storage_object_by_id(self, sdk_client: RunloopSDK) -> None:
266266
# Create an object
267267
created = sdk_client.storage_object.upload_from_text(
268268
"Content for retrieval",
269-
unique_name("sdk-storage-retrieve"),
269+
name=unique_name("sdk-storage-retrieve"),
270270
)
271271

272272
try:
@@ -286,7 +286,7 @@ def test_list_storage_objects_by_content_type(self, sdk_client: RunloopSDK) -> N
286286
# Create object with specific content type
287287
obj = sdk_client.storage_object.upload_from_text(
288288
"Text content",
289-
unique_name("sdk-storage-list-type"),
289+
name=unique_name("sdk-storage-list-type"),
290290
)
291291

292292
try:
@@ -310,7 +310,7 @@ def test_mount_storage_object_to_devbox(self, sdk_client: RunloopSDK) -> None:
310310
# Create storage object with content
311311
obj = sdk_client.storage_object.upload_from_text(
312312
"Mounted content from SDK",
313-
unique_name("sdk-mount-object"),
313+
name=unique_name("sdk-mount-object"),
314314
)
315315

316316
try:
@@ -342,7 +342,7 @@ def test_access_mounted_storage_object(self, sdk_client: RunloopSDK) -> None:
342342
# Create storage object
343343
obj = sdk_client.storage_object.upload_from_text(
344344
"Content to mount and access",
345-
unique_name("sdk-mount-access"),
345+
name=unique_name("sdk-mount-access"),
346346
)
347347

348348
try:
@@ -384,7 +384,7 @@ def test_storage_object_large_content(self, sdk_client: RunloopSDK) -> None:
384384

385385
obj = sdk_client.storage_object.upload_from_text(
386386
large_content,
387-
unique_name("sdk-storage-large"),
387+
name=unique_name("sdk-storage-large"),
388388
)
389389

390390
try:
@@ -403,7 +403,7 @@ def test_storage_object_binary_content(self, sdk_client: RunloopSDK) -> None:
403403

404404
obj = sdk_client.storage_object.upload_from_bytes(
405405
binary_content,
406-
unique_name("sdk-storage-binary"),
406+
name=unique_name("sdk-storage-binary"),
407407
content_type="binary",
408408
)
409409

@@ -419,7 +419,7 @@ def test_storage_object_empty_content(self, sdk_client: RunloopSDK) -> None:
419419
"""Test uploading empty content."""
420420
obj = sdk_client.storage_object.upload_from_text(
421421
"",
422-
unique_name("sdk-storage-empty"),
422+
name=unique_name("sdk-storage-empty"),
423423
)
424424

425425
try:

0 commit comments

Comments
 (0)