Skip to content

Commit

Permalink
[files] Add all output files for project
Browse files Browse the repository at this point in the history
  • Loading branch information
frankrousseau committed Feb 10, 2024
1 parent 2fd16aa commit 924ae6a
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 0 deletions.
46 changes: 46 additions & 0 deletions gazu/files.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,52 @@ def all_output_files_for_asset_instance(
return raw.fetch_all(path, params, client=client)


def all_output_files_for_project(
project,
output_type=None,
task_type=None,
name=None,
representation=None,
file_status=None,
client=default,
):
"""
Args:
entity (str / dict): The entity dict or ID.
output_type (str / dict): The output type dict or ID.
task_type (str / dict): The task type dict or ID.
name (str): The file name
representation (str): The file representation
file_status (str / dict): The file status
Returns:
list:
Output files for a given project (asset or shot), output type,
task_type, name and representation
"""
project = normalize_model_parameter(project)
output_type = normalize_model_parameter(output_type)
task_type = normalize_model_parameter(task_type)
file_status = normalize_model_parameter(file_status)
path = "projects/{project_id}/output-files".format(
project_id=project["id"]
)

params = {}
if output_type:
params["output_type_id"] = output_type["id"]
if task_type:
params["task_type_id"] = task_type["id"]
if representation:
params["representation"] = representation
if name:
params["name"] = name
if file_status:
params["file_status_id"] = file_status["id"]

return raw.fetch_all(path, params, client=client)


@cache
def all_softwares(client=default):
"""
Expand Down
17 changes: 17 additions & 0 deletions tests/test_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -562,6 +562,23 @@ def test_get_output_files_for_asset_instance(self):
self.assertEqual(output_files[0]["id"], "output-file-01")
self.assertEqual(output_files[0]["name"], "main")

def test_get_output_files_for_project(self):
with requests_mock.mock() as mock:
base_path = "projects/project-01/output-files"
path = gazu.client.url_path_join("data", base_path)
params = {"output_type_id": "output-type-1"}

mock.get(
gazu.client.get_full_url(
gazu.client.build_path_with_params(path, params)
),
text=json.dumps([{"id": "output-file-01", "name": "main"}]),
)
output_files = gazu.files.all_output_files_for_project(
{"id": "project-01"}, output_type={"id": "output-type-1"}
)
self.assertEqual(output_files[0]["name"], "main")

def test_update_modification_date(self):
with requests_mock.mock() as mock:
path = "/actions/working-files/working-file-01/modified"
Expand Down

0 comments on commit 924ae6a

Please sign in to comment.