コード例 #1
0
ファイル: json.py プロジェクト: 1service/zato-apitest
def assert_value(ctx, path, value, wrapper=None):
    if 'data_impl' not in ctx.zato.response:
        raise ValueError('Assertion called but no format set')

    value = wrapper(value) if wrapper else value
    actual = get_pointer(ctx.zato.response.data_impl, path)
    assert_equals(value, actual)
    return True
コード例 #2
0
ファイル: json.py プロジェクト: damianignacio/zato-apitest
def assert_value(ctx, path, value, wrapper=None):
    if 'data_impl' not in ctx.zato.response:
        raise ValueError('Assertion called but no format set')

    value = wrapper(value) if wrapper else value
    actual = get_pointer(ctx.zato.response.data_impl, path)
    assert_equals(value, actual)
    return True
コード例 #3
0
ファイル: json.py プロジェクト: zatosource/zato-apitest
def _then_json_pointer_contains(ctx, path, expected):
    actual_list = get_pointer(ctx.zato.response.data_impl, path)

    for item in actual_list:
        try:
            assert_equals(item, expected)
        except AssertionError:
            pass
        else:
            return True
    else:
        raise AssertionError('Expected data `{}` not in `{}`'.format(expected, actual_list))
コード例 #4
0
ファイル: json.py プロジェクト: websvcPT/zato-apitest
def _then_json_pointer_contains(ctx, path, expected):
    actual_list = get_pointer(ctx.zato.response.data_impl, path)

    for item in actual_list:
        try:
            assert_equals(item, expected)
        except AssertionError:
            pass
        else:
            return True
    else:
        raise AssertionError('Expected data `{}` not in `{}`'.format(
            expected, actual_list))
コード例 #5
0
def then_store_path_under_name_with_default(ctx, path, name, default):
    if ctx.zato.request.is_xml:
        value = ctx.zato.response.data_impl.xpath(path)
        if value:
            if len(value) == 1:
                value = value[0].text
            else:
                value = [elem.text for elem in value]
        else:
            if default == NO_VALUE:
                raise ValueError('No such path `{}`'.format(path))
            else:
                value = default
    else:
        value = get_pointer(ctx.zato.response.data_impl, path, default)
        if value == NO_VALUE:
            raise ValueError('No such path `{}`'.format(path))

    ctx.zato.user_ctx[name] = value
コード例 #6
0
ファイル: common.py プロジェクト: rogeriofalcone/zato-apitest
def then_store_path_under_name_with_default(ctx, path, name, default):
    if ctx.zato.request.is_xml:
        value = ctx.zato.response.data_impl.xpath(path)
        if value:
            if len(value) == 1:
                value = value[0].text
            else:
                value = [elem.text for elem in value]
        else:
            if default == NO_VALUE:
                raise ValueError('No such path `{}`'.format(path))
            else:
                value = default
    else:
        value = get_pointer(ctx.zato.response.data_impl, path, default)
        if value == NO_VALUE:
            raise ValueError('No such path `{}`'.format(path))

    ctx.zato.user_ctx[name] = value
コード例 #7
0
ファイル: json.py プロジェクト: damianignacio/zato-apitest
def then_json_pointer_isnt_empty(ctx, path):
    actual = get_pointer(ctx.zato.response.data_impl, path, INVALID)
    assert actual != INVALID, 'Path `{}` Should not be empty'.format(path)
コード例 #8
0
ファイル: json.py プロジェクト: damianignacio/zato-apitest
def then_json_pointer_isnt_one_of(ctx, path, value):
    actual = get_pointer(ctx.zato.response.data_impl, path)
    value = util.parse_list(value)
    assert actual not in value, 'Expected for `{}` ({}) not to be in `{}`'.format(actual, path, value)
コード例 #9
0
ファイル: json.py プロジェクト: 1service/zato-apitest
def then_json_pointer_isnt_a_string(ctx, path, value):
    actual = get_pointer(ctx.zato.response.data_impl, path)
    assert actual != value, 'Expected `{}` != `{}`'.format(actual, value)
コード例 #10
0
ファイル: steps.py プロジェクト: grenzi/ctakes_exploration
def then_json_pointer_is_a_base64_object(ctx, path, path2, value):
    actual = get_pointer(ctx.zato.response.data_impl, path)
    decoded_value = json.loads(base64.b64decode(actual))
    actual = get_pointer(decoded_value, path2)

    return assert_equals(actual, value)
コード例 #11
0
ファイル: json.py プロジェクト: 1service/zato-apitest
def then_json_pointer_isnt_one_of(ctx, path, value):
    actual = get_pointer(ctx.zato.response.data_impl, path)
    value = util.parse_list(value)
    assert actual not in value, 'Expected for `{}` ({}) not to be in `{}`'.format(
        actual, path, value)
コード例 #12
0
ファイル: json.py プロジェクト: 1service/zato-apitest
def then_json_pointer_is_a_base32_crockford(ctx, path, checksum):
    actual = get_pointer(ctx.zato.response.data_impl, path)
    crockford_decode(actual.replace('-', ''), checksum.lower() == 'true')
コード例 #13
0
ファイル: json.py プロジェクト: 1service/zato-apitest
def then_json_pointer_is_any_float(ctx, path):
    actual = get_pointer(ctx.zato.response.data_impl, path)
    assert isinstance(actual, float), \
        'Expected a float in {}, got a `{}`'.format(path, type(actual))
    return True
コード例 #14
0
ファイル: json.py プロジェクト: universsky/zato-apitest
def then_json_pointer_is_any_float(ctx, path):
    actual = get_pointer(ctx.zato.response.data_impl, path)
    assert isinstance(actual, float), "Expected a float in {}, got a `{}`".format(path, type(actual))
    return True
コード例 #15
0
def then_json_pointer_is_boolean_true(ctx, path):
    actual = get_pointer(ctx.zato.response.data_impl, path, [])
    assert isinstance(actual, list), 'Path `{}` should be a list'.format(path)
    assert actual, 'Path `{}` should not be an empty list'.format(path)
コード例 #16
0
ファイル: steps.py プロジェクト: grenzi/ctakes_exploration
def then_json_pointer_isnt_an_empty_list(ctx, path):
    actual = get_pointer(ctx.zato.response.data_impl, path)
    assert actual != [], 'Value `{}`, is an empty list'.format(actual)
コード例 #17
0
def then_json_pointer_isnt_an_empty_list(ctx, path):
    actual = get_pointer(ctx.zato.response.data_impl, path)
    assert actual != [], 'Value `{}`, is an empty list'.format(actual)
コード例 #18
0
def then_json_pointer_is_a_base64_object(ctx, path, path2, value):
    actual = get_pointer(ctx.zato.response.data_impl, path)
    decoded_value = json.loads(base64.b64decode(actual))
    actual = get_pointer(decoded_value, path2)

    return assert_equals(actual, value)
コード例 #19
0
ファイル: json.py プロジェクト: universsky/zato-apitest
def then_json_pointer_isnt_a_string(ctx, path, value):
    actual = get_pointer(ctx.zato.response.data_impl, path)
    assert actual != value, "Expected `{}` != `{}`".format(actual, value)
コード例 #20
0
ファイル: json.py プロジェクト: damianignacio/zato-apitest
def then_json_pointer_is_a_base32_crockford(ctx, path, checksum):
    actual = get_pointer(ctx.zato.response.data_impl, path)
    crockford_decode(actual.replace('-', ''), checksum.lower() == 'true')
コード例 #21
0
ファイル: json.py プロジェクト: 1service/zato-apitest
def then_json_pointer_isnt_empty(ctx, path):
    actual = get_pointer(ctx.zato.response.data_impl, path, INVALID)
    assert actual != INVALID, 'Path `{}` Should not be empty'.format(path)
コード例 #22
0
ファイル: json.py プロジェクト: zatosource/zato-apitest
def then_json_pointer_is_boolean_true(ctx, path):
    actual = get_pointer(ctx.zato.response.data_impl, path, [])
    assert isinstance(actual, list), 'Path `{}` should be a list'.format(path)
    assert actual, 'Path `{}` should not be an empty list'.format(path)
コード例 #23
0
ファイル: json.py プロジェクト: Cito/zato-apitest
def then_json_pointer_is_any_integer(ctx, path):
    actual = get_pointer(ctx.zato.response.data_impl, path)
    assert isinstance(actual, int_types), \
        'Expected an integer in {}, got a `{}`'.format(path, type(actual))
    return True