-
Notifications
You must be signed in to change notification settings - Fork 151
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Document Delete APIs and add TLV Command Statuses
- Loading branch information
github-actions
committed
Apr 16, 2024
1 parent
936212f
commit 5953d22
Showing
59 changed files
with
665 additions
and
393 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
145 changes: 145 additions & 0 deletions
145
demos/python/sdk_wireless_camera_control/tests/e2e/test_delete_media.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,145 @@ | ||
# test_delete_media.py/Open GoPro, Version 2.0 (C) Copyright 2021 GoPro, Inc. (http://gopro.com/OpenGoPro). | ||
# This copyright was auto-generated on Tue Apr 16 20:07:53 UTC 2024 | ||
|
||
import asyncio | ||
from typing import AsyncGenerator | ||
|
||
import pytest | ||
|
||
from open_gopro import Params, proto | ||
from open_gopro.gopro_wired import WiredGoPro | ||
from open_gopro.models import MediaPath | ||
|
||
|
||
@pytest.fixture(scope="function") | ||
async def gopro() -> AsyncGenerator[WiredGoPro, None]: | ||
async with WiredGoPro() as gopro: | ||
assert (await gopro.http_command.delete_all()).ok | ||
yield gopro | ||
|
||
|
||
async def create_single_photo(gopro: WiredGoPro) -> MediaPath: | ||
# Set a "single" photo preset | ||
presets = (await gopro.http_command.get_preset_status()).data | ||
photo_presets = next(group for group in presets["presetGroupArray"] if "photo" in group["id"].lower()) | ||
single_preset_id = next(preset for preset in photo_presets["presetArray"] if "single" in preset["mode"].lower())[ | ||
"id" | ||
] | ||
assert (await gopro.http_command.load_preset(preset=single_preset_id)).ok | ||
|
||
assert (await gopro.http_command.set_shutter(shutter=Params.Toggle.ENABLE)).ok | ||
photo = (await gopro.http_command.get_last_captured_media()).data | ||
# Sanity check photo is in media list | ||
assert photo in (await gopro.http_command.get_media_list()).data | ||
return photo | ||
|
||
|
||
async def create_burst_photo(gopro: WiredGoPro) -> MediaPath: | ||
# Set a "burst" photo preset | ||
presets = (await gopro.http_command.get_preset_status()).data | ||
photo_presets = next(group for group in presets["presetGroupArray"] if "photo" in group["id"].lower()) | ||
burst_preset_id = next(preset for preset in photo_presets["presetArray"] if "burst" in preset["mode"].lower())["id"] | ||
assert (await gopro.http_command.load_preset(preset=burst_preset_id)).ok | ||
|
||
assert (await gopro.http_command.set_shutter(shutter=Params.Toggle.ENABLE)).ok | ||
grouped_photo = (await gopro.http_command.get_last_captured_media()).data | ||
# Sanity check photo is in media list | ||
assert grouped_photo in (await gopro.http_command.get_media_list()).data | ||
return grouped_photo | ||
|
||
|
||
async def create_timelapse_photo(gopro: WiredGoPro) -> MediaPath: | ||
# Set a "timelapse" photo preset | ||
presets = (await gopro.http_command.get_preset_status()).data | ||
timelapse_presets = next(group for group in presets["presetGroupArray"] if "timelapse" in group["id"].lower()) | ||
assert (await gopro.http_command.load_preset_group(group=proto.EnumPresetGroup.PRESET_GROUP_ID_TIMELAPSE)).ok | ||
assert (await gopro.http_setting.media_format.set(Params.MediaFormat.TIME_LAPSE_PHOTO)).ok | ||
lapse_id = next(preset for preset in timelapse_presets["presetArray"] if "lapse_photo" in preset["mode"].lower())[ | ||
"id" | ||
] | ||
assert (await gopro.http_command.load_preset(preset=lapse_id)).ok | ||
|
||
# Take a timelapse | ||
assert (await gopro.http_command.set_shutter(shutter=Params.Toggle.ENABLE)).ok | ||
await asyncio.sleep(3) | ||
assert (await gopro.http_command.set_shutter(shutter=Params.Toggle.DISABLE)).ok | ||
|
||
grouped_photo = (await gopro.http_command.get_last_captured_media()).data | ||
# Sanity check photo is in media list | ||
assert grouped_photo in (await gopro.http_command.get_media_list()).data | ||
return grouped_photo | ||
|
||
|
||
@pytest.mark.timeout(60) | ||
class TestOpenGoPro: | ||
""" | ||
Test already-existing but not yet documented open gopro endpoints. | ||
Results: | ||
- the delete group endpoint does not exist | ||
- the delete file endpoint succeeds in deleting both single and grouped (burst) files. | ||
""" | ||
|
||
@pytest.mark.asyncio | ||
async def test_delete_file_deletes_single_file(self, gopro: WiredGoPro): | ||
# GIVEN | ||
photo = await create_single_photo(gopro) | ||
|
||
# WHEN | ||
assert (await gopro.http_command.delete_file(path=photo.as_path)).ok | ||
|
||
# THEN | ||
media_list = (await gopro.http_command.get_media_list()).data.files | ||
assert not media_list # Media list should be empty | ||
|
||
@pytest.mark.asyncio | ||
async def test_delete_file_partially_deletes_burst_group(self, gopro: WiredGoPro): | ||
# GIVEN | ||
burst_group = await create_burst_photo(gopro) | ||
|
||
# WHEN | ||
assert (await gopro.http_command.delete_file(path=burst_group.as_path)).ok | ||
|
||
# THEN | ||
media_list = (await gopro.http_command.get_media_list()).data.files | ||
assert media_list | ||
assert burst_group not in media_list | ||
|
||
@pytest.mark.asyncio | ||
async def test_delete_file_partially_deletes_timelapse_group(self, gopro: WiredGoPro): | ||
# GIVEN | ||
timelapse_group = await create_timelapse_photo(gopro) | ||
|
||
# WHEN | ||
assert (await gopro.http_command.delete_file(path=timelapse_group.as_path)).ok | ||
|
||
# THEN | ||
media_list = (await gopro.http_command.get_media_list()).data.files | ||
assert media_list | ||
assert timelapse_group not in media_list | ||
|
||
@pytest.mark.asyncio | ||
async def test_delete_group_deletes_burst_group(self, gopro: WiredGoPro): | ||
# GIVEN | ||
burst_group = await create_burst_photo(gopro) | ||
|
||
# WHEN | ||
assert (await gopro.http_command.delete_group(path=burst_group.as_path)).ok | ||
|
||
# THEN | ||
media_list = (await gopro.http_command.get_media_list()).data.files | ||
assert not media_list | ||
|
||
@pytest.mark.asyncio | ||
async def test_delete_group_deletes_timelapse_group(self, gopro: WiredGoPro): | ||
# GIVEN | ||
timelapse_group = await create_timelapse_photo(gopro) | ||
|
||
# WHEN | ||
assert (await gopro.http_command.delete_group(path=timelapse_group.as_path)).ok | ||
|
||
# THEN | ||
media_list = (await gopro.http_command.get_media_list()).data.files | ||
assert not media_list |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.