Commit 7f011348 authored by Łukasz Nowak's avatar Łukasz Nowak

Rename to checkConnected

Even more -- return True in case if all was ok.
parent 771aa3d7
......@@ -66,7 +66,7 @@ class SoftwareInstance(Item):
return result_dict
security.declareProtected(Permissions.AccessContentsInformation,
'checkDisconnected')
'checkConnected')
def checkDisconnected(self, graph, root):
size = len(graph)
visited = set()
......@@ -83,3 +83,4 @@ class SoftwareInstance(Item):
# anyway wrong in Software Instance trees
if size != len(visited) + 1:
raise DisconnectedSoftwareTree
return True
......@@ -153,7 +153,7 @@ graph[software_instance.getUid()] = software_instance.getPredecessorUidList() +
\n
# check if all elements are still connected\n
script.log(graph, root_software_instance.getUid())\n
software_instance.checkDisconnected(graph, root_software_instance.getUid())\n
software_instance.checkConnected(graph, root_software_instance.getUid())\n
\n
software_instance.edit(\n
predecessor_list=predecessor_list,\n
......
247
\ No newline at end of file
248
\ No newline at end of file
......@@ -8206,7 +8206,7 @@ class TestVifibSlapWebService(testVifibMixin):
def _test_si_tree(self):
software_instance = self.portal.software_instance_module.newContent(
portal_type='Software Instance')
self.checkDisconnected = software_instance.checkDisconnected
self.checkConnected = software_instance.checkConnected
def test_si_tree_simple_connected(self):
"""Graph of one element is connected
......@@ -8216,7 +8216,7 @@ class TestVifibSlapWebService(testVifibMixin):
self._test_si_tree()
graph = {'A': []}
root = 'A'
self.assertEqual(None, self.checkDisconnected(graph, root))
self.assertEqual(True, self.checkConnected(graph, root))
def test_si_tree_simple_list_connected(self):
"""Graph of list is connected
......@@ -8226,7 +8226,7 @@ class TestVifibSlapWebService(testVifibMixin):
self._test_si_tree()
graph = {'A': [], 'B': ['C'], 'C': ['A']}
root = 'B'
self.assertEqual(None, self.checkDisconnected(graph, root))
self.assertEqual(True, self.checkConnected(graph, root))
def test_si_tree_complex_connected(self):
"""Tree is connected
......@@ -8245,7 +8245,7 @@ class TestVifibSlapWebService(testVifibMixin):
'F': [],
}
root = 'B'
self.assertEqual(None, self.checkDisconnected(graph, root))
self.assertEqual(True, self.checkConnected(graph, root))
def test_si_tree_simple_list_disconnected(self):
"""Two lists are disconnected
......@@ -8257,7 +8257,7 @@ class TestVifibSlapWebService(testVifibMixin):
graph = {'A': ['B'], 'B': [], 'C': []}
root = 'A'
from erp5.document.SoftwareInstance import DisconnectedSoftwareTree
self.assertRaises(DisconnectedSoftwareTree, self.checkDisconnected, graph,
self.assertRaises(DisconnectedSoftwareTree, self.checkConnected, graph,
root)
# For now limitation of implementation gives false positive
......@@ -8270,10 +8270,11 @@ class TestVifibSlapWebService(testVifibMixin):
self._test_si_tree()
graph = {'A': ['B'], 'B': ['A']}
root = 'B'
self.assertEqual(None, self.checkDisconnected(graph, root))
self.assertEqual(True, self.checkConnected(graph, root))
def test_si_tree_cyclic_disconnected(self):
"""Two trees, where one is cyclic are disconnected
B --> A
\-> H
C --> D --> G
......@@ -8292,7 +8293,7 @@ class TestVifibSlapWebService(testVifibMixin):
}
root = 'B'
from erp5.document.SoftwareInstance import DisconnectedSoftwareTree
self.assertRaises(DisconnectedSoftwareTree, self.checkDisconnected, graph,
self.assertRaises(DisconnectedSoftwareTree, self.checkConnected, graph,
root)
########################################
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment