Skip to content

Commit

Permalink
Initial commit (#945)
Browse files Browse the repository at this point in the history
  • Loading branch information
JBWilkie authored Oct 23, 2024
1 parent 1479069 commit 2644edc
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 1 deletion.
2 changes: 1 addition & 1 deletion darwin/item.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def parse(cls, raw: Dict[str, Any], dataset_slug: str = "n/a") -> "DatasetItem":
"current_workflow_id": raw.get("workflow_data", {}).get("workflow_id"),
"current_workflow": raw.get("workflow_data"),
"slots": raw["slots"],
"layout": raw["layout"],
"layout": raw.get("layout"),
}
else:
data = {
Expand Down
73 changes: 73 additions & 0 deletions tests/darwin/dataset/remote_dataset_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,47 @@ def files_content() -> Dict[str, Any]:
}


@pytest.fixture()
def unprocessed_file_content() -> Dict[str, Any]:
return {
"items": [
{
"id": "018c6826-766c-d596-44b3-46159c7c23bc",
"name": "segment_1.mp4",
"priority": 0,
"status": "processing",
"path": "/",
"tags": [],
"cursor": "018c6826-766c-d596-44b3-46159c7c23bc",
"uploads": [
{
"type": "video",
"file_name": "segment_1.mp4",
"processing_status": "processing",
"slot_name": "0",
"fps": 25,
"upload_id": "5404aafe-6434-44cb-8bc2-4b3758466bbf",
"as_frames": False,
}
],
"slots": [],
"inserted_at": "2023-12-14T11:46:40Z",
"updated_at": "2023-12-14T11:46:40Z",
"dataset_id": 611387,
"archived": False,
"processing_status": "processing",
"workflow_status": "new",
"slot_types": ["video"],
}
],
"page": {
"count": 2,
"next": None,
"previous": "018c6826-766c-d596-44b3-46159c7c23bc",
},
}


# This test was never actually running
# TODO: Fix this test
# class TestDatasetCreation:
Expand Down Expand Up @@ -599,6 +640,38 @@ def test_fetches_files_with_commas(
== "example,with, comma.mp4"
)

@responses.activate
def test_returns_unprocessed_files(
self,
darwin_client: Client,
dataset_name: str,
dataset_slug: str,
team_slug_darwin_json_v2: str,
unprocessed_file_content: dict,
):
remote_dataset = RemoteDatasetV2(
client=darwin_client,
team=team_slug_darwin_json_v2,
name=dataset_name,
slug=dataset_slug,
dataset_id=1,
)
url = "http://localhost/api/v2/teams/v7-darwin-json-v2/items?item_names%5B%5D=example%2Cwith%2C+comma.mp4&page%5Bsize%5D=500&include_workflow_data=true&dataset_ids%5B%5D=1"
responses.add(
responses.GET,
url,
json=unprocessed_file_content,
status=200,
)
filters = {"item_names": ["example,with, comma.mp4"]}

list(remote_dataset.fetch_remote_files(filters))

assert (
responses.calls[0].request.params["item_names[]"]
== "example,with, comma.mp4"
)


@pytest.mark.usefixtures("file_read_write_test")
class TestFetchRemoteClasses:
Expand Down

0 comments on commit 2644edc

Please sign in to comment.