def test_all_supporters(self): dag = DepDag() a = Vertex('a', dag) a.depends_on('b') b = dag['b'] b.depends_on('c') self.assertEqual(['b', 'c'], names_list(a.all_supporters()))
def test_all_supporters(self): vmap = VerticesMap(None) a = Vertex('a', vmap) a.depends_on('b') b = vmap['b'] b.depends_on('c') self.assertEqual(['b', 'c'], a.supporters(recurse=True))
def test_has_payload__for_callable(self): vertex = Vertex('vertex_44', DepDag()) self.assertFalse(vertex.has_payload()) call_log = list() def has_payload_callback(): call_log.append('CALLED') return True vertex.payload = has_payload_callback self.assertTrue(vertex.has_payload()) self.assertEqual(['CALLED'], call_log)
def test_depends_on__test_supporters(self): vtx = Vertex('vertex_0', VerticesMap(None)) vtx.depends_on('vertex_1', 'vertex_2') expected = ['vertex_1', 'vertex_2'] self.assertEqual(expected, vtx.supporters(recurse=False)) vtx.depends_on('vertex_2', 'vertex_3') expected = ['vertex_1', 'vertex_2', 'vertex_3'] self.assertEqual(expected, vtx.supporters(recurse=False))
def test_depends_on__test_supporters(self): vertex = Vertex('vertex_0', DepDag()) vertex.depends_on('vertex_1', 'vertex_2') expected = ['vertex_1', 'vertex_2'] self.assertEqual(expected, names_list(vertex.direct_supporters())) vertex.depends_on('vertex_2', 'vertex_3') expected = ['vertex_1', 'vertex_2', 'vertex_3'] self.assertEqual(expected, names_list(vertex.direct_supporters()))
def test_is_resolved__simplest_case(self): vmap = VerticesMap(None) a = Vertex('a', vmap) a.depends_on('b') self.assertFalse(a.is_resolved()) b = vmap['b'] self.assertFalse(b.is_resolved()) b.payload = 'payload for vert-b' self.assertFalse(a.is_resolved()) self.assertTrue(b.is_resolved()) a.payload = 'payload for vert-a' self.assertTrue(a.is_resolved()) self.assertTrue(b.is_resolved())
def test_is_resolved__simplest_case(self): dag = DepDag() a = Vertex('a', dag) a.depends_on('b') self.assertFalse(a.is_resolved()) b = dag['b'] self.assertFalse(b.is_resolved()) b.payload = 'payload for vert-b' self.assertFalse(a.is_resolved()) self.assertTrue(b.is_resolved()) a.payload = 'payload for vert-a' self.assertTrue(a.is_resolved()) self.assertTrue(b.is_resolved())
def test__setitem__(self): vert = VerticesMap(None) with self.assertRaises(NotImplementedError): vert['whatever'] = Vertex('whatever', vert)
def test_provide_payload(self): vertex = Vertex('vertex_33', VerticesMap(None)) self.assertFalse(vertex.provided) vertex.payload = "any payload would do" self.assertTrue(vertex.provided)
def test__repr__(self): vtx = Vertex('vertex_22', VerticesMap(None)) expected = "<Vertex(name='vertex_22') object at 0x" self.assertTrue(repr(vtx).startswith(expected))
def test__setitem__(self): dag = DepDag() with self.assertRaises(NotImplementedError): dag['whatever'] = Vertex('whatever', dag)
def test_has_payload__for_object(self): vertex = Vertex('vertex_33', DepDag()) self.assertFalse(vertex.has_payload()) vertex.payload = "any payload would do" self.assertTrue(vertex.has_payload())
def test__repr__(self): vertex = Vertex('vertex_22', DepDag()) expected = "<Vertex(name='vertex_22') object at 0x" self.assertTrue(repr(vertex).startswith(expected))
def test__setattr__(self): dag = DepDag() with self.assertRaises(AttributeError): dag.whatever = Vertex('whatever', dag)
def test_creation__test_name(self): vertex = Vertex('vertex_11', VerticesMap(None)) self.assertEqual('vertex_11', vertex.name) self.assertFalse(vertex.provided)
def test__setattr__(self): vert = VerticesMap(None) with self.assertRaises(AttributeError): vert.z = Vertex('z', vert)
def test_creation__test_name(self): vertex = Vertex('vertex_11', DepDag()) self.assertEqual('vertex_11', vertex.name) self.assertFalse(vertex.has_payload())