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 data is refreshed."""
# Arrange
data = get_json('apps.json')['items'][0]
app = AppEntity(api, data)
# Act
await app.refresh()
# Assert
assert app.single_instance
assert app.webhook_target_url == \
"https://homeassistant.sayre.net:8321/"
assert app.webhook_public_key
async def test_settings(api):
"""Tests the settings method."""
# Arrange
data = get_json('app_get.json')
app = AppEntity(api, data)
# Act
settings = await app.settings()
# Assert
assert settings.settings == {'test': 'test'}
async def test_save(api):
"""Tests updating an entity."""
# Arrange
data = get_json('app_get.json')
app = AppEntity(api, data)
before = app.last_updated_date
# Act
await app.save()
# Assert
assert app.last_updated_date > before
async def test_oauth(api):
"""Tests the oauth method."""
# Arrange
data = get_json('app_get.json')
app = AppEntity(api, data)
# Act
oauth = await app.oauth()
# Assert
assert oauth.app_id == app.app_id
assert oauth.client_name == 'pysmartthings-test'
assert oauth.scope == ["r:devices"]
async def create_app(self, app: App) -> (AppEntity, AppOAuthClient):
"""Create a new app."""
entity = await self._service.create_app(app.to_data())
return AppEntity(self._service, entity["app"]), AppOAuthClient(entity)
async def app(self, app_id: str) -> AppEntity:
"""Retrieve an app with the specified ID."""
entity = await self._service.get_app(app_id)
return AppEntity(self._service, entity)
async def create_app(self, app: App) -> (AppEntity, AppOAuthClient):
"""Create a new app."""
entity = await self._service.create_app(app.to_data())
return AppEntity(self._service, entity["app"]), AppOAuthClient(entity)