2025-01-30 18:34:32 -03:00
|
|
|
from io import BytesIO
|
|
|
|
|
|
|
|
|
|
import pytest
|
2025-02-04 19:18:58 -03:00
|
|
|
from urllib3.util import parse_url
|
2025-01-30 18:34:32 -03:00
|
|
|
|
2025-02-04 19:18:58 -03:00
|
|
|
from benchmarks.codex.client.async_client import AsyncCodexClientImpl
|
2025-01-31 15:49:58 -03:00
|
|
|
from benchmarks.core.utils.random import random_data
|
2025-01-30 18:34:32 -03:00
|
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture
|
|
|
|
|
def random_file() -> BytesIO:
|
|
|
|
|
b = BytesIO()
|
|
|
|
|
random_data(size=2048, outfile=b)
|
|
|
|
|
b.seek(0)
|
|
|
|
|
return b
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.codex_integration
|
|
|
|
|
@pytest.mark.asyncio
|
2025-02-04 19:18:58 -03:00
|
|
|
async def test_should_upload_file(codex_node_1_url: str, random_file):
|
|
|
|
|
codex_client = AsyncCodexClientImpl(parse_url(codex_node_1_url))
|
|
|
|
|
cid = await codex_client.upload(
|
2025-01-30 18:34:32 -03:00
|
|
|
content=random_file, name="dataset-1", mime_type="application/octet-stream"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
assert cid is not None
|
|
|
|
|
|
2025-02-04 19:18:58 -03:00
|
|
|
manifest = await codex_client.manifest(cid)
|
2025-01-30 18:34:32 -03:00
|
|
|
|
|
|
|
|
assert manifest.cid == cid
|
|
|
|
|
assert manifest.datasetSize == 2048
|
|
|
|
|
assert manifest.mimetype == "application/octet-stream"
|