예제 #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
예제 #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"]
예제 #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']
예제 #4
0
 def test_to_data_device():
     """Test the to_data method for devices."""
     # Arrange
     sub = Subscription()
     sub.source_type = SourceType.DEVICE
     sub.device_id = "397678e5-9995-4a39-9d9f-ae6ba310236b"
     sub.component_id = "main"
     sub.capability = "switch"
     sub.attribute = "switchLevel"
     sub.value = "100"
     sub.state_change_only = True
     sub.subscription_name = "Test"
     # Act
     data = sub.to_data()
     # Assert
     assert data["sourceType"] == SourceType.DEVICE.value
     assert data["device"]["deviceId"] == "397678e5-9995-4a39-9d9f-ae6ba310236b"
     assert data["device"]["componentId"] == "main"
     assert data["device"]["capability"] == "switch"
     assert data["device"]["attribute"] == "switchLevel"
     assert data["device"]["value"] == "100"
     assert data["device"]["subscriptionName"] == "Test"
     assert data["device"]["stateChangeOnly"]
예제 #5
0
 def test_to_data_device():
     """Test the to_data method for devices."""
     # Arrange
     sub = Subscription()
     sub.source_type = SourceType.DEVICE
     sub.device_id = '397678e5-9995-4a39-9d9f-ae6ba310236b'
     sub.component_id = 'main'
     sub.capability = 'switch'
     sub.attribute = 'switchLevel'
     sub.value = '100'
     sub.state_change_only = True
     sub.subscription_name = "Test"
     # Act
     data = sub.to_data()
     # Assert
     assert data['sourceType'] == SourceType.DEVICE.value
     assert data['device']['deviceId'] == \
         '397678e5-9995-4a39-9d9f-ae6ba310236b'
     assert data['device']['componentId'] == 'main'
     assert data['device']['capability'] == "switch"
     assert data['device']['attribute'] == "switchLevel"
     assert data['device']['value'] == "100"
     assert data['device']['subscriptionName'] == 'Test'
     assert data['device']['stateChangeOnly']