def test_entity_device_info_schema(self): """Test MQTT entity device info validation.""" # just identifier mqtt.MQTT_ENTITY_DEVICE_INFO_SCHEMA({'identifiers': ['abcd']}) mqtt.MQTT_ENTITY_DEVICE_INFO_SCHEMA({'identifiers': 'abcd'}) # just connection mqtt.MQTT_ENTITY_DEVICE_INFO_SCHEMA( {'connections': [ ['mac', '02:5b:26:a8:dc:12'], ]}) # full device info mqtt.MQTT_ENTITY_DEVICE_INFO_SCHEMA({ 'identifiers': ['helloworld', 'hello'], 'connections': [ ["mac", "02:5b:26:a8:dc:12"], ["zigbee", "zigbee_id"], ], 'manufacturer': 'Whatever', 'name': 'Beer', 'model': 'Glass', 'sw_version': '0.1-beta', }) # full device info with via_device mqtt.MQTT_ENTITY_DEVICE_INFO_SCHEMA({ 'identifiers': ['helloworld', 'hello'], 'connections': [ ["mac", "02:5b:26:a8:dc:12"], ["zigbee", "zigbee_id"], ], 'manufacturer': 'Whatever', 'name': 'Beer', 'model': 'Glass', 'sw_version': '0.1-beta', 'via_device': 'test-hub', }) # no identifiers with pytest.raises(vol.Invalid): mqtt.MQTT_ENTITY_DEVICE_INFO_SCHEMA({ 'manufacturer': 'Whatever', 'name': 'Beer', 'model': 'Glass', 'sw_version': '0.1-beta', }) # empty identifiers with pytest.raises(vol.Invalid): mqtt.MQTT_ENTITY_DEVICE_INFO_SCHEMA({ 'identifiers': [], 'connections': [], 'name': 'Beer', })
def test_entity_device_info_schema(self): """Test MQTT entity device info validation.""" # just identifier mqtt.MQTT_ENTITY_DEVICE_INFO_SCHEMA({"identifiers": ["abcd"]}) mqtt.MQTT_ENTITY_DEVICE_INFO_SCHEMA({"identifiers": "abcd"}) # just connection mqtt.MQTT_ENTITY_DEVICE_INFO_SCHEMA( {"connections": [["mac", "02:5b:26:a8:dc:12"]]}) # full device info mqtt.MQTT_ENTITY_DEVICE_INFO_SCHEMA({ "identifiers": ["helloworld", "hello"], "connections": [["mac", "02:5b:26:a8:dc:12"], ["zigbee", "zigbee_id"]], "manufacturer": "Whatever", "name": "Beer", "model": "Glass", "sw_version": "0.1-beta", }) # full device info with via_device mqtt.MQTT_ENTITY_DEVICE_INFO_SCHEMA({ "identifiers": ["helloworld", "hello"], "connections": [["mac", "02:5b:26:a8:dc:12"], ["zigbee", "zigbee_id"]], "manufacturer": "Whatever", "name": "Beer", "model": "Glass", "sw_version": "0.1-beta", "via_device": "test-hub", }) # no identifiers with pytest.raises(vol.Invalid): mqtt.MQTT_ENTITY_DEVICE_INFO_SCHEMA({ "manufacturer": "Whatever", "name": "Beer", "model": "Glass", "sw_version": "0.1-beta", }) # empty identifiers with pytest.raises(vol.Invalid): mqtt.MQTT_ENTITY_DEVICE_INFO_SCHEMA({ "identifiers": [], "connections": [], "name": "Beer" })