From fdd79ee2c9f48e422e84f30364e23151a9314cc9 Mon Sep 17 00:00:00 2001 From: Evan Blaudy Date: Tue, 8 Oct 2024 00:14:33 +0200 Subject: [PATCH 1/4] [requirements] upgrade --- setup.cfg | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/setup.cfg b/setup.cfg index 38adbf60..ba1f395f 100644 --- a/setup.cfg +++ b/setup.cfg @@ -49,8 +49,8 @@ test = lint = autoflake==2.3.1; python_version >= '3.8' - black==24.8.0; python_version >= '3.8' - pre-commit==3.8.0; python_version >= '3.9' + black==24.10.0; python_version >= '3.9' + pre-commit==4.0.0; python_version >= '3.9' [bdist_wheel] universal = 1 From e8cf2cb768423d67d7cf1298254cd5f0bcdaecc8 Mon Sep 17 00:00:00 2001 From: Evan Blaudy Date: Thu, 10 Oct 2024 15:08:41 +0200 Subject: [PATCH 2/4] [requirements] upgrade --- setup.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.cfg b/setup.cfg index ba1f395f..a2723b02 100644 --- a/setup.cfg +++ b/setup.cfg @@ -50,7 +50,7 @@ test = lint = autoflake==2.3.1; python_version >= '3.8' black==24.10.0; python_version >= '3.9' - pre-commit==4.0.0; python_version >= '3.9' + pre-commit==4.0.1; python_version >= '3.9' [bdist_wheel] universal = 1 From 63080d3a106f615f09e39f5660a0a3d71f081b45 Mon Sep 17 00:00:00 2001 From: Evan Blaudy Date: Thu, 10 Oct 2024 15:12:26 +0200 Subject: [PATCH 3/4] [qa] for task.new_task when using get_default_task_status allow to use a custom client + remove duplicate of task.get_default_task_status --- gazu/task.py | 26 +++----------------------- 1 file changed, 3 insertions(+), 23 deletions(-) diff --git a/gazu/task.py b/gazu/task.py index f7db2aaa..1da36d25 100644 --- a/gazu/task.py +++ b/gazu/task.py @@ -257,12 +257,7 @@ def all_tasks_for_task_status(project, task_type, task_status, client=default): @cache -def all_tasks_for_task_type( - project, - task_type, - episode=None, - client=default -): +def all_tasks_for_task_type(project, task_type, episode=None, client=default): """ Args: project (str / dict): The project dict or the project ID. @@ -532,18 +527,6 @@ def get_task_status_by_name(name, client=default): return raw.fetch_first("task-status", {"name": name}, client=client) -@cache -def get_default_task_status(client=default): - """ - Args: - name (str / dict): The name of claimed task status. - - Returns: - dict: Task status matching given name. - """ - return raw.fetch_first("task-status", {"is_default": True}, client=client) - - @cache def get_task_status_by_short_name(task_status_short_name, client=default): """ @@ -661,7 +644,7 @@ def new_task( entity = normalize_model_parameter(entity) task_type = normalize_model_parameter(task_type) if task_status is None: - task_status = get_default_task_status() + task_status = get_default_task_status(client=client) data = { "project_id": entity["project_id"], @@ -1267,10 +1250,7 @@ def get_task_url(task, client=default): def all_tasks_for_project( - project, - task_type=None, - episode=None, - client=default + project, task_type=None, episode=None, client=default ): """ Args: From 97e046a83988393db99e17184fc52250b85d1f3d Mon Sep 17 00:00:00 2001 From: Evan Blaudy Date: Thu, 10 Oct 2024 15:12:48 +0200 Subject: [PATCH 4/4] [qa] black --- gazu/casting.py | 5 ++++- gazu/playlist.py | 32 ++++++++++------------------- tests/test_casting.py | 4 +++- tests/test_playlist.py | 46 +++++++++++++++++++++++++----------------- 4 files changed, 45 insertions(+), 42 deletions(-) diff --git a/gazu/casting.py b/gazu/casting.py index d5a855c1..c4a5033f 100644 --- a/gazu/casting.py +++ b/gazu/casting.py @@ -60,7 +60,10 @@ def update_episode_casting(project, episode, casting, client=default): """ episode = normalize_model_parameter(episode) project = normalize_model_parameter(project) - path = "data/projects/%s/entities/%s/casting" % (project["id"], episode["id"]) + path = "data/projects/%s/entities/%s/casting" % ( + project["id"], + episode["id"], + ) return raw.put(path, casting, client=client) diff --git a/gazu/playlist.py b/gazu/playlist.py index 8677eacc..03ae0cb8 100644 --- a/gazu/playlist.py +++ b/gazu/playlist.py @@ -166,16 +166,12 @@ def get_entity_preview_files(entity, client=default): entity = normalize_model_parameter(entity) return raw.get( "data/playlists/entities/%s/preview-files" % entity["id"], - client=client + client=client, ) def add_entity_to_playlist( - playlist, - entity, - preview_file=None, - persist=True, - client=default + playlist, entity, preview_file=None, persist=True, client=default ): """ Add an entity to the playlist, use the last uploaded preview as revision @@ -197,25 +193,23 @@ def add_entity_to_playlist( for task_type_id in preview_files.keys(): task_type_files = preview_files[task_type_id] first_file = task_type_files[0] - if preview_file is None or \ - preview_file["created_at"] < first_file["created_at"]: + if ( + preview_file is None + or preview_file["created_at"] < first_file["created_at"] + ): preview_file = first_file preview_file = normalize_model_parameter(preview_file) - playlist["shots"].append({ - "entity_id": entity["id"], - "preview_file_id": preview_file["id"] - }) + playlist["shots"].append( + {"entity_id": entity["id"], "preview_file_id": preview_file["id"]} + ) if persist: update_playlist(playlist, client=client) return playlist def remove_entity_from_playlist( - playlist, - entity, - persist=True, - client=default + playlist, entity, persist=True, client=default ): """ Remove all occurences of a given entity from a playlist. @@ -239,11 +233,7 @@ def remove_entity_from_playlist( def update_entity_preview( - playlist, - entity, - preview_file, - persist=True, - client=default + playlist, entity, preview_file, persist=True, client=default ): """ Remove all occurences of a given entity from a playlist. diff --git a/tests/test_casting.py b/tests/test_casting.py index ddc35778..72a0c99e 100644 --- a/tests/test_casting.py +++ b/tests/test_casting.py @@ -47,7 +47,9 @@ def test_update_episode_casting(self): mock.put(gazu.client.get_full_url(path), text=json.dumps(casting)) episode = {"id": fakeid("episode-01")} project = {"id": fakeid("project-01")} - casting = gazu.casting.update_episode_casting(project, episode, casting) + casting = gazu.casting.update_episode_casting( + project, episode, casting + ) self.assertEqual(casting[0]["asset_id"], fakeid("asset-1")) def test_get_asset_type_casting(self): diff --git a/tests/test_playlist.py b/tests/test_playlist.py index 7b02b31c..7f5a6fc9 100644 --- a/tests/test_playlist.py +++ b/tests/test_playlist.py @@ -179,7 +179,8 @@ def test_add_entity_to_playlist(self): ) mock.get( gazu.client.get_full_url( - "data/playlists/entities/%s/preview-files" % fakeid("shot-1") + "data/playlists/entities/%s/preview-files" + % fakeid("shot-1") ), text=json.dumps( {fakeid("task-type-1"): [{"id": fakeid("preview-1")}]} @@ -188,26 +189,33 @@ def test_add_entity_to_playlist(self): playlist = { "id": fakeid("playlist-1"), "name": "name_changed", - "shots": [] - } - shot = { - "id": fakeid("shot-1"), - "name": "SH01" + "shots": [], } + shot = {"id": fakeid("shot-1"), "name": "SH01"} playlist = gazu.playlist.add_entity_to_playlist(playlist, shot) self.assertEqual(playlist["id"], fakeid("playlist-1")) - self.assertEqual(playlist["shots"], [{ - "entity_id": fakeid("shot-1"), - "preview_file_id": fakeid("preview-1") - }]) + self.assertEqual( + playlist["shots"], + [ + { + "entity_id": fakeid("shot-1"), + "preview_file_id": fakeid("preview-1"), + } + ], + ) playlist = gazu.playlist.update_entity_preview( - playlist, - shot, - fakeid("preview-2") - ) - self.assertEqual(playlist["shots"], [{ - "entity_id": fakeid("shot-1"), - "preview_file_id": fakeid("preview-2") - }]) - playlist = gazu.playlist.remove_entity_from_playlist(playlist, shot) + playlist, shot, fakeid("preview-2") + ) + self.assertEqual( + playlist["shots"], + [ + { + "entity_id": fakeid("shot-1"), + "preview_file_id": fakeid("preview-2"), + } + ], + ) + playlist = gazu.playlist.remove_entity_from_playlist( + playlist, shot + ) self.assertEqual(playlist["shots"], [])