Ejemplo n.º 1
0
def test_link():
    model = PropertyModel()
    settings = [
        "#category",
        {
            "a":
                {
                    "label": "Document",
                    "default": "test",
                },
        },
        {
            "b":
                {
                    "label": "Document",
                    "link": "a",
                }
        },
    ]
    model.load_settings(settings)

    prop_map = model.property_map()
    item_a = prop_map["a"]
    item_b = prop_map["b"]
    assert item_b.value == "test"

    item_a.set_value("test x")
    assert item_b.value == "test x"
    item_b.set_value("test xx")
    assert item_b.value == "test xx"
Ejemplo n.º 2
0
def test_required():
    model = PropertyModel()

    settings = [
        "#category",
        {
            "a": {
                "label": "Document",
                "required": True,
            }
        },
    ]
    model.load_settings(settings)
    assert False is model.is_complete()

    model.property_map()["a"].set_value("test")
    assert True is model.is_complete()
Ejemplo n.º 3
0
def test_load_settings():
    model = PropertyModel()

    # category and basic param
    settings = [
        "#category",
        "a",
        "b",
        "c",
    ]

    model.load_settings(settings)
    assert [u'a', u'b', u'c'] == [x.text() for x in model.properties()]
    model.clear()

    # Detailed parameters
    settings = [
        "#category",
        {
            "a": {
                "label": "Document",
            },
        },
        {
            "b": {
                "label": "Check",
                "value_type": "TypeBool",
                "default": False
            }
        },
    ]
    model.load_settings(settings)

    assert ['Document', 'Check'] == [x.text() for x in model.properties()]
    check_item = model.property_map()["b"]  # type: PropertyItem
    assert TypeBool is check_item.value_type
    assert not check_item.value