Beispiel #1
0
def test_to_hap(mock_driver):
    bridge = Bridge(mock_driver, "Test Bridge")
    acc = Accessory(mock_driver, "Test Accessory", aid=2)
    assert acc.available is True
    bridge.add_accessory(acc)

    assert bridge.to_HAP() == [
        {
            "aid": 1,
            "services": [
                {
                    "iid": 1,
                    "type": "0000003E-0000-1000-8000-0026BB765291",
                    "characteristics": [
                        {
                            "iid": 2,
                            "type": "00000014-0000-1000-8000-0026BB765291",
                            "description": "Identify",
                            "perms": ["pw"],
                            "format": "bool",
                        },
                        {
                            "iid": 3,
                            "type": "00000020-0000-1000-8000-0026BB765291",
                            "description": "Manufacturer",
                            "perms": ["pr"],
                            "format": "string",
                            "value": "",
                        },
                        {
                            "iid": 4,
                            "type": "00000021-0000-1000-8000-0026BB765291",
                            "description": "Model",
                            "perms": ["pr"],
                            "format": "string",
                            "value": "",
                        },
                        {
                            "iid": 5,
                            "type": "00000023-0000-1000-8000-0026BB765291",
                            "description": "Name",
                            "perms": ["pr"],
                            "format": "string",
                            "value": "Test Bridge",
                        },
                        {
                            "iid": 6,
                            "type": "00000030-0000-1000-8000-0026BB765291",
                            "description": "SerialNumber",
                            "perms": ["pr"],
                            "format": "string",
                            "value": "default",
                        },
                        {
                            "iid": 7,
                            "type": "00000052-0000-1000-8000-0026BB765291",
                            "description": "FirmwareRevision",
                            "perms": ["pr"],
                            "format": "string",
                            "value": "",
                        },
                    ],
                }
            ],
        },
        {
            "aid": 2,
            "services": [
                {
                    "iid": 1,
                    "type": "0000003E-0000-1000-8000-0026BB765291",
                    "characteristics": [
                        {
                            "iid": 2,
                            "type": "00000014-0000-1000-8000-0026BB765291",
                            "description": "Identify",
                            "perms": ["pw"],
                            "format": "bool",
                        },
                        {
                            "iid": 3,
                            "type": "00000020-0000-1000-8000-0026BB765291",
                            "description": "Manufacturer",
                            "perms": ["pr"],
                            "format": "string",
                            "value": "",
                        },
                        {
                            "iid": 4,
                            "type": "00000021-0000-1000-8000-0026BB765291",
                            "description": "Model",
                            "perms": ["pr"],
                            "format": "string",
                            "value": "",
                        },
                        {
                            "iid": 5,
                            "type": "00000023-0000-1000-8000-0026BB765291",
                            "description": "Name",
                            "perms": ["pr"],
                            "format": "string",
                            "value": "Test Accessory",
                        },
                        {
                            "iid": 6,
                            "type": "00000030-0000-1000-8000-0026BB765291",
                            "description": "SerialNumber",
                            "perms": ["pr"],
                            "format": "string",
                            "value": "default",
                        },
                        {
                            "iid": 7,
                            "type": "00000052-0000-1000-8000-0026BB765291",
                            "description": "FirmwareRevision",
                            "perms": ["pr"],
                            "format": "string",
                            "value": "",
                        },
                    ],
                }
            ],
        },
    ]
    assert acc.to_HAP() == {
        "aid": 2,
        "services": [
            {
                "iid": 1,
                "type": "0000003E-0000-1000-8000-0026BB765291",
                "characteristics": [
                    {
                        "iid": 2,
                        "type": "00000014-0000-1000-8000-0026BB765291",
                        "description": "Identify",
                        "perms": ["pw"],
                        "format": "bool",
                    },
                    {
                        "iid": 3,
                        "type": "00000020-0000-1000-8000-0026BB765291",
                        "description": "Manufacturer",
                        "perms": ["pr"],
                        "format": "string",
                        "value": "",
                    },
                    {
                        "iid": 4,
                        "type": "00000021-0000-1000-8000-0026BB765291",
                        "description": "Model",
                        "perms": ["pr"],
                        "format": "string",
                        "value": "",
                    },
                    {
                        "iid": 5,
                        "type": "00000023-0000-1000-8000-0026BB765291",
                        "description": "Name",
                        "perms": ["pr"],
                        "format": "string",
                        "value": "Test Accessory",
                    },
                    {
                        "iid": 6,
                        "type": "00000030-0000-1000-8000-0026BB765291",
                        "description": "SerialNumber",
                        "perms": ["pr"],
                        "format": "string",
                        "value": "default",
                    },
                    {
                        "iid": 7,
                        "type": "00000052-0000-1000-8000-0026BB765291",
                        "description": "FirmwareRevision",
                        "perms": ["pr"],
                        "format": "string",
                        "value": "",
                    },
                ],
            }
        ],
    }
Beispiel #2
0
def test_to_hap(mock_driver):
    bridge = Bridge(mock_driver, "Test Bridge")
    acc = Accessory(mock_driver, "Test Accessory", aid=2)
    assert acc.available is True
    bridge.add_accessory(acc)

    assert bridge.to_HAP() == [
        {
            "aid":
            1,
            "services": [{
                "characteristics": [
                    {
                        "format": "bool",
                        "iid": 2,
                        "perms": ["pw"],
                        "type": "14",
                    },
                    {
                        "format": "string",
                        "iid": 3,
                        "perms": ["pr"],
                        "type": "20",
                        "value": "",
                    },
                    {
                        "format": "string",
                        "iid": 4,
                        "perms": ["pr"],
                        "type": "21",
                        "value": "",
                    },
                    {
                        "format": "string",
                        "iid": 5,
                        "perms": ["pr"],
                        "type": "23",
                        "value": "Test Bridge",
                    },
                    {
                        "format": "string",
                        "iid": 6,
                        "perms": ["pr"],
                        "type": "30",
                        "value": "default",
                    },
                    {
                        "format": "string",
                        "iid": 7,
                        "perms": ["pr"],
                        "type": "52",
                        "value": "",
                    },
                ],
                "iid":
                1,
                "type":
                "3E",
            }],
        },
        {
            "aid":
            2,
            "services": [{
                "characteristics": [
                    {
                        "format": "bool",
                        "iid": 2,
                        "perms": ["pw"],
                        "type": "14",
                    },
                    {
                        "format": "string",
                        "iid": 3,
                        "perms": ["pr"],
                        "type": "20",
                        "value": "",
                    },
                    {
                        "format": "string",
                        "iid": 4,
                        "perms": ["pr"],
                        "type": "21",
                        "value": "",
                    },
                    {
                        "format": "string",
                        "iid": 5,
                        "perms": ["pr"],
                        "type": "23",
                        "value": "Test Accessory",
                    },
                    {
                        "format": "string",
                        "iid": 6,
                        "perms": ["pr"],
                        "type": "30",
                        "value": "default",
                    },
                    {
                        "format": "string",
                        "iid": 7,
                        "perms": ["pr"],
                        "type": "52",
                        "value": "",
                    },
                ],
                "iid":
                1,
                "type":
                "3E",
            }],
        },
    ]
    assert acc.to_HAP() == {
        "aid":
        2,
        "services": [{
            "characteristics": [
                {
                    "format": "bool",
                    "iid": 2,
                    "perms": ["pw"],
                    "type": "14",
                },
                {
                    "format": "string",
                    "iid": 3,
                    "perms": ["pr"],
                    "type": "20",
                    "value": "",
                },
                {
                    "format": "string",
                    "iid": 4,
                    "perms": ["pr"],
                    "type": "21",
                    "value": "",
                },
                {
                    "format": "string",
                    "iid": 5,
                    "perms": ["pr"],
                    "type": "23",
                    "value": "Test Accessory",
                },
                {
                    "format": "string",
                    "iid": 6,
                    "perms": ["pr"],
                    "type": "30",
                    "value": "default",
                },
                {
                    "format": "string",
                    "iid": 7,
                    "perms": ["pr"],
                    "type": "52",
                    "value": "",
                },
            ],
            "iid":
            1,
            "type":
            "3E",
        }],
    }
    bridge.get_characteristic(2, 2).display_name = "Custom Name Identify"
    assert acc.to_HAP() == {
        "aid":
        2,
        "services": [{
            "characteristics": [
                {
                    "description": "Custom Name Identify",
                    "format": "bool",
                    "iid": 2,
                    "perms": ["pw"],
                    "type": "14",
                },
                {
                    "format": "string",
                    "iid": 3,
                    "perms": ["pr"],
                    "type": "20",
                    "value": "",
                },
                {
                    "format": "string",
                    "iid": 4,
                    "perms": ["pr"],
                    "type": "21",
                    "value": "",
                },
                {
                    "format": "string",
                    "iid": 5,
                    "perms": ["pr"],
                    "type": "23",
                    "value": "Test Accessory",
                },
                {
                    "format": "string",
                    "iid": 6,
                    "perms": ["pr"],
                    "type": "30",
                    "value": "default",
                },
                {
                    "format": "string",
                    "iid": 7,
                    "perms": ["pr"],
                    "type": "52",
                    "value": "",
                },
            ],
            "iid":
            1,
            "type":
            "3E",
        }],
    }