def test_build_graph_get_leaf_collect(self):
    x = self.app.AsyncResult('1')
    x.backend._cache['1'] = {'status': states.SUCCESS, 'result': None}
    c = [EagerResult(str(i), i, states.SUCCESS) for i in range(3)]
    x.iterdeps = Mock()
    x.iterdeps.return_value = ((None, x), (x, c[0]), (c[0], c[1]), (c[1], c[2]))
    x.backend.READY_STATES = states.READY_STATES
    self.assertTrue(x.graph)
    self.assertIs(x.get_leaf(), 2)
    it = x.collect()
    self.assertListEqual(list(it), [(x, None), (c[0], 0), (c[1], 1), (c[2], 2)])
def test_build_graph_get_leaf_collect(self):
    x = self.app.AsyncResult('1')
    x.backend._cache['1'] = {'status': states.SUCCESS, 'result': None}
    c = [EagerResult(str(i), i, states.SUCCESS) for i in range(3)]
    x.iterdeps = Mock()
    x.iterdeps.return_value = ((None, x), (x, c[0]), (c[0], c[1]), (c[1], c[2]))
    x.backend.READY_STATES = states.READY_STATES
    self.assertTrue(x.graph)
    self.assertIs(x.get_leaf(), 2)
    it = x.collect()
    self.assertListEqual(list(it), [(x, None), (c[0], 0), (c[1], 1), (c[2], 2)])