def test_sources(schema, composite, sources, expected_target):
    change: Change = BestAvailableV2(schema, {}, target, sources)
    expected: Dict = copy.deepcopy(composite.content)
    if expected_target is not None:
        expected["immutable"]["target"] = expected_target
    change(composite)
    assert composite.content == expected
Example #2
0
 def __post_init__(self) -> None:
     sources = []
     if self.immutable_source is not None:
         sources.append(self.immutable_source)
     sources.append(self.temporal_source)
     self.bestAvailableV2 = BestAvailableV2(self.schema, self.lookups,
                                            self.target, sources,
                                            not self.use_older_periods)
def test_sources_no_immutable_values(schema, composite, sources,
                                     expected_target):
    change: Change = BestAvailableV2(schema, {}, target, sources)
    del composite.content["immutable"]
    expected: Dict = copy.deepcopy(composite.content)
    if expected_target is not None:
        expected.setdefault("immutable", {})["target"] = expected_target
    change(composite)
    assert composite.content == expected
def test_sources_no_temporal_values(schema, composite, sources,
                                    expected_target):
    change: Change = BestAvailableV2(schema, {}, target, sources)
    del composite.content["2016"]
    del composite.content["2017"]
    del composite.content["2018"]
    del composite.content["2019"]
    expected: Dict = copy.deepcopy(composite.content)
    if expected_target is not None:
        expected["immutable"]["target"] = expected_target
    change(composite)
    assert composite.content == expected
def test_no_sources(schema, composite):
    change: Change = BestAvailableV2(schema, {}, target, [])
    expected: Dict = copy.deepcopy(composite.content)
    change(composite)
    assert composite.content == expected
def test_sources_with_different_data_types(schema, composite, sources):
    with pytest.raises(ValueError):
        change: Change = BestAvailableV2(schema, {}, target, sources)