Exemplo n.º 1
0
def run_schema_checks():

    print("\nStarting schema tests")
    print("---------------------\n")
    pattern_results = _.every(
        get_obj_by_path(get_test_data(), "test_patterns"), verify_pattern)

    print("\nSchema pattern tests passed: %s\n" % pattern_results)

    full_payload_tests = get_obj_by_path(get_test_data(), "test_payloads")

    payload_results = _.every(full_payload_tests, verify_against_schema)
    print("\nPayload tests passed: %s" % payload_results)

    return pattern_results and payload_results
Exemplo n.º 2
0
def run_schema_checks():

    print("\nStarting schema tests")
    print("---------------------\n")
    pattern_results = _.every(
        get_obj_by_path(get_test_data(), "test_patterns"),
        verify_pattern)

    print("\nSchema pattern tests passed: %s\n" % pattern_results)

    full_payload_tests = get_obj_by_path(get_test_data(), "test_payloads")

    payload_results = _.every(full_payload_tests, verify_against_schema)
    print("\nPayload tests passed: %s" % payload_results)

    return pattern_results and payload_results
Exemplo n.º 3
0
def verify_pattern(element, key, obj, idx):
    print("Checking patterns for '%s'" % key)
    pattern_path = str("test_patterns/" + key)
    path_to_pattern_in_schema = get_obj_by_path(get_test_data(),
                                                pattern_path + "/pattern_path")
    obj_in_schema = get_obj_by_path(get_schema(), path_to_pattern_in_schema)
    pattern = obj_in_schema["pattern"] if "pattern" in obj_in_schema else None
    enum = obj_in_schema["enum"] if "enum" in obj_in_schema else None
    test_payloads = get_obj_by_path(get_test_data(),
                                    pattern_path + "/payload_tests")

    # we need to merge in pattern and enum data from parent context
    # unfortunately, functional library does not support passing in
    #  context data
    for i, test in enumerate(test_payloads):
        test["pattern"] = pattern if not enum else "(" + ")|(".join(enum) + ")"

    return _.every(test_payloads, is_valid_regex)
Exemplo n.º 4
0
def verify_pattern(element, key, obj, idx):
    print("Checking patterns for '%s'" % key)
    pattern_path = str("test_patterns/"+key)
    path_to_pattern_in_schema = get_obj_by_path(get_test_data(),
                                                pattern_path + "/pattern_path")
    obj_in_schema = get_obj_by_path(get_schema(),
                                    path_to_pattern_in_schema)
    pattern = obj_in_schema["pattern"] if "pattern" in obj_in_schema else None
    enum = obj_in_schema["enum"] if "enum" in obj_in_schema else None
    test_payloads = get_obj_by_path(get_test_data(),
                                    pattern_path + "/payload_tests")

    # we need to merge in pattern and enum data from parent context
    # unfortunately, functional library does not support passing in
    #  context data
    for i, test in enumerate(test_payloads):
        test["pattern"] = pattern if not enum else "(" + ")|(".join(enum) + ")"

    return _.every(test_payloads, is_valid_regex)