def test_immutable(schema, composites, context):
    composite_list = list(composites)
    criteria: Dict = {"i_text_in_folder": "I(folder)"}
    the_filter: Filter = HasAnySpecificValues(context, schema, criteria)
    f_iter: InMemoryFilterIterator = InMemoryFilterIterator([the_filter])
    actual: List[Composite] = list(f_iter(composite_list))
    expected: List = [composite_list[3]]
    assert actual == expected
def test_one_temporal(schema, composites, context):
    composite_list = list(composites)
    criteria: Dict = {"t_text_in_root": "bbbb"}
    the_filter: Filter = HasAnySpecificValues(context, schema, criteria)
    f_iter: InMemoryFilterIterator = InMemoryFilterIterator([the_filter])
    actual: List[Composite] = list(f_iter(composite_list))
    expected: List[Composite] = [composite_list[2]]
    del expected[0].content["period_2"]
    assert actual == expected
def test_two_temporal_match_same(schema, composites, context):
    composite_list = list(composites)
    criteria: Dict = {"t_text_in_folder": "aaaa", "t_text_in_root": "bbbb"}
    the_filter: Filter = HasAnySpecificValues(context,
                                              schema,
                                              criteria,
                                              narrows=False)
    f_iter: InMemoryFilterIterator = InMemoryFilterIterator([the_filter])
    actual: List[Composite] = list(f_iter(composite_list))
    expected: List = [composite_list[2]]
    assert actual == expected
def test_one_temporal(schema, composites, context):
    composite_list = list(composites)
    criteria: Dict = {"t_text_in_root": "bbbb"}
    the_filter: Filter = HasAnySpecificValues(context,
                                              schema,
                                              criteria,
                                              filters=False)
    expected: List[Composite] = make_c3_expected(composite_list)
    f_iter: InMemoryFilterIterator = InMemoryFilterIterator([the_filter])
    actual: List[Composite] = list(f_iter(composite_list))
    assert actual == expected
def test_no_narrow(schema, composites, context):
    composite_list = list(composites)
    expected: Dict = copy.deepcopy(composite_list[2].content)
    criteria: Dict = {"t_text_in_root": "bbbb"}
    the_filter: Filter = HasAnySpecificValues(context,
                                              schema,
                                              criteria,
                                              narrows=False)
    f_iter: InMemoryFilterIterator = InMemoryFilterIterator([the_filter])
    outcome: List[Composite] = list(f_iter(composite_list))
    actual: Dict = outcome[0].content
    assert actual == expected
def test_t_and_i_immutable_wrong(schema, composites, context):
    composite_list = list(composites)
    criteria: Dict = {
        "i_text_in_folder": "Not a real value",
        "t_text_in_folder": "P1(folder)"
    }
    the_filter: Filter = HasAnySpecificValues(context, schema, criteria)
    f_iter: InMemoryFilterIterator = InMemoryFilterIterator([the_filter])
    actual: List[Composite] = list(f_iter(composite_list))
    expected: List = [composite_list[3]]
    del expected[0].content["period_2"]
    assert actual == expected
def test_two_temporal_match_different(schema, composites, context):
    composite_list = list(composites)
    criteria: Dict = {
        "t_text_in_folder": "in a folder",
        "t_text_in_root": "bbbb"
    }
    the_filter: Filter = HasAnySpecificValues(context, schema, criteria)
    f_iter: InMemoryFilterIterator = InMemoryFilterIterator([the_filter])
    expected: List = [composite_list[0], composite_list[2]]
    del expected[1].content["period_2"]
    actual: List[Composite] = list(f_iter(composite_list))
    assert actual == expected
def test_temporal_and_immutable_match(schema, composites, context):
    composite_list = list(composites)
    criteria: Dict = {
        "i_text_in_folder": "lorem",
        "t_text_in_folder": "P1(folder)"
    }
    the_filter: Filter = HasAnySpecificValues(context,
                                              schema,
                                              criteria,
                                              narrows=False)
    f_iter: InMemoryFilterIterator = InMemoryFilterIterator([the_filter])
    actual: List[Composite] = list(f_iter(composite_list))
    expected: List = [composite_list[0], composite_list[3]]
    assert actual == expected
def test_t_and_i_temporal_wrong(schema, composites, context):
    composite_list = list(composites)
    criteria: Dict = {
        "i_text_in_folder": "I(folder)",
        "t_text_in_folder": "Not a real value"
    }
    the_filter: Filter = HasAnySpecificValues(context,
                                              schema,
                                              criteria,
                                              narrows=False)
    f_iter: InMemoryFilterIterator = InMemoryFilterIterator([the_filter])
    actual: List[Composite] = list(f_iter(composite_list))
    expected: List = [composite_list[3]]
    assert actual == expected
def test_t_and_i_temporal_wrong(schema, composites, context):
    composite_list = list(composites)
    criteria: Dict = {
        "i_text_in_folder": "I(folder)",
        "t_text_in_folder": "Not a real value"
    }
    the_filter: Filter = HasAnySpecificValues(context,
                                              schema,
                                              criteria,
                                              filters=False)
    f_iter: InMemoryFilterIterator = InMemoryFilterIterator([the_filter])
    expected: List[Composite] = [copy.copy(c) for c in composite_list]
    for composite in expected[:-1]:
        for period in composite.periods:
            del composite.content[period]
    actual: List[Composite] = list(f_iter(composite_list))
    assert actual == expected
def test_temporal_and_immutable(schema, composites, context):
    composite_list = list(composites)
    criteria: Dict = {
        "i_text_in_folder": "lorem",
        "t_text_in_folder": "P1(folder)"
    }
    the_filter: Filter = HasAnySpecificValues(context,
                                              schema,
                                              criteria,
                                              filters=False)
    f_iter: InMemoryFilterIterator = InMemoryFilterIterator([the_filter])
    actual: List[Composite] = list(f_iter(composite_list))

    expected: List[Composite] = [copy.copy(c) for c in composite_list]
    del expected[2].content["period_1"]
    del expected[2].content["period_2"]
    del expected[3].content["period_2"]
    assert actual == expected
def test_immutable(schema, composites, context):
    composite_list = list(composites)
    criteria: Dict = {"i_text_in_folder": "I(folder)"}
    the_filter: Filter = HasAnySpecificValues(context,
                                              schema,
                                              criteria,
                                              filters=False)
    f_iter: InMemoryFilterIterator = InMemoryFilterIterator([the_filter])

    # Because the only criterion is an immutable variable, it applies to all periods; consequently, all periods are
    # retained for Composite 4.
    expected: List[Composite] = [copy.copy(c) for c in composite_list]
    del expected[0].content["period_1"]
    del expected[2].content["period_1"]
    del expected[2].content["period_2"]

    actual: List[Composite] = list(f_iter(composite_list))
    assert actual == expected