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): ...@@ -66,7 +66,7 @@ class SoftwareInstance(Item):
return result_dict return result_dict
security.declareProtected(Permissions.AccessContentsInformation, security.declareProtected(Permissions.AccessContentsInformation,
'checkDisconnected') 'checkConnected')
def checkDisconnected(self, graph, root): def checkDisconnected(self, graph, root):
size = len(graph) size = len(graph)
visited = set() visited = set()
...@@ -83,3 +83,4 @@ class SoftwareInstance(Item): ...@@ -83,3 +83,4 @@ class SoftwareInstance(Item):
# anyway wrong in Software Instance trees # anyway wrong in Software Instance trees
if size != len(visited) + 1: if size != len(visited) + 1:
raise DisconnectedSoftwareTree raise DisconnectedSoftwareTree
return True
...@@ -153,7 +153,7 @@ graph[software_instance.getUid()] = software_instance.getPredecessorUidList() + ...@@ -153,7 +153,7 @@ graph[software_instance.getUid()] = software_instance.getPredecessorUidList() +
\n \n
# check if all elements are still connected\n # check if all elements are still connected\n
script.log(graph, root_software_instance.getUid())\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 \n
software_instance.edit(\n software_instance.edit(\n
predecessor_list=predecessor_list,\n predecessor_list=predecessor_list,\n
......
247 248
\ No newline at end of file \ No newline at end of file
...@@ -8206,7 +8206,7 @@ class TestVifibSlapWebService(testVifibMixin): ...@@ -8206,7 +8206,7 @@ class TestVifibSlapWebService(testVifibMixin):
def _test_si_tree(self): def _test_si_tree(self):
software_instance = self.portal.software_instance_module.newContent( software_instance = self.portal.software_instance_module.newContent(
portal_type='Software Instance') portal_type='Software Instance')
self.checkDisconnected = software_instance.checkDisconnected self.checkConnected = software_instance.checkConnected
def test_si_tree_simple_connected(self): def test_si_tree_simple_connected(self):
"""Graph of one element is connected """Graph of one element is connected
...@@ -8216,7 +8216,7 @@ class TestVifibSlapWebService(testVifibMixin): ...@@ -8216,7 +8216,7 @@ class TestVifibSlapWebService(testVifibMixin):
self._test_si_tree() self._test_si_tree()
graph = {'A': []} graph = {'A': []}
root = '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): def test_si_tree_simple_list_connected(self):
"""Graph of list is connected """Graph of list is connected
...@@ -8226,7 +8226,7 @@ class TestVifibSlapWebService(testVifibMixin): ...@@ -8226,7 +8226,7 @@ class TestVifibSlapWebService(testVifibMixin):
self._test_si_tree() self._test_si_tree()
graph = {'A': [], 'B': ['C'], 'C': ['A']} graph = {'A': [], 'B': ['C'], 'C': ['A']}
root = 'B' root = 'B'
self.assertEqual(None, self.checkDisconnected(graph, root)) self.assertEqual(True, self.checkConnected(graph, root))
def test_si_tree_complex_connected(self): def test_si_tree_complex_connected(self):
"""Tree is connected """Tree is connected
...@@ -8245,7 +8245,7 @@ class TestVifibSlapWebService(testVifibMixin): ...@@ -8245,7 +8245,7 @@ class TestVifibSlapWebService(testVifibMixin):
'F': [], 'F': [],
} }
root = 'B' root = 'B'
self.assertEqual(None, self.checkDisconnected(graph, root)) self.assertEqual(True, self.checkConnected(graph, root))
def test_si_tree_simple_list_disconnected(self): def test_si_tree_simple_list_disconnected(self):
"""Two lists are disconnected """Two lists are disconnected
...@@ -8257,7 +8257,7 @@ class TestVifibSlapWebService(testVifibMixin): ...@@ -8257,7 +8257,7 @@ class TestVifibSlapWebService(testVifibMixin):
graph = {'A': ['B'], 'B': [], 'C': []} graph = {'A': ['B'], 'B': [], 'C': []}
root = 'A' root = 'A'
from erp5.document.SoftwareInstance import DisconnectedSoftwareTree from erp5.document.SoftwareInstance import DisconnectedSoftwareTree
self.assertRaises(DisconnectedSoftwareTree, self.checkDisconnected, graph, self.assertRaises(DisconnectedSoftwareTree, self.checkConnected, graph,
root) root)
# For now limitation of implementation gives false positive # For now limitation of implementation gives false positive
...@@ -8270,10 +8270,11 @@ class TestVifibSlapWebService(testVifibMixin): ...@@ -8270,10 +8270,11 @@ class TestVifibSlapWebService(testVifibMixin):
self._test_si_tree() self._test_si_tree()
graph = {'A': ['B'], 'B': ['A']} graph = {'A': ['B'], 'B': ['A']}
root = 'B' root = 'B'
self.assertEqual(None, self.checkDisconnected(graph, root)) self.assertEqual(True, self.checkConnected(graph, root))
def test_si_tree_cyclic_disconnected(self): def test_si_tree_cyclic_disconnected(self):
"""Two trees, where one is cyclic are disconnected """Two trees, where one is cyclic are disconnected
B --> A B --> A
\-> H \-> H
C --> D --> G C --> D --> G
...@@ -8292,7 +8293,7 @@ class TestVifibSlapWebService(testVifibMixin): ...@@ -8292,7 +8293,7 @@ class TestVifibSlapWebService(testVifibMixin):
} }
root = 'B' root = 'B'
from erp5.document.SoftwareInstance import DisconnectedSoftwareTree from erp5.document.SoftwareInstance import DisconnectedSoftwareTree
self.assertRaises(DisconnectedSoftwareTree, self.checkDisconnected, graph, self.assertRaises(DisconnectedSoftwareTree, self.checkConnected, graph,
root) 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