Esempio n. 1
0
def test_input_equals_output(resource_client, input_model, output_model):
    pruned_input_model = prune_properties_from_model(
        input_model.copy(), resource_client.write_only_paths)

    pruned_output_model = prune_properties_if_not_exist_in_path(
        output_model.copy(), pruned_input_model,
        resource_client.read_only_paths)

    pruned_output_model = prune_properties_if_not_exist_in_path(
        pruned_output_model, pruned_input_model,
        resource_client.create_only_paths)

    assertion_error_message = (
        "All properties specified in the request MUST "
        "be present in the model returned, and they MUST"
        " match exactly, with the exception of properties"
        " defined as writeOnlyProperties in the resource schema")
    # only comparing properties in input model to those in output model and
    # ignoring extraneous properties that maybe present in output model.
    try:
        for key in pruned_input_model:
            if key in resource_client.properties_without_insertion_order:
                assert test_unordered_list_match(pruned_input_model[key],
                                                 pruned_output_model[key])
            else:
                assert (pruned_input_model[key] == pruned_output_model[key]
                        ), assertion_error_message
    except KeyError as e:
        raise AssertionError(assertion_error_message) from e
def test_input_equals_output(resource_client, input_model, output_model):
    pruned_input_model = prune_properties_from_model(
        input_model.copy(), resource_client.write_only_paths)

    pruned_output_model = prune_properties_if_not_exist_in_path(
        output_model.copy(), pruned_input_model,
        resource_client.read_only_paths)
    pruned_output_model = prune_properties_if_not_exist_in_path(
        pruned_output_model, pruned_input_model,
        resource_client.create_only_paths)

    assert pruned_input_model == pruned_output_model
Esempio n. 3
0
def test_input_equals_output(resource_client, input_model, output_model):
    pruned_input_model = prune_properties_from_model(
        copy.deepcopy(input_model),
        set(
            list(resource_client.read_only_paths) +
            list(resource_client.write_only_paths)),
    )

    pruned_output_model = prune_properties_from_model(
        copy.deepcopy(output_model), resource_client.read_only_paths)

    pruned_output_model = prune_properties_if_not_exist_in_path(
        pruned_output_model, pruned_input_model,
        resource_client.create_only_paths)
    resource_client.compare(
        pruned_input_model,
        pruned_output_model,
    )
Esempio n. 4
0
def test_prune_properties_if_not_exist_in_path():
    previous_model = {
        "spam": "eggs",
        "one": "two",
        "array": ["first", "second"],
    }
    model = {
        "foo": "bar",
        "spam": "eggs",
        "one": "two",
        "array": ["first", "second"],
    }
    model = prune_properties_if_not_exist_in_path(
        model,
        previous_model,
        [
            ("properties", "foo"),
            ("properties", "spam"),
            ("properties", "array", "1"),
            ("properties", "invalid"),
        ],
    )
    assert model == previous_model