Beispiel #1
0
def test_property_child(under_test_read_write: PropertyWrapper,
                        default_property_base, context_mock):
    assert under_test_read_write.push(
        Property(name=CHILD_PROPERTY_NAME,
                 default_value=DEFAULT_PROPERTY_VALUE))
    assert list(under_test_read_write.enum())[0] == CHILD_PROPERTY_ID
    assert under_test_read_write.prop.children[CHILD_PROPERTY_NAME].read(
    ) == DEFAULT_PROPERTY_VALUE
Beispiel #2
0
def test_property_illegal_push(context_mock):
    prop_no_push = Property(name=DEFAULT_PROPERTY_NAME,
                            default_value=DEFAULT_PROPERTY_VALUE,
                            allow_push=False)
    prop_no_push.set_parent_path(DEFAULT_MODULE_NAME)
    wrapper = PropertyWrapper(prop=prop_no_push,
                              ctx=context_mock,
                              allow_read=True,
                              allow_write=True)
    with LogCapture(attributes=strip_prefix) as log_capture:
        assert not wrapper.push(child=Property(name=CHILD_PROPERTY_NAME))
        log_capture.check(
            f'Unauthorized push in property {DEFAULT_MODULE_NAME}:{DEFAULT_PROPERTY_NAME}!',
        )