Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async def test_save_no_app_id(api):
"""Tests save when there's no app id."""
# Arrange
settings = AppSettingsEntity(api, None)
# Act/Assert
with pytest.raises(ValueError):
await settings.save()
async def test_refresh(api):
"""Tests data is refreshed."""
# Arrange
data = {'settings': {'test2': 'test'}}
settings = AppSettingsEntity(api, APP_ID, data)
# Act
await settings.refresh()
# Assert
assert settings.settings == {'test': 'test'}
async def test_refresh_no_app_id(api):
"""Tests refresh when there's no app id."""
# Arrange
settings = AppSettingsEntity(api, None)
# Act/Assert
with pytest.raises(ValueError):
await settings.refresh()
async def test_save(api):
"""Tests the save function."""
# Arrange
data = {'settings': {'test': 'test'}}
settings = AppSettingsEntity(api, APP_ID, data)
# Act
await settings.save()
# Assert
assert settings.settings == {'test': 'test'}
async def update_app_settings(self, data: AppSettings) -> AppSettingsEntity:
"""Update an app's settings."""
entity = await self._service.update_app_settings(data.app_id, data.to_data())
return AppSettingsEntity(self._service, data.app_id, entity)
async def app_settings(self, app_id: str) -> AppSettingsEntity:
"""Get an app's settings."""
settings = await self._service.get_app_settings(app_id)
return AppSettingsEntity(self._service, app_id, settings)
async def settings(self) -> AppSettingsEntity:
"""Get the app's settings."""
entity = await self._api.get_app_settings(self._app_id)
return AppSettingsEntity(self._api, self._app_id, entity)