def test_tracker_remove_computation_must_decrease_count():
    tracker = ReplicationTracker()
    tracker.add(['c1', 'c2', 'c3'])
    tracker.add(['c1', 'c2', 'c3'])
    tracker.remove(['c1', 'c3'])

    assert not tracker.is_empty()
    assert not tracker.is_done('c1')
    assert not tracker.is_done('c2')
    assert not tracker.is_done('c3')
    assert tracker.replicating['c1'] == 1
    assert tracker.replicating['c2'] == 2
    assert tracker.replicating['c3'] == 1
def test_tracker_remove_computation_must_decrease_count():
    tracker = ReplicationTracker()
    tracker.add(["c1", "c2", "c3"])
    tracker.add(["c1", "c2", "c3"])
    tracker.remove(["c1", "c3"])

    assert not tracker.is_empty()
    assert not tracker.is_done("c1")
    assert not tracker.is_done("c2")
    assert not tracker.is_done("c3")
    assert tracker.replicating["c1"] == 1
    assert tracker.replicating["c2"] == 2
    assert tracker.replicating["c3"] == 1
def test_tracker_add_computation_several_time_must_increase_count():
    tracker = ReplicationTracker()
    tracker.add(["c1", "c2", "c3"])
    tracker.add(["c1", "c3"])

    assert not tracker.is_empty()
    assert tracker.replicating["c1"] == 2
    assert tracker.replicating["c2"] == 1
    assert tracker.replicating["c3"] == 2
def test_tracker_add_computation_several_time_must_increase_count():
    tracker = ReplicationTracker()
    tracker.add(['c1', 'c2', 'c3'])
    tracker.add(['c1', 'c3'])

    assert not tracker.is_empty()
    assert tracker.replicating['c1'] == 2
    assert tracker.replicating['c2'] == 1
    assert tracker.replicating['c3'] == 2
def test_tracker_when_reaching_0_computation_is_removed():
    tracker = ReplicationTracker()
    tracker.add(["c1", "c2", "c3"])
    tracker.remove(["c1", "c3"])

    assert tracker.is_done("c1")
    assert tracker.replicating["c2"] == 1
    assert tracker.is_done("c3")

    tracker.remove(["c2"])
    assert tracker.is_empty()
def test_tracker_add_computations():
    tracker = ReplicationTracker()
    tracker.add(["c1", "c2", "c3"])

    assert not tracker.is_empty()
    assert set(tracker.in_progress()) == {"c1", "c2", "c3"}
def test_tracker_when_reaching_0_computation_is_removed():
    tracker = ReplicationTracker()
    tracker.add(['c1', 'c2', 'c3'])
    tracker.remove(['c1', 'c3'])

    assert tracker.is_done('c1')
    assert tracker.replicating['c2'] == 1
    assert tracker.is_done('c3')

    tracker.remove(['c2'])
    assert tracker.is_empty()
def test_tracker_add_computations():
    tracker = ReplicationTracker()
    tracker.add(['c1', 'c2', 'c3'])

    assert not tracker.is_empty()
    assert set(tracker.in_progress()) == {'c1', 'c2', 'c3'}