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_refresh(api):
"""Tests the refresh method."""
# Arrange
entity = AppOAuthEntity(
api, 'c6cde2b0-203e-44cf-a510-3b3ed4706996', None)
# Act
await entity.refresh()
# Assert
assert entity.client_name == 'pysmartthings-test'
assert 'r:devices' in entity.scope
async def test_save(api):
"""Tests the refresh method."""
# Arrange
entity = AppOAuthEntity(
api, 'c6cde2b0-203e-44cf-a510-3b3ed4706996', None)
entity.client_name = 'pysmartthings-test'
entity.scope.append('r:devices')
# Act/Assert
await entity.save()
def __init__(self, api: Api, app_id: str, data: Optional[dict]):
"""Init the class."""
self._client_details = AppOAuthEntity(api, app_id, None)
super().__init__(data)
async def update_app_oauth(self, data: AppOAuth) -> AppOAuthEntity:
"""Update an app's OAuth settings without having to retrieve it."""
entity = await self._service.update_app_oauth(data.app_id, data.to_data())
return AppOAuthEntity(self._service, data.app_id, entity)
async def oauth(self) -> AppOAuthEntity:
"""Get the app's OAuth settings."""
entity = await self._api.get_app_oauth(self._app_id)
return AppOAuthEntity(self._api, self._app_id, entity)
async def app_oauth(self, app_id: str) -> AppOAuthEntity:
"""Get an app's OAuth settings."""
oauth = await self._service.get_app_oauth(app_id)
return AppOAuthEntity(self._service, app_id, oauth)