Beispiel #1
0
 def test_webhook_target_url():
     """Tests get/set of webhook_target_url."""
     # Arrange
     app = App()
     # Act
     expected = "http://my.web.site/"
     app.webhook_target_url = expected
     actual = app.webhook_target_url
     # Assert
     assert expected == actual
Beispiel #2
0
 def test_display_name():
     """Tests get/set of display_name."""
     # Arrange
     app = App()
     # Act
     expected = "My Display Name"
     app.display_name = expected
     actual = app.display_name
     # Assert
     assert expected == actual
Beispiel #3
0
 def test_app_name():
     """Tests get/set of app_name."""
     # Arrange
     app = App()
     # Act
     expected_app_name = "my_app"
     app.app_name = expected_app_name
     app_name = app.app_name
     # Assert
     assert app_name == expected_app_name
Beispiel #4
0
 def test_app_type_lambda():
     """Tests get/set of app_type to labmda."""
     # Arrange
     app = App()
     # Act
     expected = APP_TYPE_LAMBDA
     app.app_type = expected
     actual = app.app_type
     # Assert
     assert expected == actual
Beispiel #5
0
 def test_app_type_webhook():
     """Tests get/set of app_type to webhook."""
     # Arrange
     app = App()
     # Act
     expected = APP_TYPE_WEBHOOK
     app.app_type = expected
     actual = app.app_type
     # Assert
     assert expected == actual
Beispiel #6
0
 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
Beispiel #7
0
 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
Beispiel #8
0
 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
Beispiel #9
0
 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"
Beispiel #10
0
 def test_app_type_invalid():
     """Tests valid values of app_type."""
     # Arrange
     app = App()
     # Act/Assert
     with pytest.raises(ValueError):
         app.app_type = ""
     with pytest.raises(ValueError):
         app.app_type = None
     with pytest.raises(ValueError):
         app.app_type = "Some type"
Beispiel #11
0
 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
 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"
Beispiel #13
0
 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
Beispiel #14
0
 def test_lambda_functions():
     """Tests get of lambda_functions."""
     # Arrange
     app = App()
     # Act
     app.lambda_functions.append("arn:aws:lambda:eu-central-1:account-id:"
                                 "function:function-name:alias-name")
     # Assert
     assert app.lambda_functions
Beispiel #15
0
 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"
     assert app.last_updated_date == "2018-12-15T17:07:42Z"