Beispiel #1
0
 def test_dependency_instanciation(self):
     """Test instanciation of a dependency."""
     service = BaseEntity("PARENT")
     service = BaseEntity("CHILD")
     self.assertRaises(AssertionError, Dependency, None)
     self.assertRaises(AssertionError, Dependency, service, "TEST")
     self.assertTrue(Dependency(service))
     self.assertTrue(Dependency(service, CHECK))
     self.assertTrue(Dependency(service, CHECK, True))
Beispiel #2
0
 def test_remove_dep(self):
     """Test method remove_dep."""
     ent = BaseEntity('foo')
     ent_dep = BaseEntity('child')
     ent.children['child'] = Dependency(ent_dep)
     ent_dep.parents['foo'] = Dependency(ent)
     ent.remove_dep('child', parent=False)
     self.assertTrue('child' not in ent.children)
     self.assertTrue('foo' not in ent.parents)
     self.assertRaises(AssertionError, ent.remove_dep, None)
Beispiel #3
0
 def test_is_strong_dependency(self):
     """Test the behaviour of is_strong method."""
     dep_a = Dependency(BaseEntity("Base"), CHECK)
     dep_b = Dependency(BaseEntity("Base"), REQUIRE)
     dep_c = Dependency(BaseEntity("Base"), REQUIRE_WEAK)
     self.assertTrue(dep_a.is_strong())
     self.assertTrue(dep_b.is_strong())
     self.assertFalse(dep_c.is_strong())
Beispiel #4
0
 def test_graph_dep_type(self):
     """Test the DOT output of a dependency type"""
     ent = BaseEntity("ENTITY")
     dep_c = Dependency(BaseEntity("Base"), CHECK)
     dep_r = Dependency(BaseEntity("Base"), REQUIRE)
     dep_rw = Dependency(BaseEntity("Base"), REQUIRE_WEAK)
     self.assertEqual(dep_c.graph(ent), '"ENTITY" -> "Base";\n')
     self.assertEqual(dep_r.graph(ent), '"ENTITY" -> "Base";\n')
     self.assertEqual(dep_rw.graph(ent),
                      '"ENTITY" -> "Base" [style=dashed];\n')
Beispiel #5
0
 def test_has_parent_dep(self):
     """Test method has_parent_dep"""
     ent = BaseEntity('foo')
     ent_dep = BaseEntity('parent')
     ent.parents['parent'] = Dependency(ent_dep)
     self.assertTrue(ent.has_parent_dep('parent'))
     del ent.parents['parent']
     self.assertFalse(ent.has_parent_dep('parent'))
Beispiel #6
0
 def test_has_child_dep(self):
     """Test method has_child_dep"""
     ent = BaseEntity('foo')
     ent_dep = BaseEntity('child')
     ent.children['child'] = Dependency(ent_dep)
     self.assertTrue(ent.has_child_dep('child'))
     del ent.children['child']
     self.assertFalse(ent.has_child_dep('child'))
Beispiel #7
0
 def test_is_strong_dependency(self):
     """Test the behaviour of is_strong method."""
     dep_a = Dependency(BaseEntity("Base"), CHECK)
     dep_b = Dependency(BaseEntity("Base"), REQUIRE)
     dep_c = Dependency(BaseEntity("Base"), REQUIRE_WEAK)
     self.assertTrue(dep_a.is_strong())
     self.assertTrue(dep_b.is_strong())
     self.assertFalse(dep_c.is_strong())
Beispiel #8
0
 def test_graph(self):
     """Test the DOT output of a dependency"""
     p_service = BaseEntity("PARENT")
     c_service = BaseEntity("CHILD")
     dep = Dependency(c_service, REQUIRE)
     #self.assertEqual(dep.graph(p_service), '"CHILD" -> "PARENT";\n')
     self.assertEqual(dep.graph(p_service), '"PARENT" -> "CHILD";\n')
     p_group = ServiceGroup('P_Group')
     c_group = ServiceGroup('C_Group')
     p_dep = Dependency(p_group)
     c_dep = Dependency(c_group)
     self.assertEqual(
         c_dep.graph(p_group), '"P_Group.__hook" -> "C_Group.__hook" '
         '[ltail="cluster_P_Group",lhead="cluster_C_Group"];\n')
     self.assertEqual(
         c_dep.graph(p_service), '"PARENT" -> "C_Group.__hook" '
         '[lhead="cluster_C_Group"];\n')
     self.assertEqual(
         dep.graph(p_group), '"P_Group.__hook" -> "CHILD" '
         '[ltail="cluster_P_Group"];\n')
Beispiel #9
0
 def test_graph_dep_type(self):
     """Test the DOT output of a dependency type"""
     ent = BaseEntity("ENTITY")
     dep_c = Dependency(BaseEntity("Base"), CHECK)
     dep_r = Dependency(BaseEntity("Base"), REQUIRE)
     dep_rw = Dependency(BaseEntity("Base"), REQUIRE_WEAK)
     self.assertEqual(dep_c.graph(ent), '"ENTITY" -> "Base";\n')
     self.assertEqual(dep_r.graph(ent), '"ENTITY" -> "Base";\n')
     self.assertEqual(dep_rw.graph(ent), 
                         '"ENTITY" -> "Base" [style=dashed];\n')
Beispiel #10
0
 def test_graph(self):
     """Test the DOT output of a dependency"""
     p_service = BaseEntity("PARENT")
     c_service = BaseEntity("CHILD")
     dep = Dependency(c_service, REQUIRE)
     #self.assertEqual(dep.graph(p_service), '"CHILD" -> "PARENT";\n')
     self.assertEqual(dep.graph(p_service), '"PARENT" -> "CHILD";\n')
     p_group = ServiceGroup('P_Group')
     c_group = ServiceGroup('C_Group')
     p_dep = Dependency(p_group)
     c_dep = Dependency(c_group)
     self.assertEqual(c_dep.graph(p_group),
                     '"P_Group.__hook" -> "C_Group.__hook" '
                     '[ltail="cluster_P_Group",lhead="cluster_C_Group"];\n')
     self.assertEqual(c_dep.graph(p_service), 
                     '"PARENT" -> "C_Group.__hook" '
                     '[lhead="cluster_C_Group"];\n')
     self.assertEqual(dep.graph(p_group),
                     '"P_Group.__hook" -> "CHILD" '
                     '[ltail="cluster_P_Group"];\n')
Beispiel #11
0
 def test_is_internal(self):
     """Test the behaviour of the method is internal"""
     dep = Dependency(target=BaseEntity('Group'), intr=True)
     self.assertTrue(dep.is_internal())
     dep = Dependency(target=BaseEntity('Group'), intr=False)
     self.assertFalse(dep.is_internal())
Beispiel #12
0
 def test_is_internal(self):
     """Test the behaviour of the method is internal"""
     dep = Dependency(target=BaseEntity('Group'), intr=True)
     self.assertTrue(dep.is_internal())
     dep = Dependency(target=BaseEntity('Group'), intr=False)
     self.assertFalse(dep.is_internal())