Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_init():
"""Tests the init function."""
# Arrange/Act
app = App()
# Assert
assert app.classifications is not None
assert app.lambda_functions is not None
def test_description_invalid():
"""Tests valid values of description."""
# Arrange
app = App()
# Act/Assert
with pytest.raises(ValueError):
app.description = ''
with pytest.raises(ValueError):
app.description = None
with pytest.raises(ValueError):
app.description = 'x' * 251
def test_description():
"""Tests get/set of description."""
# Arrange
app = App()
# Act
expected = "My Description"
app.description = expected
actual = app.description
# Assert
assert expected == actual
def test_single_instance():
"""Tests get/set of single_instance."""
# Arrange
app = App()
# Act
expected = True
app.single_instance = expected
actual = app.single_instance
# Assert
assert expected == actual
async def test_create_app(smartthings):
"""Tests the create app method."""
# Arrange
app = App()
data = get_json('app_post_request.json')
data['appId'] = APP_ID
app.apply_data(data)
# Act
app, oauth = await smartthings.create_app(app)
# Assert
assert app.app_id == APP_ID
assert oauth.client_id == '7cd4d474-7b36-4e03-bbdb-4cd4ae45a2be'
assert oauth.client_secret == '9b3fd445-42d6-441b-b386-99ea51e13cb0'
def test_apply_data():
"""Tests the apply_data function."""
# Arrange
app = App()
data = get_json('app_get.json')
# Act
app.apply_data(data)
# Assert
assert app.app_id == "c6cde2b0-203e-44cf-a510-3b3ed4706996"
assert app.app_name == "pysmartthings-test"
assert app.app_type == "WEBHOOK_SMART_APP"
assert app.classifications == [CLASSIFICATION_AUTOMATION]
assert app.display_name == "Test"
assert app.description == \
"A SmartApp that relays events to the pysmartthings library"
assert app.single_instance
assert app.webhook_target_url == \
"https://homeassistant.sayre.net:8321/"
assert app.webhook_public_key
assert app.created_date == "2018-12-15T17:07:41Z"
def test_app_name_invalid():
"""Tests valid values of app_name."""
# Arrange
app = App()
# Act/Assert
with pytest.raises(ValueError):
app.app_name = ''
with pytest.raises(ValueError):
app.app_name = None
with pytest.raises(ValueError):
app.app_name = "My Super Cool App"
def test_display_name_invalid():
"""Tests valid values of display_name."""
# Arrange
app = App()
# Act/Assert
with pytest.raises(ValueError):
app.display_name = ''
with pytest.raises(ValueError):
app.display_name = None
with pytest.raises(ValueError):
app.display_name = 'x' * 76
def __init__(self, api: Api, data=None):
"""Create a new instance of the AppEntity class."""
Entity.__init__(self, api)
App.__init__(self)
if data:
self.apply_data(data)