Exemple #1
0
 def test_vertex_name_is_tuple(self):
     # exercising any hashable to be used as a vertex name (PR #2)
     vmap = VerticesMap(None)
     vmap[('vertex_a', )].depends_on(('vertex_b', ))
     self.assertEqual([('vertex_b', )],
                      vmap[('vertex_a', )].supporters(recurse=True))
     self.assertEqual([], vmap[('vertex_b', )].supporters(recurse=True))
Exemple #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))
Exemple #3
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))
Exemple #4
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())
Exemple #5
0
 def test__setattr__(self):
     vert = VerticesMap(None)
     with self.assertRaises(AttributeError):
         vert.z = Vertex('z', vert)
Exemple #6
0
 def test_creation__test_name(self):
     vertex = Vertex('vertex_11', VerticesMap(None))
     self.assertEqual('vertex_11', vertex.name)
     self.assertFalse(vertex.provided)
Exemple #7
0
 def test__getattr__(self):
     vert = VerticesMap(None)
     vertex = vert.vertex_384
     self.assertIsInstance(vertex, Vertex)
     self.assertEqual('vertex_384', vertex.name)
Exemple #8
0
 def test__setitem__(self):
     vert = VerticesMap(None)
     with self.assertRaises(NotImplementedError):
         vert['whatever'] = Vertex('whatever', vert)
Exemple #9
0
 def test__getitem__(self):
     vert = VerticesMap(None)
     vertex_a = vert['a']
     self.assertIsInstance(vertex_a, Vertex)
     self.assertEqual('a', vertex_a.name)
Exemple #10
0
 def test_creation(self):
     VerticesMap(None)
Exemple #11
0
 def test__contains__(self):
     vmap = VerticesMap(None)
     vmap.one.depends_on('two')
     self.assertTrue('one' in vmap)
     self.assertTrue('two' in vmap)
Exemple #12
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)
Exemple #13
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))