Ejemplo n.º 1
0
 async def test_create_subscription(smartthings):
     """Tests the create subscription method."""
     # Arrange
     sub = Subscription()
     sub.source_type = "CAPABILITY"
     sub.location_id = LOCATION_ID
     sub.capability = "switch"
     sub.installed_app_id = INSTALLED_APP_ID
     # Act
     entity = await smartthings.create_subscription(sub)
     # Assert
     assert entity.subscription_id == SUBSCRIPTION_ID
Ejemplo n.º 2
0
 def test_to_data_capability():
     """Test the to_data method for capabilities."""
     # Arrange
     sub = Subscription()
     sub.source_type = SourceType.CAPABILITY
     sub.location_id = "397678e5-9995-4a39-9d9f-ae6ba310236b"
     sub.capability = "switch"
     sub.attribute = "switchLevel"
     sub.value = "100"
     sub.state_change_only = False
     sub.subscription_name = "Test"
     # Act
     data = sub.to_data()
     # Assert
     assert data["sourceType"] == SourceType.CAPABILITY.value
     assert (data["capability"]["locationId"] ==
             "397678e5-9995-4a39-9d9f-ae6ba310236b")
     assert data["capability"]["capability"] == "switch"
     assert data["capability"]["attribute"] == "switchLevel"
     assert data["capability"]["value"] == "100"
     assert data["capability"]["subscriptionName"] == "Test"
     assert not data["capability"]["stateChangeOnly"]
Ejemplo n.º 3
0
 def test_to_data_capability():
     """Test the to_data method for capabilities."""
     # Arrange
     sub = Subscription()
     sub.source_type = SourceType.CAPABILITY
     sub.location_id = '397678e5-9995-4a39-9d9f-ae6ba310236b'
     sub.capability = 'switch'
     sub.attribute = 'switchLevel'
     sub.value = '100'
     sub.state_change_only = False
     sub.subscription_name = "Test"
     # Act
     data = sub.to_data()
     # Assert
     assert data['sourceType'] == SourceType.CAPABILITY.value
     assert data['capability']['locationId'] == \
         '397678e5-9995-4a39-9d9f-ae6ba310236b'
     assert data['capability']['capability'] == 'switch'
     assert data['capability']['attribute'] == 'switchLevel'
     assert data['capability']['value'] == '100'
     assert data['capability']['subscriptionName'] == 'Test'
     assert not data['capability']['stateChangeOnly']