def _update_context_from_factors( self, other: Comparable, context: ContextRegister) -> Optional[ContextRegister]: incoming = ContextRegister( dict(zip(self.generic_factors, other.generic_factors))) updated_context = context.merged_with(incoming) return updated_context
def test_import_to_mapping_no_change(self, make_entity): old_mapping = ContextRegister( {make_entity["motel"]: make_entity["trees"]}) assert dict( old_mapping.merged_with( {make_entity["motel"]: make_entity["trees"]})) == { make_entity["motel"]: make_entity["trees"], }
def test_import_to_context_register(self, make_entity, watt_factor): f = watt_factor["f7"] left = ContextRegister({ watt_factor["f7"]: watt_factor["f7_swap_entities"], make_entity["motel"]: make_entity["trees"], }) right = ContextRegister({make_entity["trees"]: make_entity["motel"]}) assert len(left.merged_with(right)) == 3