Exemple #1
0
def test_ui_simple_schema(coresys):
    """Test with simple schema."""
    assert UiOptions(coresys)({
        "name": "str",
        "password": "******",
        "fires": "bool",
        "alias": "str?"
    }, ) == [
        {
            "name": "name",
            "required": True,
            "type": "string"
        },
        {
            "format": "password",
            "name": "password",
            "required": True,
            "type": "string"
        },
        {
            "name": "fires",
            "required": True,
            "type": "boolean"
        },
        {
            "name": "alias",
            "optional": True,
            "type": "string"
        },
    ]
Exemple #2
0
def test_ui_simple_device_schema_no_filter(coresys):
    """Test with simple schema without filter."""
    for device in (
            Device(
                "ttyACM0",
                Path("/dev/ttyACM0"),
                Path("/sys/bus/usb/002"),
                "tty",
                None,
                [],
                {"ID_VENDOR": "xy"},
                [],
            ),
            Device(
                "ttyUSB0",
                Path("/dev/ttyUSB0"),
                Path("/sys/bus/usb/001"),
                "tty",
                None,
                [Path("/dev/ttyS1"),
                 Path("/dev/serial/by-id/xyx")],
                {"ID_VENDOR": "xy"},
                [],
            ),
            Device(
                "ttyS0",
                Path("/dev/ttyS0"),
                Path("/sys/bus/usb/003"),
                "tty",
                None,
                [],
                {},
                [],
            ),
            Device(
                "video1",
                Path("/dev/video1"),
                Path("/sys/bus/usb/004"),
                "misc",
                None,
                [],
                {"ID_VENDOR": "xy"},
                [],
            ),
    ):
        coresys.hardware.update_device(device)

    data = UiOptions(coresys)({
        "name": "str",
        "password": "******",
        "fires": "bool",
        "alias": "str?",
        "input": "device",
    }, )

    assert sorted(data[-1]["options"]) == sorted(
        ["/dev/serial/by-id/xyx", "/dev/ttyACM0", "/dev/ttyS0", "/dev/video1"])
    assert data[-1]["type"] == "select"
Exemple #3
0
def test_ui_group_list_schema(coresys):
    """Test with group schema."""
    assert UiOptions(coresys)(
        {
            "name": "str",
            "password": "******",
            "fires": "bool",
            "alias": "str?",
            "extended": [{
                "name": "str",
                "data": ["str?"],
                "path": "str?"
            }],
        }, ) == [
            {
                "name": "name",
                "required": True,
                "type": "string"
            },
            {
                "format": "password",
                "name": "password",
                "required": True,
                "type": "string"
            },
            {
                "name": "fires",
                "required": True,
                "type": "boolean"
            },
            {
                "name": "alias",
                "optional": True,
                "type": "string"
            },
            {
                "multiple":
                True,
                "name":
                "extended",
                "optional":
                True,
                "schema": [
                    {
                        "name": "name",
                        "required": True,
                        "type": "string"
                    },
                    {
                        "multiple": True,
                        "name": "data",
                        "optional": True,
                        "type": "string"
                    },
                    {
                        "name": "path",
                        "optional": True,
                        "type": "string"
                    },
                ],
                "type":
                "schema",
            },
        ]