Skip to content

Commit

Permalink
Merge pull request #315 from EvanBldy/master
Browse files Browse the repository at this point in the history
[files] add new function gazu.files.remove_preview_file
  • Loading branch information
frankrousseau authored Feb 17, 2024
2 parents 3d8c9d1 + c10d754 commit 85f9e02
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
14 changes: 14 additions & 0 deletions gazu/files.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,20 @@ def get_preview_file(preview_file_id, client=default):
return raw.fetch_one("preview-files", preview_file_id, client=client)


def remove_preview_file(preview_file, client=default):
"""
Remove given preview file from database.
Args:
preview_file (str / dict): The preview_file dict or ID.
"""
preview_file = normalize_model_parameter(preview_file)
return raw.delete(
"data/preview-files/%s" % preview_file["id"],
client=client,
)


@cache
def get_all_preview_files_for_task(task, client=default):
"""
Expand Down
10 changes: 10 additions & 0 deletions tests/test_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -1067,6 +1067,16 @@ def test_get_preview_file(self):
)
self.assertEqual(preview_file["name"], "preview-file-1")

def test_remove_preview_file(self):
with requests_mock.mock() as mock:
mock_route(
mock,
"DELETE",
"data/preview-files/%s" % fakeid("preview-file-1"),
status_code=204,
)
gazu.files.remove_preview_file(fakeid("preview-file-1"))

def test_get_all_preview_files_for_task(self):
with requests_mock.mock() as mock:
text = [
Expand Down

0 comments on commit 85f9e02

Please sign in to comment.