Example #1
0
def test_filter_allows_correctly():
    """Tests if the filter allows appropriate items correctly"""
    sample_item = {"name": "me"}

    result = make_filter(name="me").apply([sample_item])

    assert result == [sample_item]
Example #2
0
def test_filter_handle_empty_keys():
    """Tests if the filter is capable to process items with no matching keys"""
    sample_item = {"name": "me"}

    result = make_filter(name="me", age=21).apply([sample_item])

    assert result == []
def test_make_filter_0_expected():
    filter_obj = make_filter(k1="v1", k2="v2")
    result = filter_obj.apply(
        [
            {"k1": "v1", "k2": "v3"},
            {"k1": "v1", "k2": "v3", "k3": "v3"},
        ]
    )
    expected_value = []
    assert result == expected_value
def test_make_filter_first_func_created_correctly():
    sample_data = [
        {
            "name": "Bill",
            "last_name": "Gilbert",
            "occupation": "was here",
            "type": "person",
        },
        {"is_dead": True, "kind": "parrot", "type": "bird", "name": "polly"},
        {"is_dead": True, "kind": "parrot", "type": "bird", "name": "billy"},
    ]

    result = make_filter(name="billy", type="bird").apply(sample_data)

    expected_value = [
        {"is_dead": True, "kind": "parrot", "type": "bird", "name": "billy"}
    ]

    assert result == expected_value
def test_make_filter_when_data_has_only_part_of_filtering_keys():
    filter_obj = make_filter(k1="v1", k100="v200")
    assert filter_obj.apply([{"k1": "v1", "k4": "v4"}]) == []
def test_make_filter_when_data_has_not_filtering_keys():
    filter_obj = make_filter(k200="v200", k100="v100")
    assert filter_obj.apply([{"k1": "v1", "k2": "v2"}]) == []