def test_check_item_required_fields():  #pylint: disable=W0612
    required_parameters = {
        key: "defaultValue"
        for key, required in config.SCHEMA_ITEM_KEYS.items() if required
    }
    # this shall not trigger an exception
    SchemaItem(**required_parameters)

    for key in required_parameters:
        parameters = deepcopy(required_parameters)
        parameters.pop(key)
        with pytest.raises(exceptions.InvalidProtocolError):
            SchemaItem(**parameters)
Пример #2
0
async def test_item(loop):
    key = "my key"
    label = "my label"
    description = "my description"
    item_type = "boolean"
    item_value = True
    display_order = 2

    item = Item(
        SchemaItem(
            key=key,
            label=label,
            description=description,
            type=item_type,
            displayOrder=display_order,
        ),
        DataItem(key=key, value=item_value),
    )

    assert item.key == key
    assert item.label == label
    assert item.description == description
    assert item.type == item_type
    assert item.value == item_value

    assert item.new_data_cb is None

    assert await item.get() == item_value
Пример #3
0
def create_item(item_type, item_value):
    key = "some key"
    return Item(
        SchemaItem(key=key,
                   label="a label",
                   description="a description",
                   type=item_type,
                   displayOrder=2), DataItem(key=key, value=item_value))
def test_item_construction_default():
    item = SchemaItem(key="a key",
                      label="a label",
                      description="a description",
                      type="a type",
                      displayOrder=2)
    assert item.key == "a key"
    assert item.label == "a label"
    assert item.description == "a description"
    assert item.type == "a type"
    assert item.displayOrder == 2
    assert item.fileToKeyMap == None
    assert item.defaultValue == None
    assert item.widget == None
def create_items_list(key_item_value_tuples):
    schemas = SchemaItemsList({
        key: SchemaItem(
            key=key,
            label="a label",
            description="a description",
            type=item_type,
            displayOrder=2,
        )
        for (key, item_type, _) in key_item_value_tuples
    })
    payloads = DataItemsList({
        key: DataItem(key=key, value=item_value)
        for key, _, item_value in key_item_value_tuples
    })
    return ItemsList(schemas, payloads)
def test_item_construction_with_optional_params():
    item = SchemaItem(key="a key",
                      label="a label",
                      description="a description",
                      type="a type",
                      displayOrder=2,
                      fileToKeyMap={"file1.txt": "a key"},
                      defaultValue="some value",
                      widget={})
    assert item.key == "a key"
    assert item.label == "a label"
    assert item.description == "a description"
    assert item.type == "a type"
    assert item.displayOrder == 2
    assert item.fileToKeyMap == {"file1.txt": "a key"}
    assert item.defaultValue == "some value"
    assert item.widget == {}
def create_item(
    user_id: int,
    project_id: str,
    node_uuid: str,
    item_type: str,
    item_value: DataItemValue,
) -> Item:
    key = "some key"
    return Item(
        user_id,
        project_id,
        node_uuid,
        SchemaItem(
            key=key,
            label="a label",
            description="a description",
            type=item_type,
            displayOrder=2,
        ),
        DataItem(key=key, value=item_value),
    )
def test_default_item():
    with pytest.raises(exceptions.InvalidProtocolError):
        item = SchemaItem()  #pylint: disable=W0612
Пример #9
0
def test_default_item():
    with pytest.raises(exceptions.InvalidProtocolError,
                       message="Expecting InvalidProtocolError"):
        item = SchemaItem()  #pylint: disable=W0612