Exemplo n.º 1
0
 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()))
Exemplo n.º 2
0
 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))
Exemplo n.º 3
0
    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)
Exemplo n.º 4
0
 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))
Exemplo n.º 5
0
 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()))
Exemplo n.º 6
0
 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())
Exemplo n.º 7
0
 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())
Exemplo n.º 8
0
 def test__setitem__(self):
     vert = VerticesMap(None)
     with self.assertRaises(NotImplementedError):
         vert['whatever'] = Vertex('whatever', vert)
Exemplo n.º 9
0
 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)
Exemplo n.º 10
0
 def test__repr__(self):
     vtx = Vertex('vertex_22', VerticesMap(None))
     expected = "<Vertex(name='vertex_22') object at 0x"
     self.assertTrue(repr(vtx).startswith(expected))
Exemplo n.º 11
0
 def test__setitem__(self):
     dag = DepDag()
     with self.assertRaises(NotImplementedError):
         dag['whatever'] = Vertex('whatever', dag)
Exemplo n.º 12
0
 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())
Exemplo n.º 13
0
 def test__repr__(self):
     vertex = Vertex('vertex_22', DepDag())
     expected = "<Vertex(name='vertex_22') object at 0x"
     self.assertTrue(repr(vertex).startswith(expected))
Exemplo n.º 14
0
 def test__setattr__(self):
     dag = DepDag()
     with self.assertRaises(AttributeError):
         dag.whatever = Vertex('whatever', dag)
Exemplo n.º 15
0
 def test_creation__test_name(self):
     vertex = Vertex('vertex_11', VerticesMap(None))
     self.assertEqual('vertex_11', vertex.name)
     self.assertFalse(vertex.provided)
Exemplo n.º 16
0
 def test__setattr__(self):
     vert = VerticesMap(None)
     with self.assertRaises(AttributeError):
         vert.z = Vertex('z', vert)
Exemplo n.º 17
0
 def test_creation__test_name(self):
     vertex = Vertex('vertex_11', DepDag())
     self.assertEqual('vertex_11', vertex.name)
     self.assertFalse(vertex.has_payload())