def test_flow_tracking_labels_diverge(changes): """ Tests a case of divergence. Diverge to a, b with different ap diffs, then converge at c. """ flow_tracking = FlowTracking() flow_tracking.add_flow_to_label(ScopedName.from_string('a'), changes.to_a) flow_tracking.add_flow_to_label(ScopedName.from_string('b'), changes.to_b) # Label a. flow_tracking.revoke() flow_tracking.converge_with_label(ScopedName.from_string('a')) flow_tracking.add_ap(changes.at_a) data_after_a = flow_tracking.get() flow_tracking.add_flow_to_label(ScopedName.from_string('c'), 0) # Label b. flow_tracking.revoke() flow_tracking.converge_with_label(ScopedName.from_string('b')) flow_tracking.add_ap(changes.at_b) data_after_b = flow_tracking.get() flow_tracking.add_flow_to_label(ScopedName.from_string('c'), 0) # Label c. flow_tracking.revoke() flow_tracking.converge_with_label(ScopedName.from_string('c')) data_at_c = flow_tracking.get() if changes.valid: assert data_after_a == data_after_b == data_at_c else: assert data_after_a != data_at_c and data_after_b != data_at_c
def test_flow_tracking_labels(changes): # Good case. flow_tracking = FlowTracking() flow_tracking.add_flow_to_label(ScopedName.from_string('a'), changes.label0) flow_tracking.add_ap(changes.body0) flow_tracking.add_flow_to_label(ScopedName.from_string('a'), changes.label1) flow_tracking.add_ap(changes.body1) current_data = flow_tracking.get() flow_tracking.converge_with_label(ScopedName.from_string('a')) assert (flow_tracking.get() == current_data) is changes.valid