def test_add(self, add_sequence, exp_state_ids, exp_loop_ids): queue = ChangeQueueWithDeps() loop_ids = [] for change in add_sequence: added, in_loop = queue.add(_cwds_fv(change)) print('added: ', added) print('in_loop:', in_loop) loop_ids.extend(map(ChangeQueueWithDeps._change_id, in_loop)) assert exp_state_ids == \ list(map(ChangeQueueWithDeps._change_id, queue._state[0])) assert exp_loop_ids == loop_ids
def test_on_test_failure(self, initq, initwd, expfl, expq, expwd): queue = ChangeQueueWithDeps((map(_cwds_fv, s) for s in initq), 'k1', map(_c2adep, initwd)) outsl, outfl, outc = queue.on_test_failure('k1') assert [] == outsl assert expfl == list(map(ChangeQueueWithDeps._change_id, outfl)) # For dep queues, failure cause is the 1st change in the fail list assert next(iter(expfl), None) == ChangeQueueWithDeps._change_id(outc) assert [list(map(_cwds_fv, s)) for s in expq] == \ _enlist_state(queue._state) assert list(map(_c2adep, expwd)) == list(queue._awaiting_deps)
def test_rm_a_deps_by_ids(self, adeps, dep_ids, exp_out, exp_a_deps): queue = ChangeQueueWithDeps(awaiting_deps=map(_c2adep, adeps)) out = queue._remove_awaiting_deps_by_ids(set(dep_ids)) assert list(map(_c2adep, exp_out)) == out assert list(map(_c2adep, exp_a_deps)) == list(queue._awaiting_deps)
def test_find_dependants_on(self, change_id, changes, exp_deps): deps = ChangeQueueWithDeps._find_dependants_on( change_id, map(_cwds_fv, changes) ) assert set(exp_deps) == set(deps)
def test_get_missing_deps(self, initq, change, exp_deps): queue = ChangeQueueWithDeps(initq) out_deps = queue._get_missing_deps(_cwds_fv(change)) assert set(exp_deps) == set(out_deps)
def test_change_requirements(self, change, exp): out = ChangeQueueWithDeps._change_requirements(change) assert set(exp) == out