From 712ab8746adf3d275d2f4b18570e71d66733956e Mon Sep 17 00:00:00 2001 From: scott Date: Fri, 14 Jun 2024 21:45:30 +0100 Subject: [PATCH 1/2] tests for edit entities --- tests/tests/mock_data.py | 4 +-- tests/tests/test_push_edit.py | 52 +++++++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+), 2 deletions(-) create mode 100644 tests/tests/test_push_edit.py diff --git a/tests/tests/mock_data.py b/tests/tests/mock_data.py index 562b75a..bac52c4 100644 --- a/tests/tests/mock_data.py +++ b/tests/tests/mock_data.py @@ -533,7 +533,7 @@ "data": None, "description": "", "entity_type_id": "1e1e03ea-3211-4a4c-a389-6bbedf9cd0e9", - "id": "ec6069cc-274a-4a27-a5de-a1f041db166c", + "id": "edit-id-1", "is_casting_standby": False, "name": "test_edit1", "nb_entities_out": 0, @@ -556,7 +556,7 @@ "data": None, "description": "", "entity_type_id": "1e1e03ea-3211-4a4c-a389-6bbedf9cd0e9", - "id": "4f1c9c68-f1ff-44b3-9c7a-9d8abd3d7419", + "id": "edit-id-2", "is_casting_standby": False, "name": "test_edit2", "nb_entities_out": 0, diff --git a/tests/tests/test_push_edit.py b/tests/tests/test_push_edit.py new file mode 100644 index 0000000..77e2df4 --- /dev/null +++ b/tests/tests/test_push_edit.py @@ -0,0 +1,52 @@ +"""tests for endpoint 'api/addons/kitsu/{version}/push' +with entities of kitsu type: Edit + +$ poetry run pytest tests/test_push_edit.py +""" + +from pprint import pprint + +import pytest + +from . import mock_data +from .fixtures import ( + PROJECT_NAME, + api, + kitsu_url, +) + + +def test_push_edits(api, kitsu_url): + entities = mock_data.all_edits_for_project + + res = api.post( + f"{kitsu_url}/push", + project_name=PROJECT_NAME, + entities=entities, + ) + assert res.status_code == 200 + assert "folders" in res.data + assert list(res.data["folders"].keys()) == ["edit-id-1", "edit-id-2"] + + +def test_edit_name_validation_bugfix(api, kitsu_url): + edit = { + "id": "edit-id-3", + "name": "", + "code": None, + "description": "", + "shotgun_id": None, + "canceled": False, + "nb_frames": None, + "nb_entities_out": 0, + "is_casting_standby": False, + "status": "running", + "project_id": "74f89547-91e2-4b91-9fd5-960cc33b30a5", + "entity_type_id": "65d66965-09c4-45df-857a-112e509db6ef", + "parent_id": "f998c1ba-4f71-4d7e-b3f4-a1c868709612", + "source_id": None, + "preview_file_id": None, + "data": None, + "ready_for": None, + "type": "Edit", + } From da5d033bfdab5e8b93a956361c305e3758353618 Mon Sep 17 00:00:00 2001 From: scott Date: Fri, 14 Jun 2024 21:46:35 +0100 Subject: [PATCH 2/2] tests for concept entities --- tests/tests/mock_data.py | 77 +++++++++++++++++++++++++++++--- tests/tests/test_push_concept.py | 51 +++++++++++++++++++++ 2 files changed, 122 insertions(+), 6 deletions(-) create mode 100644 tests/tests/test_push_concept.py diff --git a/tests/tests/mock_data.py b/tests/tests/mock_data.py index bac52c4..9b8ae0a 100644 --- a/tests/tests/mock_data.py +++ b/tests/tests/mock_data.py @@ -583,7 +583,7 @@ "description": None, "entity_concept_links": [], "entity_type_id": "e6fd7768-c032-4b6f-a5b4-2b0b892b8540", - "id": "62707498-bbd2-4fcf-a7be-4b061942086c", + "id": "concept-id-1", "is_casting_standby": False, "name": "temp1.png-5f893bd8-69eb-49d7-9093-fb4cc8327894", "nb_entities_out": 0, @@ -601,26 +601,26 @@ { "canceled": False, "code": None, - "created_at": "2024-02-19T13:16:00", "created_by": "7910f71b-245b-4168-9c92-8bf38d0e403d", "data": None, "description": None, "entity_concept_links": [], "entity_type_id": "e6fd7768-c032-4b6f-a5b4-2b0b892b8540", - "id": "3be7f393-3696-4167-b10a-1efc584b0318", + "id": "concept-id-2", "is_casting_standby": False, "name": "temp2.jpg-a219866e-b637-4717-8490-b208a76a0d75", "nb_entities_out": 0, "nb_frames": None, "parent_id": None, "preview_file_id": "aa56ffb5-2875-420a-879e-4d23f2b40e28", - "project_id": "67c8ad65-0350-4b38-93be-5d0a4653f465", + "project_id": "project-id-1", "ready_for": None, "shotgun_id": None, "source_id": None, "status": "running", "type": "Concept", - "updated_at": "2024-02-19T13:16:01", + "created_at": "2024-01-01T00:00:00", + "updated_at": "2024-01-01T00:00:00", }, { "canceled": False, @@ -631,7 +631,7 @@ "description": None, "entity_concept_links": [], "entity_type_id": "e6fd7768-c032-4b6f-a5b4-2b0b892b8540", - "id": "60e2e35f-4cf3-4e4a-b0ab-5e11424ebb17", + "id": "concept-id-3", "is_casting_standby": False, "name": "temp3.jpg-d4e7d9af-5ccb-4192-b350-66b1049ee8f2", "nb_entities_out": 0, @@ -647,3 +647,68 @@ "updated_at": "2024-02-19T13:16:09", }, ] + +all_concept_tasks = [ + { + "assignees": [], + "name": "main", + "description": None, + "priority": 0, + "duration": 0.0, + "estimation": 0.0, + "completion_rate": 0, + "retake_count": 0, + "sort_order": 0, + "start_date": None, + "due_date": None, + "real_start_date": None, + "end_date": None, + "last_comment_date": "2024-02-12T17:48:54", + "nb_assets_ready": 0, + "data": None, + "shotgun_id": None, + "project_id": "3bbf7eb9-32ad-48a3-ba7b-c26606909c37", + "task_type_id": "task-type-id-3", + "task_type_name": "Concept", + "task_status_id": "status-id-1", + "task_status_name": "Approved", + "entity_id": "concept-id-1", + "assigner_id": "cc27d066-07cb-45c8-8a1c-0ca84eba48b2", + "id": "concept-task-id-1", + "created_at": "2024-02-12T17:48:54", + "updated_at": "2024-02-12T17:48:54", + "type": "Task", + "persons": [], + }, + { + "assignees": [], + "name": "main", + "description": None, + "priority": 0, + "duration": 0.0, + "estimation": 0.0, + "completion_rate": 0, + "retake_count": 0, + "sort_order": 0, + "start_date": None, + "due_date": None, + "real_start_date": None, + "end_date": None, + "last_comment_date": "2024-02-12T17:48:54", + "nb_assets_ready": 0, + "data": None, + "shotgun_id": None, + "project_id": "project-id-1", + "task_type_id": "task-type-id-3", + "task_type_name": "Concept", + "task_status_id": "status-id-1", + "task_status_name": "Approved", + "entity_id": "concept-id-2", + "assigner_id": "user-id-1", + "id": "concept-task-id-2", + "created_at": "2024-02-12T17:48:54", + "updated_at": "2024-02-12T17:48:54", + "type": "Task", + "persons": [], + }, +] diff --git a/tests/tests/test_push_concept.py b/tests/tests/test_push_concept.py new file mode 100644 index 0000000..6b91612 --- /dev/null +++ b/tests/tests/test_push_concept.py @@ -0,0 +1,51 @@ +"""tests for endpoint 'api/addons/kitsu/{version}/push' +with entities of kitsu type: Concept + +$ poetry run pytest tests/test_push_concept.py +""" + +from pprint import pprint + +import pytest + +from . import mock_data +from .fixtures import ( + PROJECT_NAME, + api, + kitsu_url, +) + + +def test_push_concepts(api, kitsu_url): + entities = mock_data.all_concepts_for_project + + res = api.post( + f"{kitsu_url}/push", + project_name=PROJECT_NAME, + entities=entities, + ) + assert res.status_code == 200 + assert "folders" in res.data + assert list(res.data["folders"].keys()) == [ + "concept-id-1", + "concept-id-2", + "concept-id-3", + ] + + +def test_push_concept_tasks(api, kitsu_url): + entities = mock_data.all_concept_tasks + + res = api.post( + f"{kitsu_url}/push", + project_name=PROJECT_NAME, + entities=entities, + ) + assert res.status_code == 200 + pprint(res.data) + + assert "tasks" in res.data + assert list(res.data["tasks"].keys()) == [ + "concept-task-id-1", + "concept-task-id-2", + ]