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"]
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']