Example #1
0
 def test_client_name_invalid():
     """Tests setting an invalid client name."""
     # Arrange
     oauth = AppOAuth("5c03e518-118a-44cb-85ad-7877d0b302e4")
     # Act/Assert
     with pytest.raises(ValueError):
         oauth.client_name = ""
Example #2
0
 def test_client_name():
     """Tests get/set of client name."""
     # Arrange
     oauth = AppOAuth("5c03e518-118a-44cb-85ad-7877d0b302e4")
     # Act
     expected = "my_app"
     oauth.client_name = expected
     actual = oauth.client_name
     # Assert
     assert actual == expected
 async def test_update_app_oauth(smartthings):
     """Tests updating OAuth settings."""
     # Arrange
     oauth = AppOAuth(APP_ID)
     oauth.client_name = "pysmartthings-test"
     oauth.scope.append("r:devices")
     # Act
     oauth_entity = await smartthings.update_app_oauth(oauth)
     # Assert
     assert oauth_entity.app_id == oauth.app_id
     assert oauth_entity.client_name == oauth.client_name
     assert oauth_entity.scope == oauth.scope
 async def test_generate_app_oauth(smartthings):
     """Tests generating new OAuth info."""
     # Arrange
     oauth = AppOAuth(APP_ID)
     oauth.client_name = "pysmartthings"
     oauth.scope.append("r:devices:*")
     # Act
     entity = await smartthings.generate_app_oauth(oauth)
     # Assert
     assert entity.client_id == "0b6a77d4-2dff-4b00-ba33-35f660fbfb83"
     assert entity.client_secret == "05a49aac-55d6-4092-96bf-7ca6ca3666d3"
     assert entity.client_details.app_id == APP_ID
     assert entity.client_details.client_name == "pysmartthings"
     assert entity.client_details.scope == ["r:devices:$", "r:devices:*"]
Example #5
0
 def test_init():
     """Tests the initialization."""
     # Arrange
     app_id = "5c03e518-118a-44cb-85ad-7877d0b302e4"
     # Act
     oauth = AppOAuth(app_id)
     # Assert
     assert app_id == oauth.app_id
     assert oauth.scope is not None