Exemplo n.º 1
0
def parse_args(args):
    data = {}
    for arg in args:
        key, value = arg.split("=")
        pointer = Pointer(value)
        pointer.resolve_labels(key)
        data[key] = pointer.get({})
    return data
Exemplo n.º 2
0
def test_pointer_should_return_default_value_for_none_value(patch_schema):
    patch_schema(
        {'a_key': {
            'type': 'integer',
            'label': 'a label',
            'default': 123
        }})
    lv = Pointer('a label')
    assert lv.get(Context({'wrong': None})) == 123
Exemplo n.º 3
0
def then_check_output(context, label, value):
    value = Pointer(value).get({})
    key = remove_namespace(LABELS[label])
    assert context.result[key] == value, (f'key = {key} '
                                          f'label = {LABELS[label]}'
                                          f'{context.result[key]} '
                                          f'({type(context.result[key])}) != '
                                          f'{value} ({type(value)})')
Exemplo n.º 4
0
def then_check_output(context, label, value):
    value = Pointer(value).get({})
    if (LABELS[label].startswith("financement")):
        key = LABELS[label][12:]  # Remove "financement." namespace.
    if (LABELS[label].startswith("remuneration")):
        key = LABELS[label][13:]  # Remove "remuneration." namespace.
    assert context.result[key] == value, (f'key = {key} '
                                          f'label = {LABELS[label]}'
                                          f'{context.result[key]} '
                                          f'({type(context.result[key])}) != '
                                          f'{value} ({type(value)})')
Exemplo n.º 5
0
def test_pointer_with_string_constant(patch_schema):
    patch_schema({})  # Make sure we have no labels.
    lv = Pointer('«CDI»')
    assert lv.get({}) == 'CDI'
Exemplo n.º 6
0
def test_pointer_raises_with_invalid_pointer():
    with pytest.raises(WrongPointerError):
        Pointer('invalid pointer')
Exemplo n.º 7
0
def test_pointer_with_bool_variable(patch_schema):
    patch_schema({'a_key': {'type': 'boolean', 'label': 'a label'}})
    lv = Pointer('a label')
    assert lv.get({'a_key': True}) is True
Exemplo n.º 8
0
def test_pointer_with_int_variable(patch_schema):
    patch_schema({'a_key': {'type': 'integer', 'label': 'a label'}})
    lv = Pointer('a label')
    assert lv.get({'a_key': 27}) == 27
Exemplo n.º 9
0
def test_pointer_with_float_constant():
    lv = Pointer('27.45')
    assert lv.get({}) == 27.45
Exemplo n.º 10
0
def test_pointer_with_int_constant():
    lv = Pointer('18')
    assert lv.get({}) == 18
Exemplo n.º 11
0
def given_set_value(context, label, value):
    key = LABELS[label]
    pointer = Pointer(value)
    pointer.resolve_labels(key)
    context.data[key] = pointer.get({})