Esempio n. 1
0
 def test_remove_inter_dep(self):
     '''Test ability to remove a dependency in a subgraph'''
     group = ServiceGroup('GROUP')
     s1 = Service('alpha')
     s2 = Service('beta')
     s3 = Service('lambda')
     group.add_inter_dep(target=s1)
     group.add_inter_dep(target=s2)
     group.add_inter_dep(target=s3)
     group.add_inter_dep(base=s1, target=s3)
     group.add_inter_dep(base=s2, target=s3)
     group.remove_inter_dep('lambda')
     self.assertTrue(s1.has_parent_dep('sink'))
     self.assertTrue(s2.has_parent_dep('sink'))
     self.assertTrue(s1.has_child_dep('source'))
     self.assertTrue(s2.has_child_dep('source'))
     self.assertFalse(s1.has_parent_dep('lambda'))
     self.assertFalse(s2.has_parent_dep('lambda'))
     group.remove_inter_dep('alpha')
     self.assertFalse(group._source.has_parent_dep('alpha'))
     self.assertTrue(group._source.has_parent_dep('beta'))
     self.assertFalse(group._sink.has_child_dep('alpha'))
     self.assertTrue(group._sink.has_child_dep('beta'))
     group.remove_inter_dep('beta')
     self.assertFalse(group._source.parents)
     self.assertFalse(group._sink.children)
Esempio n. 2
0
 def test_remove_inter_dep(self):
     '''Test ability to remove a dependency in a subgraph'''
     group = ServiceGroup('GROUP')
     s1 = Service('alpha')
     s2 = Service('beta')
     s3 = Service('lambda')
     group.add_inter_dep(target=s1)
     group.add_inter_dep(target=s2)
     group.add_inter_dep(target=s3)
     group.add_inter_dep(base=s1, target=s3)
     group.add_inter_dep(base=s2, target=s3)
     group.remove_inter_dep('lambda')
     self.assertTrue(s1.has_parent_dep('sink'))
     self.assertTrue(s2.has_parent_dep('sink'))
     self.assertTrue(s1.has_child_dep('source'))
     self.assertTrue(s2.has_child_dep('source'))
     self.assertFalse(s1.has_parent_dep('lambda'))
     self.assertFalse(s2.has_parent_dep('lambda'))
     group.remove_inter_dep('alpha')
     self.assertFalse(group._source.has_parent_dep('alpha'))
     self.assertTrue(group._source.has_parent_dep('beta'))
     self.assertFalse(group._sink.has_child_dep('alpha'))
     self.assertTrue(group._sink.has_child_dep('beta'))
     group.remove_inter_dep('beta')
     self.assertFalse(group._source.parents)
     self.assertFalse(group._sink.children)
Esempio n. 3
0
 def test_add_inter_dep_service_group_second(self):
     '''Test ability to add dependencies to the subgraph N2'''
     group = ServiceGroup('GROUP')
     s1 = Service('alpha')
     s2 = Service('beta')
     s3 = Service('lambda')
     group.add_inter_dep(target=s1)
     group.add_inter_dep(base=s1, target=s2)
     group.add_inter_dep(target=s3)
     group.add_inter_dep(base=s1, target=s3)
     self.assertTrue(s1.has_parent_dep('beta'))
     self.assertTrue(s1.has_parent_dep('lambda'))
     self.assertTrue(s1.has_child_dep('source'))
     self.assertTrue(s2.has_child_dep('alpha'))
     self.assertTrue(s3.has_child_dep('alpha'))
     self.assertTrue(s2.has_parent_dep('sink'))
     self.assertTrue(s3.has_parent_dep('sink'))
Esempio n. 4
0
 def test_add_inter_dep_service_group_second(self):
     '''Test ability to add dependencies to the subgraph N2'''
     group = ServiceGroup('GROUP')
     s1 = Service('alpha')
     s2 = Service('beta')
     s3 = Service('lambda')
     group.add_inter_dep(target=s1)
     group.add_inter_dep(base=s1, target=s2)
     group.add_inter_dep(target=s3)
     group.add_inter_dep(base=s1, target=s3)
     self.assertTrue(s1.has_parent_dep('beta'))
     self.assertTrue(s1.has_parent_dep('lambda'))
     self.assertTrue(s1.has_child_dep('source'))
     self.assertTrue(s2.has_child_dep('alpha'))
     self.assertTrue(s3.has_child_dep('alpha'))
     self.assertTrue(s2.has_parent_dep('sink'))
     self.assertTrue(s3.has_parent_dep('sink'))
Esempio n. 5
0
 def test_forget_service(self):
     '''The how the manager forgets a service properly'''
     manager = service_manager_self()
     s1 = Service('S1')
     s2 = Service('S2')
     s3 = Service('S3')
     s4 = Service('S4')
     s1.add_dep(target=s2)
     s2.add_dep(target=s3)
     s2.add_dep(target=s4)
     manager.register_services(s1, s2, s3, s4)
     manager.forget_service(s1)
     self.assertFalse(manager.has_service(s1))
     self.assertFalse(s1.has_parent_dep('S2'))
     self.assertFalse(s2.has_child_dep('S1'))
     manager.forget_services(s2, s4)
     self.assertFalse(manager.has_service(s2))
     self.assertFalse(manager.has_service(s4))
     self.assertFalse(s4.has_child_dep('S3'))
     self.assertFalse(s3.has_parent_dep('S4'))