Commit ccbf6e16 authored by Rafael Monnerat's avatar Rafael Monnerat

Improve code for stable assertions

See merge request nexedi/slapos.core!615
parents 90f756ea 926841f6
...@@ -246,7 +246,7 @@ class testSlapOSAbyss(SlapOSTestCaseMixin): ...@@ -246,7 +246,7 @@ class testSlapOSAbyss(SlapOSTestCaseMixin):
for new_array in new_array_list: for new_array in new_array_list:
if 'file_system_image/process_state/converted' in new_array.getPublicationSectionList(): if 'file_system_image/process_state/converted' in new_array.getPublicationSectionList():
break break
self.assertTrue('file_system_image/process_state/converted' in new_array.getPublicationSectionList()) self.assertIn('file_system_image/process_state/converted', new_array.getPublicationSectionList())
self.assertEquals(len(new_array.getArray()), 0) self.assertEquals(len(new_array.getArray()), 0)
...@@ -295,7 +295,7 @@ class testSlapOSAbyss(SlapOSTestCaseMixin): ...@@ -295,7 +295,7 @@ class testSlapOSAbyss(SlapOSTestCaseMixin):
for compute_node in self.compute_node_list: for compute_node in self.compute_node_list:
data_array_list = self._getRelatedDataArrayList(compute_node) data_array_list = self._getRelatedDataArrayList(compute_node)
self.assertEqual(len(data_array_list), 1) self.assertEqual(len(data_array_list), 1)
self.assertTrue("file_system_image/process_state/converted" in data_array_list[0].getPublicationSectionList()) self.assertIn("file_system_image/process_state/converted", data_array_list[0].getPublicationSectionList())
self.portal.portal_alarms.wendelin_handle_analysis.activeSense() self.portal.portal_alarms.wendelin_handle_analysis.activeSense()
self.tic() self.tic()
...@@ -304,7 +304,7 @@ class testSlapOSAbyss(SlapOSTestCaseMixin): ...@@ -304,7 +304,7 @@ class testSlapOSAbyss(SlapOSTestCaseMixin):
for compute_node in self.compute_node_list: for compute_node in self.compute_node_list:
data_array_list = self._getRelatedDataArrayList(compute_node) data_array_list = self._getRelatedDataArrayList(compute_node)
self.assertEqual(len(data_array_list), 1) self.assertEqual(len(data_array_list), 1)
self.assertTrue("file_system_image/process_state/converted" in data_array_list[0].getPublicationSectionList()) self.assertIn("file_system_image/process_state/converted", data_array_list[0].getPublicationSectionList())
# process data array # process data array
self.portal.portal_alarms.slapos_process_data_array.activeSense() self.portal.portal_alarms.slapos_process_data_array.activeSense()
...@@ -315,7 +315,7 @@ class testSlapOSAbyss(SlapOSTestCaseMixin): ...@@ -315,7 +315,7 @@ class testSlapOSAbyss(SlapOSTestCaseMixin):
for compute_node in self.compute_node_list: for compute_node in self.compute_node_list:
data_array_list = self._getRelatedDataArrayList(compute_node) data_array_list = self._getRelatedDataArrayList(compute_node)
self.assertEqual(len(data_array_list), 2) self.assertEqual(len(data_array_list), 2)
self.assertTrue("file_system_image/process_state/converted" in data_array_list[-1].getPublicationSectionList()) self.assertIn("file_system_image/process_state/converted", data_array_list[-1].getPublicationSectionList())
self.portal.portal_alarms.wendelin_handle_analysis.activeSense() self.portal.portal_alarms.wendelin_handle_analysis.activeSense()
...@@ -324,7 +324,7 @@ class testSlapOSAbyss(SlapOSTestCaseMixin): ...@@ -324,7 +324,7 @@ class testSlapOSAbyss(SlapOSTestCaseMixin):
for compute_node in self.compute_node_list: for compute_node in self.compute_node_list:
data_array_list = self._getRelatedDataArrayList(compute_node) data_array_list = self._getRelatedDataArrayList(compute_node)
self.assertEqual(len(data_array_list), 2) self.assertEqual(len(data_array_list), 2)
self.assertTrue("file_system_image/process_state/converted" in data_array_list[-1].getPublicationSectionList()) self.assertIn("file_system_image/process_state/converted", data_array_list[-1].getPublicationSectionList())
self.portal.portal_alarms.slapos_process_data_array.activeSense() self.portal.portal_alarms.slapos_process_data_array.activeSense()
...@@ -384,28 +384,28 @@ class testSlapOSAbyss(SlapOSTestCaseMixin): ...@@ -384,28 +384,28 @@ class testSlapOSAbyss(SlapOSTestCaseMixin):
for compute_node in self.compute_node_list: for compute_node in self.compute_node_list:
data_array_list = self._getRelatedDataArrayList(compute_node) data_array_list = self._getRelatedDataArrayList(compute_node)
self.assertEqual(len(data_array_list), 2) self.assertEqual(len(data_array_list), 2)
self.assertTrue("file_system_image/process_state/converted" in data_array_list[-1].getPublicationSectionList()) self.assertIn("file_system_image/process_state/converted", data_array_list[-1].getPublicationSectionList())
self.portal.portal_alarms.slapos_process_data_array.activeSense() self.portal.portal_alarms.slapos_process_data_array.activeSense()
self.tic() self.tic()
data_array_list = self._getRelatedDataArrayList(self.portal.compute_node_module['database_debian10']) data_array_list = self._getRelatedDataArrayList(self.portal.compute_node_module['database_debian10'])
self.assertEqual(len(data_array_list), 2) self.assertEqual(len(data_array_list), 2)
self.assertTrue("file_system_image/process_state/archived" in data_array_list[0].getPublicationSectionList()) self.assertIn("file_system_image/process_state/archived", data_array_list[0].getPublicationSectionList())
self.assertTrue("file_system_image/process_state/processed" in data_array_list[1].getPublicationSectionList()) self.assertIn("file_system_image/process_state/processed", data_array_list[1].getPublicationSectionList())
data_array_list = self._getRelatedDataArrayList(self.portal.compute_node_module['database_debian11']) data_array_list = self._getRelatedDataArrayList(self.portal.compute_node_module['database_debian11'])
self.assertEqual(len(data_array_list), 2) self.assertEqual(len(data_array_list), 2)
self.assertTrue("file_system_image/process_state/archived" in data_array_list[0].getPublicationSectionList()) self.assertIn("file_system_image/process_state/archived", data_array_list[0].getPublicationSectionList())
self.assertTrue("file_system_image/process_state/processed" in data_array_list[1].getPublicationSectionList()) self.assertIn("file_system_image/process_state/processed", data_array_list[1].getPublicationSectionList())
data_array_list = self._getRelatedDataArrayList(self.portal.compute_node_module['node_debian10']) data_array_list = self._getRelatedDataArrayList(self.portal.compute_node_module['node_debian10'])
self.assertEqual(len(data_array_list), 2) self.assertEqual(len(data_array_list), 2)
self.assertTrue("file_system_image/process_state/processed" in data_array_list[0].getPublicationSectionList()) self.assertIn("file_system_image/process_state/processed", data_array_list[0].getPublicationSectionList())
self.assertTrue("file_system_image/process_state/processed" in data_array_list[1].getPublicationSectionList()) self.assertIn("file_system_image/process_state/processed", data_array_list[1].getPublicationSectionList())
self.assertTrue('file_system_image/diff_end/identical' in data_array_list[1].getPublicationSectionList()) self.assertIn('file_system_image/diff_end/identical', data_array_list[1].getPublicationSectionList())
# now ingest different data for node_debian10 # now ingest different data for node_debian10
request_dict = { request_dict = {
...@@ -421,24 +421,24 @@ class testSlapOSAbyss(SlapOSTestCaseMixin): ...@@ -421,24 +421,24 @@ class testSlapOSAbyss(SlapOSTestCaseMixin):
self.tic() self.tic()
data_array_list = self._getRelatedDataArrayList(self.portal.compute_node_module['node_debian10']) data_array_list = self._getRelatedDataArrayList(self.portal.compute_node_module['node_debian10'])
self.assertEqual(len(data_array_list), 3) self.assertEqual(len(data_array_list), 3)
self.assertTrue("file_system_image/process_state/processed" in data_array_list[0].getPublicationSectionList()) self.assertIn("file_system_image/process_state/processed", data_array_list[0].getPublicationSectionList())
self.assertTrue("file_system_image/process_state/processed" in data_array_list[1].getPublicationSectionList()) self.assertIn("file_system_image/process_state/processed", data_array_list[1].getPublicationSectionList())
# This is the new one with different value # This is the new one with different value
self.assertTrue("file_system_image/process_state/converted" in data_array_list[2].getPublicationSectionList()) self.assertIn("file_system_image/process_state/converted", data_array_list[2].getPublicationSectionList())
self.portal.portal_alarms.slapos_process_data_array.activeSense() self.portal.portal_alarms.slapos_process_data_array.activeSense()
self.tic() self.tic()
data_array_list = self._getRelatedDataArrayList(self.portal.compute_node_module['node_debian10']) data_array_list = self._getRelatedDataArrayList(self.portal.compute_node_module['node_debian10'])
self.assertEqual(len(data_array_list), 4) self.assertEqual(len(data_array_list), 4)
self.assertTrue("file_system_image/process_state/processed" in data_array_list[0].getPublicationSectionList()) self.assertIn("file_system_image/process_state/processed", data_array_list[0].getPublicationSectionList())
self.assertTrue("file_system_image/process_state/processed" in data_array_list[1].getPublicationSectionList()) self.assertIn("file_system_image/process_state/processed", data_array_list[1].getPublicationSectionList())
self.assertTrue("file_system_image/process_state/processed" in data_array_list[2].getPublicationSectionList()) self.assertIn("file_system_image/process_state/processed", data_array_list[2].getPublicationSectionList())
# array 3 is the result of array 0 and array 2, Note: array 0 is the first access data # array 3 is the result of array 0 and array 2, Note: array 0 is the first access data
self.assertTrue("file_system_image/process_state/converted" in data_array_list[3].getPublicationSectionList()) self.assertIn("file_system_image/process_state/converted", data_array_list[3].getPublicationSectionList())
predecessor_list = [x.getRelativeUrl() for x in data_array_list[3].getPredecessorValueList(portal_type='Data Array')] predecessor_list = [x.getRelativeUrl() for x in data_array_list[3].getPredecessorValueList(portal_type='Data Array')]
self.assertTrue(data_array_list[0].getRelativeUrl() in predecessor_list) self.assertIn(data_array_list[0].getRelativeUrl(), predecessor_list)
self.assertTrue(data_array_list[2].getRelativeUrl() in predecessor_list) self.assertIn(data_array_list[2].getRelativeUrl(), predecessor_list)
# only have one diff # only have one diff
self.assertTrue(len(data_array_list[3].getArray()), 1) self.assertTrue(len(data_array_list[3].getArray()), 1)
...@@ -447,17 +447,17 @@ class testSlapOSAbyss(SlapOSTestCaseMixin): ...@@ -447,17 +447,17 @@ class testSlapOSAbyss(SlapOSTestCaseMixin):
# array 3 compare with database_debian10 # array 3 compare with database_debian10
data_array_list = self._getRelatedDataArrayList(self.portal.compute_node_module['node_debian10']) data_array_list = self._getRelatedDataArrayList(self.portal.compute_node_module['node_debian10'])
self.assertEqual(len(data_array_list), 5) self.assertEqual(len(data_array_list), 5)
self.assertTrue("file_system_image/process_state/processed" in data_array_list[0].getPublicationSectionList()) self.assertIn("file_system_image/process_state/processed", data_array_list[0].getPublicationSectionList())
self.assertTrue("file_system_image/process_state/processed" in data_array_list[1].getPublicationSectionList()) self.assertIn("file_system_image/process_state/processed", data_array_list[1].getPublicationSectionList())
self.assertTrue("file_system_image/process_state/processed" in data_array_list[2].getPublicationSectionList()) self.assertIn("file_system_image/process_state/processed", data_array_list[2].getPublicationSectionList())
self.assertTrue("file_system_image/process_state/processed" in data_array_list[3].getPublicationSectionList()) self.assertIn("file_system_image/process_state/processed", data_array_list[3].getPublicationSectionList())
# array 4 is result of array 3 and database_debian10 # array 4 is result of array 3 and database_debian10
self.assertTrue("file_system_image/process_state/converted" in data_array_list[4].getPublicationSectionList()) self.assertIn("file_system_image/process_state/converted", data_array_list[4].getPublicationSectionList())
predecessor_list = [x.getRelativeUrl() for x in data_array_list[4].getPredecessorValueList(portal_type='Data Array')] predecessor_list = [x.getRelativeUrl() for x in data_array_list[4].getPredecessorValueList(portal_type='Data Array')]
last_detabase_debian10 = self._getRelatedDataArrayList(self.portal.compute_node_module['database_debian10'])[-1] last_detabase_debian10 = self._getRelatedDataArrayList(self.portal.compute_node_module['database_debian10'])[-1]
self.assertTrue(last_detabase_debian10.getRelativeUrl() in predecessor_list) self.assertIn(last_detabase_debian10.getRelativeUrl(), predecessor_list)
self.assertTrue(data_array_list[3].getRelativeUrl() in predecessor_list) self.assertIn(data_array_list[3].getRelativeUrl(), predecessor_list)
self.assertTrue(len(data_array_list[4].getArray()), 1) self.assertTrue(len(data_array_list[4].getArray()), 1)
self.portal.portal_alarms.slapos_process_data_array.activeSense() self.portal.portal_alarms.slapos_process_data_array.activeSense()
...@@ -465,25 +465,25 @@ class testSlapOSAbyss(SlapOSTestCaseMixin): ...@@ -465,25 +465,25 @@ class testSlapOSAbyss(SlapOSTestCaseMixin):
# array 4 compare with database_debian11 # array 4 compare with database_debian11
data_array_list = self._getRelatedDataArrayList(self.portal.compute_node_module['node_debian10']) data_array_list = self._getRelatedDataArrayList(self.portal.compute_node_module['node_debian10'])
self.assertEqual(len(data_array_list), 6) self.assertEqual(len(data_array_list), 6)
self.assertTrue("file_system_image/process_state/processed" in data_array_list[0].getPublicationSectionList()) self.assertIn("file_system_image/process_state/processed", data_array_list[0].getPublicationSectionList())
self.assertTrue("file_system_image/process_state/processed" in data_array_list[1].getPublicationSectionList()) self.assertIn("file_system_image/process_state/processed", data_array_list[1].getPublicationSectionList())
self.assertTrue("file_system_image/process_state/processed" in data_array_list[2].getPublicationSectionList()) self.assertIn("file_system_image/process_state/processed", data_array_list[2].getPublicationSectionList())
self.assertTrue("file_system_image/process_state/processed" in data_array_list[3].getPublicationSectionList()) self.assertIn("file_system_image/process_state/processed", data_array_list[3].getPublicationSectionList())
self.assertTrue("file_system_image/process_state/processed" in data_array_list[4].getPublicationSectionList()) self.assertIn("file_system_image/process_state/processed", data_array_list[4].getPublicationSectionList())
# array 5 is result of array 4 and database_debian11 # array 5 is result of array 4 and database_debian11
self.assertTrue("file_system_image/process_state/converted" in data_array_list[5].getPublicationSectionList()) self.assertIn("file_system_image/process_state/converted", data_array_list[5].getPublicationSectionList())
predecessor_list = [x.getRelativeUrl() for x in data_array_list[5].getPredecessorValueList(portal_type='Data Array')] predecessor_list = [x.getRelativeUrl() for x in data_array_list[5].getPredecessorValueList(portal_type='Data Array')]
last_detabase_debian11 = self._getRelatedDataArrayList(self.portal.compute_node_module['database_debian11'])[-1] last_detabase_debian11 = self._getRelatedDataArrayList(self.portal.compute_node_module['database_debian11'])[-1]
self.assertTrue(last_detabase_debian11.getRelativeUrl() in predecessor_list) self.assertIn(last_detabase_debian11.getRelativeUrl(), predecessor_list)
self.assertTrue(data_array_list[4].getRelativeUrl() in predecessor_list) self.assertIn(data_array_list[4].getRelativeUrl(), predecessor_list)
self.assertTrue(len(data_array_list[5].getArray()), 1) self.assertTrue(len(data_array_list[5].getArray()), 1)
# no more database to compare # no more database to compare
self.portal.portal_alarms.slapos_process_data_array.activeSense() self.portal.portal_alarms.slapos_process_data_array.activeSense()
self.tic() self.tic()
self.assertTrue("file_system_image/process_state/processed" in data_array_list[5].getPublicationSectionList()) self.assertIn("file_system_image/process_state/processed", data_array_list[5].getPublicationSectionList())
self.assertTrue('file_system_image/diff_end/different' in data_array_list[5].getPublicationSectionList()) self.assertIn('file_system_image/diff_end/different', data_array_list[5].getPublicationSectionList())
def test_data_processing_for_multi_data_ingestion(self): def test_data_processing_for_multi_data_ingestion(self):
# almost same as test_data_processing_for_sequence_data_ingestion # almost same as test_data_processing_for_sequence_data_ingestion
...@@ -516,7 +516,7 @@ class testSlapOSAbyss(SlapOSTestCaseMixin): ...@@ -516,7 +516,7 @@ class testSlapOSAbyss(SlapOSTestCaseMixin):
for compute_node in self.compute_node_list: for compute_node in self.compute_node_list:
data_array_list = self._getRelatedDataArrayList(compute_node) data_array_list = self._getRelatedDataArrayList(compute_node)
self.assertEqual(len(data_array_list), 1) self.assertEqual(len(data_array_list), 1)
self.assertTrue("file_system_image/process_state/converted" in data_array_list[0].getPublicationSectionList()) self.assertIn("file_system_image/process_state/converted", data_array_list[0].getPublicationSectionList())
# process data array # process data array
...@@ -524,17 +524,17 @@ class testSlapOSAbyss(SlapOSTestCaseMixin): ...@@ -524,17 +524,17 @@ class testSlapOSAbyss(SlapOSTestCaseMixin):
self.tic() self.tic()
data_array_list = self._getRelatedDataArrayList(self.portal.compute_node_module['database_debian10']) data_array_list = self._getRelatedDataArrayList(self.portal.compute_node_module['database_debian10'])
self.assertEqual(len(data_array_list), 1) self.assertEqual(len(data_array_list), 1)
self.assertTrue("file_system_image/process_state/processed" in data_array_list[0].getPublicationSectionList()) self.assertIn("file_system_image/process_state/processed", data_array_list[0].getPublicationSectionList())
data_array_list = self._getRelatedDataArrayList(self.portal.compute_node_module['database_debian11']) data_array_list = self._getRelatedDataArrayList(self.portal.compute_node_module['database_debian11'])
self.assertEqual(len(data_array_list), 1) self.assertEqual(len(data_array_list), 1)
self.assertTrue("file_system_image/process_state/processed" in data_array_list[0].getPublicationSectionList()) self.assertIn("file_system_image/process_state/processed", data_array_list[0].getPublicationSectionList())
data_array_list = self._getRelatedDataArrayList(self.portal.compute_node_module['node_debian10']) data_array_list = self._getRelatedDataArrayList(self.portal.compute_node_module['node_debian10'])
self.assertEqual(len(data_array_list), 1) self.assertEqual(len(data_array_list), 1)
self.assertTrue("file_system_image/process_state/processed" in data_array_list[0].getPublicationSectionList()) self.assertIn("file_system_image/process_state/processed", data_array_list[0].getPublicationSectionList())
self.portal.portal_alarms.wendelin_handle_analysis.activeSense() self.portal.portal_alarms.wendelin_handle_analysis.activeSense()
...@@ -543,49 +543,49 @@ class testSlapOSAbyss(SlapOSTestCaseMixin): ...@@ -543,49 +543,49 @@ class testSlapOSAbyss(SlapOSTestCaseMixin):
for compute_node in self.compute_node_list: for compute_node in self.compute_node_list:
data_array_list = self._getRelatedDataArrayList(compute_node) data_array_list = self._getRelatedDataArrayList(compute_node)
self.assertEqual(len(data_array_list), 2) self.assertEqual(len(data_array_list), 2)
self.assertTrue("file_system_image/process_state/converted" in data_array_list[-1].getPublicationSectionList()) self.assertIn("file_system_image/process_state/converted", data_array_list[-1].getPublicationSectionList())
self.portal.portal_alarms.slapos_process_data_array.activeSense() self.portal.portal_alarms.slapos_process_data_array.activeSense()
self.tic() self.tic()
data_array_list = self._getRelatedDataArrayList(self.portal.compute_node_module['database_debian10']) data_array_list = self._getRelatedDataArrayList(self.portal.compute_node_module['database_debian10'])
self.assertEqual(len(data_array_list), 2) self.assertEqual(len(data_array_list), 2)
self.assertTrue("file_system_image/process_state/archived" in data_array_list[0].getPublicationSectionList()) self.assertIn("file_system_image/process_state/archived", data_array_list[0].getPublicationSectionList())
self.assertTrue("file_system_image/process_state/processed" in data_array_list[1].getPublicationSectionList()) self.assertIn("file_system_image/process_state/processed", data_array_list[1].getPublicationSectionList())
data_array_list = self._getRelatedDataArrayList(self.portal.compute_node_module['database_debian11']) data_array_list = self._getRelatedDataArrayList(self.portal.compute_node_module['database_debian11'])
self.assertEqual(len(data_array_list), 2) self.assertEqual(len(data_array_list), 2)
self.assertTrue("file_system_image/process_state/archived" in data_array_list[0].getPublicationSectionList()) self.assertIn("file_system_image/process_state/archived", data_array_list[0].getPublicationSectionList())
self.assertTrue("file_system_image/process_state/processed" in data_array_list[1].getPublicationSectionList()) self.assertIn("file_system_image/process_state/processed", data_array_list[1].getPublicationSectionList())
data_array_list = self._getRelatedDataArrayList(self.portal.compute_node_module['node_debian10']) data_array_list = self._getRelatedDataArrayList(self.portal.compute_node_module['node_debian10'])
self.assertEqual(len(data_array_list), 2) self.assertEqual(len(data_array_list), 2)
self.assertTrue("file_system_image/process_state/processed" in data_array_list[0].getPublicationSectionList()) self.assertIn("file_system_image/process_state/processed", data_array_list[0].getPublicationSectionList())
self.assertTrue("file_system_image/process_state/processed" in data_array_list[1].getPublicationSectionList()) self.assertIn("file_system_image/process_state/processed", data_array_list[1].getPublicationSectionList())
self.assertTrue('file_system_image/diff_end/identical' in data_array_list[1].getPublicationSectionList()) self.assertIn('file_system_image/diff_end/identical', data_array_list[1].getPublicationSectionList())
self.portal.ERP5Site_createDataAnalysisList() self.portal.ERP5Site_createDataAnalysisList()
self.portal.ERP5Site_executeDataAnalysisList() self.portal.ERP5Site_executeDataAnalysisList()
self.tic() self.tic()
data_array_list = self._getRelatedDataArrayList(self.portal.compute_node_module['node_debian10']) data_array_list = self._getRelatedDataArrayList(self.portal.compute_node_module['node_debian10'])
self.assertEqual(len(data_array_list), 3) self.assertEqual(len(data_array_list), 3)
self.assertTrue("file_system_image/process_state/processed" in data_array_list[0].getPublicationSectionList()) self.assertIn("file_system_image/process_state/processed", data_array_list[0].getPublicationSectionList())
self.assertTrue("file_system_image/process_state/processed" in data_array_list[1].getPublicationSectionList()) self.assertIn("file_system_image/process_state/processed", data_array_list[1].getPublicationSectionList())
# This is the new one with different value # This is the new one with different value
self.assertTrue("file_system_image/process_state/converted" in data_array_list[2].getPublicationSectionList()) self.assertIn("file_system_image/process_state/converted", data_array_list[2].getPublicationSectionList())
self.portal.portal_alarms.slapos_process_data_array.activeSense() self.portal.portal_alarms.slapos_process_data_array.activeSense()
self.tic() self.tic()
data_array_list = self._getRelatedDataArrayList(self.portal.compute_node_module['node_debian10']) data_array_list = self._getRelatedDataArrayList(self.portal.compute_node_module['node_debian10'])
self.assertEqual(len(data_array_list), 4) self.assertEqual(len(data_array_list), 4)
self.assertTrue("file_system_image/process_state/processed" in data_array_list[0].getPublicationSectionList()) self.assertIn("file_system_image/process_state/processed", data_array_list[0].getPublicationSectionList())
self.assertTrue("file_system_image/process_state/processed" in data_array_list[1].getPublicationSectionList()) self.assertIn("file_system_image/process_state/processed", data_array_list[1].getPublicationSectionList())
self.assertTrue("file_system_image/process_state/processed" in data_array_list[2].getPublicationSectionList()) self.assertIn("file_system_image/process_state/processed", data_array_list[2].getPublicationSectionList())
# array 3 is the result of array 0 and array 2, Note: array 0 is the first access data # array 3 is the result of array 0 and array 2, Note: array 0 is the first access data
self.assertTrue("file_system_image/process_state/converted" in data_array_list[3].getPublicationSectionList()) self.assertIn("file_system_image/process_state/converted", data_array_list[3].getPublicationSectionList())
predecessor_list = [x.getRelativeUrl() for x in data_array_list[3].getPredecessorValueList(portal_type='Data Array')] predecessor_list = [x.getRelativeUrl() for x in data_array_list[3].getPredecessorValueList(portal_type='Data Array')]
self.assertTrue(data_array_list[0].getRelativeUrl() in predecessor_list) self.assertIn(data_array_list[0].getRelativeUrl(), predecessor_list)
self.assertTrue(data_array_list[2].getRelativeUrl() in predecessor_list) self.assertIn(data_array_list[2].getRelativeUrl(), predecessor_list)
# only have one diff # only have one diff
self.assertTrue(len(data_array_list[3].getArray()), 1) self.assertTrue(len(data_array_list[3].getArray()), 1)
...@@ -594,16 +594,16 @@ class testSlapOSAbyss(SlapOSTestCaseMixin): ...@@ -594,16 +594,16 @@ class testSlapOSAbyss(SlapOSTestCaseMixin):
# array 3 compare with database_debian10 # array 3 compare with database_debian10
data_array_list = self._getRelatedDataArrayList(self.portal.compute_node_module['node_debian10']) data_array_list = self._getRelatedDataArrayList(self.portal.compute_node_module['node_debian10'])
self.assertEqual(len(data_array_list), 5) self.assertEqual(len(data_array_list), 5)
self.assertTrue("file_system_image/process_state/processed" in data_array_list[0].getPublicationSectionList()) self.assertIn("file_system_image/process_state/processed", data_array_list[0].getPublicationSectionList())
self.assertTrue("file_system_image/process_state/processed" in data_array_list[1].getPublicationSectionList()) self.assertIn("file_system_image/process_state/processed", data_array_list[1].getPublicationSectionList())
self.assertTrue("file_system_image/process_state/processed" in data_array_list[2].getPublicationSectionList()) self.assertIn("file_system_image/process_state/processed", data_array_list[2].getPublicationSectionList())
self.assertTrue("file_system_image/process_state/processed" in data_array_list[3].getPublicationSectionList()) self.assertIn("file_system_image/process_state/processed", data_array_list[3].getPublicationSectionList())
# array 4 is result of array 3 and database_debian10 # array 4 is result of array 3 and database_debian10
self.assertTrue("file_system_image/process_state/converted" in data_array_list[4].getPublicationSectionList()) self.assertIn("file_system_image/process_state/converted", data_array_list[4].getPublicationSectionList())
predecessor_list = [x.getRelativeUrl() for x in data_array_list[4].getPredecessorValueList(portal_type='Data Array')] predecessor_list = [x.getRelativeUrl() for x in data_array_list[4].getPredecessorValueList(portal_type='Data Array')]
last_detabase_debian10 = self._getRelatedDataArrayList(self.portal.compute_node_module['database_debian10'])[-1] last_detabase_debian10 = self._getRelatedDataArrayList(self.portal.compute_node_module['database_debian10'])[-1]
self.assertTrue(last_detabase_debian10.getRelativeUrl() in predecessor_list) self.assertIn(last_detabase_debian10.getRelativeUrl(), predecessor_list)
self.assertTrue(data_array_list[3].getRelativeUrl() in predecessor_list) self.assertIn(data_array_list[3].getRelativeUrl(), predecessor_list)
self.assertTrue(len(data_array_list[4].getArray()), 1) self.assertTrue(len(data_array_list[4].getArray()), 1)
self.portal.portal_alarms.slapos_process_data_array.activeSense() self.portal.portal_alarms.slapos_process_data_array.activeSense()
...@@ -611,25 +611,25 @@ class testSlapOSAbyss(SlapOSTestCaseMixin): ...@@ -611,25 +611,25 @@ class testSlapOSAbyss(SlapOSTestCaseMixin):
# array 4 compare with database_debian11 # array 4 compare with database_debian11
data_array_list = self._getRelatedDataArrayList(self.portal.compute_node_module['node_debian10']) data_array_list = self._getRelatedDataArrayList(self.portal.compute_node_module['node_debian10'])
self.assertEqual(len(data_array_list), 6) self.assertEqual(len(data_array_list), 6)
self.assertTrue("file_system_image/process_state/processed" in data_array_list[0].getPublicationSectionList()) self.assertIn("file_system_image/process_state/processed", data_array_list[0].getPublicationSectionList())
self.assertTrue("file_system_image/process_state/processed" in data_array_list[1].getPublicationSectionList()) self.assertIn("file_system_image/process_state/processed", data_array_list[1].getPublicationSectionList())
self.assertTrue("file_system_image/process_state/processed" in data_array_list[2].getPublicationSectionList()) self.assertIn("file_system_image/process_state/processed", data_array_list[2].getPublicationSectionList())
self.assertTrue("file_system_image/process_state/processed" in data_array_list[3].getPublicationSectionList()) self.assertIn("file_system_image/process_state/processed", data_array_list[3].getPublicationSectionList())
self.assertTrue("file_system_image/process_state/processed" in data_array_list[4].getPublicationSectionList()) self.assertIn("file_system_image/process_state/processed", data_array_list[4].getPublicationSectionList())
# array 5 is result of array 4 and database_debian11 # array 5 is result of array 4 and database_debian11
self.assertTrue("file_system_image/process_state/converted" in data_array_list[5].getPublicationSectionList()) self.assertIn("file_system_image/process_state/converted", data_array_list[5].getPublicationSectionList())
predecessor_list = [x.getRelativeUrl() for x in data_array_list[5].getPredecessorValueList(portal_type='Data Array')] predecessor_list = [x.getRelativeUrl() for x in data_array_list[5].getPredecessorValueList(portal_type='Data Array')]
last_detabase_debian11 = self._getRelatedDataArrayList(self.portal.compute_node_module['database_debian11'])[-1] last_detabase_debian11 = self._getRelatedDataArrayList(self.portal.compute_node_module['database_debian11'])[-1]
self.assertTrue(last_detabase_debian11.getRelativeUrl() in predecessor_list) self.assertIn(last_detabase_debian11.getRelativeUrl(), predecessor_list)
self.assertTrue(data_array_list[4].getRelativeUrl() in predecessor_list) self.assertIn(data_array_list[4].getRelativeUrl(), predecessor_list)
self.assertTrue(len(data_array_list[5].getArray()), 1) self.assertTrue(len(data_array_list[5].getArray()), 1)
# no more database to compare # no more database to compare
self.portal.portal_alarms.slapos_process_data_array.activeSense() self.portal.portal_alarms.slapos_process_data_array.activeSense()
self.tic() self.tic()
self.assertTrue("file_system_image/process_state/processed" in data_array_list[5].getPublicationSectionList()) self.assertIn("file_system_image/process_state/processed", data_array_list[5].getPublicationSectionList())
self.assertTrue('file_system_image/diff_end/different' in data_array_list[5].getPublicationSectionList()) self.assertIn('file_system_image/diff_end/different', data_array_list[5].getPublicationSectionList())
def test_data_processing_check_copmute_node_state(self): def test_data_processing_check_copmute_node_state(self):
...@@ -666,8 +666,8 @@ class testSlapOSAbyss(SlapOSTestCaseMixin): ...@@ -666,8 +666,8 @@ class testSlapOSAbyss(SlapOSTestCaseMixin):
self.portal.portal_alarms.slapos_process_data_array.activeSense() self.portal.portal_alarms.slapos_process_data_array.activeSense()
self.tic() self.tic()
last_diff_array = self._getRelatedDataArrayList(self.portal.compute_node_module['node_debian10'])[-1] last_diff_array = self._getRelatedDataArrayList(self.portal.compute_node_module['node_debian10'])[-1]
self.assertTrue(modified_array.getReference() in last_diff_array.getReference()) self.assertIn(modified_array.getReference(), last_diff_array.getReference())
self.assertTrue(default_array.getReference() in last_diff_array.getReference()) self.assertIn(default_array.getReference(), last_diff_array.getReference())
self.portal.portal_alarms.slapos_process_data_array.activeSense() self.portal.portal_alarms.slapos_process_data_array.activeSense()
self.tic() self.tic()
self.portal.portal_alarms.slapos_process_data_array.activeSense() self.portal.portal_alarms.slapos_process_data_array.activeSense()
...@@ -696,7 +696,7 @@ class testSlapOSAbyss(SlapOSTestCaseMixin): ...@@ -696,7 +696,7 @@ class testSlapOSAbyss(SlapOSTestCaseMixin):
self.tic() self.tic()
self.portal.portal_alarms.slapos_process_data_array.activeSense() self.portal.portal_alarms.slapos_process_data_array.activeSense()
self.tic() self.tic()
self.assertTrue('file_system_image/diff_end/identical' in self._getRelatedDataArrayList(self.portal.compute_node_module['node_debian10'])[-1].getPublicationSectionList()) self.assertIn('file_system_image/diff_end/identical', self._getRelatedDataArrayList(self.portal.compute_node_module['node_debian10'])[-1].getPublicationSectionList())
self.assertTrue(self.portal.compute_node_module['node_debian10'].ComputeNode_hasModifiedFile() is None) self.assertTrue(self.portal.compute_node_module['node_debian10'].ComputeNode_hasModifiedFile() is None)
...@@ -782,42 +782,42 @@ class testSlapOSAbyss(SlapOSTestCaseMixin): ...@@ -782,42 +782,42 @@ class testSlapOSAbyss(SlapOSTestCaseMixin):
diff_server_data_array_list = [] diff_server_data_array_list = []
for i in server_data_array_list: for i in server_data_array_list:
self.assertTrue("file_system_image/process_state/processed" in i.getPublicationSectionList()) self.assertIn("file_system_image/process_state/processed", i.getPublicationSectionList())
diff_server_data_array_list.append(i.getPredecessorRelatedValue(portal_type='Data Array')) diff_server_data_array_list.append(i.getPredecessorRelatedValue(portal_type='Data Array'))
self.portal.portal_alarms.slapos_process_data_array.activeSense() self.portal.portal_alarms.slapos_process_data_array.activeSense()
self.tic() self.tic()
self.assertTrue(diff_server_data_array_list[0].getPredecessorRelatedValue(portal_type='Data Array') in reference_data_array_list[0].getPredecessorRelatedValueList(portal_type='Data Array')) self.assertIn(diff_server_data_array_list[0].getPredecessorRelatedValue(portal_type='Data Array'), reference_data_array_list[0].getPredecessorRelatedValueList(portal_type='Data Array'))
diff_1 = diff_server_data_array_list[0].getPredecessorRelatedValue(portal_type='Data Array') diff_1 = diff_server_data_array_list[0].getPredecessorRelatedValue(portal_type='Data Array')
self.assertEqual(len(diff_1.getPredecessorValueList(portal_type='Data Array')), 2) self.assertEqual(len(diff_1.getPredecessorValueList(portal_type='Data Array')), 2)
self.assertTrue("file_system_image/process_state/converted" in diff_1.getPublicationSectionList()) self.assertIn("file_system_image/process_state/converted", diff_1.getPublicationSectionList())
self.assertTrue((diff_1.getArray() == [7, 9, 10, 11, 15, 17, 18]).all()) self.assertTrue((diff_1.getArray() == [7, 9, 10, 11, 15, 17, 18]).all())
self.assertTrue(diff_server_data_array_list[1].getPredecessorRelatedValue(portal_type='Data Array') in reference_data_array_list[0].getPredecessorRelatedValueList(portal_type='Data Array')) self.assertIn(diff_server_data_array_list[1].getPredecessorRelatedValue(portal_type='Data Array'), reference_data_array_list[0].getPredecessorRelatedValueList(portal_type='Data Array'))
diff_2 = diff_server_data_array_list[1].getPredecessorRelatedValue(portal_type='Data Array') diff_2 = diff_server_data_array_list[1].getPredecessorRelatedValue(portal_type='Data Array')
self.assertEqual(len(diff_2.getPredecessorValueList(portal_type='Data Array')), 2) self.assertEqual(len(diff_2.getPredecessorValueList(portal_type='Data Array')), 2)
self.assertTrue("file_system_image/process_state/converted" in diff_2.getPublicationSectionList()) self.assertIn("file_system_image/process_state/converted", diff_2.getPublicationSectionList())
self.assertTrue((diff_2.getArray() == [2, 8, 14]).all()) self.assertTrue((diff_2.getArray() == [2, 8, 14]).all())
self.assertTrue(diff_server_data_array_list[2].getPredecessorRelatedValue(portal_type='Data Array') in reference_data_array_list[0].getPredecessorRelatedValueList(portal_type='Data Array')) self.assertIn(diff_server_data_array_list[2].getPredecessorRelatedValue(portal_type='Data Array'), reference_data_array_list[0].getPredecessorRelatedValueList(portal_type='Data Array'))
diff_3 = diff_server_data_array_list[2].getPredecessorRelatedValue(portal_type='Data Array') diff_3 = diff_server_data_array_list[2].getPredecessorRelatedValue(portal_type='Data Array')
self.assertEqual(len(diff_3.getPredecessorValueList(portal_type='Data Array')), 2) self.assertEqual(len(diff_3.getPredecessorValueList(portal_type='Data Array')), 2)
self.assertTrue("file_system_image/process_state/converted" in diff_3.getPublicationSectionList()) self.assertIn("file_system_image/process_state/converted", diff_3.getPublicationSectionList())
self.assertTrue((diff_3.getArray() == [11, 17, 31]).all()) self.assertTrue((diff_3.getArray() == [11, 17, 31]).all())
self.assertTrue(diff_server_data_array_list[3].getPredecessorRelatedValue(portal_type='Data Array') in reference_data_array_list[1].getPredecessorRelatedValueList(portal_type='Data Array')) self.assertIn(diff_server_data_array_list[3].getPredecessorRelatedValue(portal_type='Data Array'), reference_data_array_list[1].getPredecessorRelatedValueList(portal_type='Data Array'))
diff_4 = diff_server_data_array_list[3].getPredecessorRelatedValue(portal_type='Data Array') diff_4 = diff_server_data_array_list[3].getPredecessorRelatedValue(portal_type='Data Array')
self.assertEqual(len(diff_4.getPredecessorValueList(portal_type='Data Array')), 2) self.assertEqual(len(diff_4.getPredecessorValueList(portal_type='Data Array')), 2)
self.assertTrue("file_system_image/process_state/converted" in diff_4.getPublicationSectionList()) self.assertIn("file_system_image/process_state/converted", diff_4.getPublicationSectionList())
self.assertTrue((diff_4.getArray() == [2, 24]).all()) self.assertTrue((diff_4.getArray() == [2, 24]).all())
self.assertTrue(diff_server_data_array_list[4].getPredecessorRelatedValue(portal_type='Data Array') in reference_data_array_list[1].getPredecessorRelatedValueList(portal_type='Data Array')) self.assertIn(diff_server_data_array_list[4].getPredecessorRelatedValue(portal_type='Data Array'), reference_data_array_list[1].getPredecessorRelatedValueList(portal_type='Data Array'))
diff_5 = diff_server_data_array_list[4].getPredecessorRelatedValue(portal_type='Data Array') diff_5 = diff_server_data_array_list[4].getPredecessorRelatedValue(portal_type='Data Array')
self.assertEqual(len(diff_5.getPredecessorValueList(portal_type='Data Array')), 2) self.assertEqual(len(diff_5.getPredecessorValueList(portal_type='Data Array')), 2)
self.assertTrue("file_system_image/process_state/converted" in diff_5.getPublicationSectionList()) self.assertIn("file_system_image/process_state/converted", diff_5.getPublicationSectionList())
self.assertTrue((diff_5.getArray() == [17, 28, 31]).all(), diff_5.getRelativeUrl()) self.assertTrue((diff_5.getArray() == [17, 28, 31]).all(), diff_5.getRelativeUrl())
...@@ -826,30 +826,30 @@ class testSlapOSAbyss(SlapOSTestCaseMixin): ...@@ -826,30 +826,30 @@ class testSlapOSAbyss(SlapOSTestCaseMixin):
self.assertTrue('file_system_image/diff_end/different' in diff_4.getPublicationSectionList()) self.assertIn('file_system_image/diff_end/different', diff_4.getPublicationSectionList())
self.assertTrue('file_system_image/diff_end/different' in diff_5.getPublicationSectionList()) self.assertIn('file_system_image/diff_end/different', diff_5.getPublicationSectionList())
self.assertTrue(diff_1.getPredecessorRelatedValue(portal_type='Data Array') in reference_data_array_list[1].getPredecessorRelatedValueList(portal_type='Data Array')) self.assertIn(diff_1.getPredecessorRelatedValue(portal_type='Data Array'), reference_data_array_list[1].getPredecessorRelatedValueList(portal_type='Data Array'))
diff_6 = diff_1.getPredecessorRelatedValue(portal_type='Data Array') diff_6 = diff_1.getPredecessorRelatedValue(portal_type='Data Array')
self.assertEqual(len(diff_6.getPredecessorValueList(portal_type='Data Array')), 2) self.assertEqual(len(diff_6.getPredecessorValueList(portal_type='Data Array')), 2)
self.assertTrue("file_system_image/process_state/converted" in diff_6.getPublicationSectionList()) self.assertIn("file_system_image/process_state/converted", diff_6.getPublicationSectionList())
self.assertTrue((diff_6.getArray() == [15, 17, 18]).all(), diff_6.getRelativeUrl()) self.assertTrue((diff_6.getArray() == [15, 17, 18]).all(), diff_6.getRelativeUrl())
self.assertTrue(diff_2.getPredecessorRelatedValue(portal_type='Data Array') in reference_data_array_list[1].getPredecessorRelatedValueList(portal_type='Data Array')) self.assertIn(diff_2.getPredecessorRelatedValue(portal_type='Data Array'), reference_data_array_list[1].getPredecessorRelatedValueList(portal_type='Data Array'))
diff_7 = diff_2.getPredecessorRelatedValue(portal_type='Data Array') diff_7 = diff_2.getPredecessorRelatedValue(portal_type='Data Array')
self.assertEqual(len(diff_7.getPredecessorValueList(portal_type='Data Array')), 2) self.assertEqual(len(diff_7.getPredecessorValueList(portal_type='Data Array')), 2)
self.assertTrue("file_system_image/process_state/converted" in diff_7.getPublicationSectionList()) self.assertIn("file_system_image/process_state/converted", diff_7.getPublicationSectionList())
self.assertTrue((diff_7.getArray() == [2]).all(), diff_7.getRelativeUrl()) self.assertTrue((diff_7.getArray() == [2]).all(), diff_7.getRelativeUrl())
self.assertTrue(diff_3.getPredecessorRelatedValue(portal_type='Data Array') in reference_data_array_list[1].getPredecessorRelatedValueList(portal_type='Data Array')) self.assertIn(diff_3.getPredecessorRelatedValue(portal_type='Data Array'), reference_data_array_list[1].getPredecessorRelatedValueList(portal_type='Data Array'))
diff_8 = diff_3.getPredecessorRelatedValue(portal_type='Data Array') diff_8 = diff_3.getPredecessorRelatedValue(portal_type='Data Array')
self.assertEqual(len(diff_8.getPredecessorValueList(portal_type='Data Array')), 2) self.assertEqual(len(diff_8.getPredecessorValueList(portal_type='Data Array')), 2)
self.assertTrue("file_system_image/process_state/converted" in diff_8.getPublicationSectionList()) self.assertIn("file_system_image/process_state/converted", diff_8.getPublicationSectionList())
self.assertTrue((diff_8.getArray() == [17, 31]).all(), diff_8.getRelativeUrl()) self.assertTrue((diff_8.getArray() == [17, 31]).all(), diff_8.getRelativeUrl())
self.portal.portal_alarms.slapos_process_data_array.activeSense() self.portal.portal_alarms.slapos_process_data_array.activeSense()
self.tic() self.tic()
for i in [diff_6, diff_7, diff_8]: for i in [diff_6, diff_7, diff_8]:
self.assertTrue('file_system_image/diff_end/different' in i.getPublicationSectionList()) self.assertIn('file_system_image/diff_end/different', i.getPublicationSectionList())
...@@ -1403,7 +1403,7 @@ class TestSlapOSSaleInvoiceTransactionBuilder(TestSlapOSSalePackingListBuilder): ...@@ -1403,7 +1403,7 @@ class TestSlapOSSaleInvoiceTransactionBuilder(TestSlapOSSalePackingListBuilder):
self.assertFalse(transaction_line.hasStopDate()) self.assertFalse(transaction_line.hasStopDate())
self.assertEqual([], transaction_line.contentValues( self.assertEqual([], transaction_line.contentValues(
portal_type='Delivery Cell')) portal_type='Delivery Cell'))
self.assertTrue(simulation_movement.getRelativeUrl() in self.assertIn(simulation_movement.getRelativeUrl(),
transaction_line.getDeliveryRelatedList( transaction_line.getDeliveryRelatedList(
portal_type='Simulation Movement')) portal_type='Simulation Movement'))
...@@ -1741,7 +1741,7 @@ class TestSlapOSSaleInvoiceTransactionTradeModelBuilder(TestSlapOSSalePackingLis ...@@ -1741,7 +1741,7 @@ class TestSlapOSSaleInvoiceTransactionTradeModelBuilder(TestSlapOSSalePackingLis
self.assertFalse(transaction_line.hasStopDate()) self.assertFalse(transaction_line.hasStopDate())
self.assertEqual([], transaction_line.contentValues( self.assertEqual([], transaction_line.contentValues(
portal_type='Delivery Cell')) portal_type='Delivery Cell'))
self.assertTrue(simulation_movement.getRelativeUrl() in self.assertIn(simulation_movement.getRelativeUrl(),
transaction_line.getDeliveryRelatedList( transaction_line.getDeliveryRelatedList(
portal_type='Simulation Movement')) portal_type='Simulation Movement'))
......
...@@ -30,10 +30,10 @@ class TestInstanceTree(TestSlapOSConstraintMixin): ...@@ -30,10 +30,10 @@ class TestInstanceTree(TestSlapOSConstraintMixin):
def test_periodicity_hour_list_value(self): def test_periodicity_hour_list_value(self):
value = 7 value = 7
message = 'Attribute periodicity_hour_list value is [7] but should be [0]' message = 'Attribute periodicity_hour_list value is [7] but should be [0]'
self.assertFalse(message in self.getMessageList(self.subscription)) self.assertNotIn(message, self.getMessageList(self.subscription))
self.subscription.setPeriodicityHour(value) self.subscription.setPeriodicityHour(value)
self.assertTrue(message in self.getMessageList(self.subscription)) self.assertIn(message, self.getMessageList(self.subscription))
self.subscription.setPeriodicityHour(0) self.subscription.setPeriodicityHour(0)
...@@ -44,10 +44,10 @@ class TestInstanceTree(TestSlapOSConstraintMixin): ...@@ -44,10 +44,10 @@ class TestInstanceTree(TestSlapOSConstraintMixin):
def test_periodicity_minute_list_value(self): def test_periodicity_minute_list_value(self):
value = 7 value = 7
message = 'Attribute periodicity_minute_list value is [7] but should be [0]' message = 'Attribute periodicity_minute_list value is [7] but should be [0]'
self.assertFalse(message in self.getMessageList(self.subscription)) self.assertNotIn(message, self.getMessageList(self.subscription))
self.subscription.setPeriodicityMinute(value) self.subscription.setPeriodicityMinute(value)
self.assertTrue(message in self.getMessageList(self.subscription)) self.assertIn(message, self.getMessageList(self.subscription))
self.subscription.setPeriodicityMinute(0) self.subscription.setPeriodicityMinute(0)
...@@ -57,36 +57,36 @@ class TestInstanceTree(TestSlapOSConstraintMixin): ...@@ -57,36 +57,36 @@ class TestInstanceTree(TestSlapOSConstraintMixin):
def test_periodicity_month_day_list_lenght(self): def test_periodicity_month_day_list_lenght(self):
message = 'There was too many objects in periodicity_month_day_list' message = 'There was too many objects in periodicity_month_day_list'
self.assertFalse(message in self.getMessageList(self.subscription)) self.assertNotIn(message, self.getMessageList(self.subscription))
self.subscription.setPeriodicityMonthDayList([1, 2]) self.subscription.setPeriodicityMonthDayList([1, 2])
self.assertTrue(message in self.getMessageList(self.subscription)) self.assertIn(message, self.getMessageList(self.subscription))
self.subscription.setPeriodicityMonthDayList([1]) self.subscription.setPeriodicityMonthDayList([1])
self.assertFalse(message in self.getMessageList(self.subscription)) self.assertNotIn(message, self.getMessageList(self.subscription))
def test_periodicity_month_day_value_range(self): def test_periodicity_month_day_value_range(self):
message = 'The periodicity_month_day value is not between 1 and 28 '\ message = 'The periodicity_month_day value is not between 1 and 28 '\
'inclusive' 'inclusive'
self.assertFalse(message in self.getMessageList(self.subscription)) self.assertNotIn(message, self.getMessageList(self.subscription))
self.subscription.setPeriodicityMonthDay(0) self.subscription.setPeriodicityMonthDay(0)
self.assertTrue(message in self.getMessageList(self.subscription)) self.assertIn(message, self.getMessageList(self.subscription))
self.subscription.setPeriodicityMonthDay(29) self.subscription.setPeriodicityMonthDay(29)
self.assertTrue(message in self.getMessageList(self.subscription)) self.assertIn(message, self.getMessageList(self.subscription))
self.subscription.setPeriodicityMonthDay(28) self.subscription.setPeriodicityMonthDay(28)
self.assertFalse(message in self.getMessageList(self.subscription)) self.assertNotIn(message, self.getMessageList(self.subscription))
self.subscription.setPeriodicityMonthDay(1) self.subscription.setPeriodicityMonthDay(1)
self.assertFalse(message in self.getMessageList(self.subscription)) self.assertNotIn(message, self.getMessageList(self.subscription))
self.subscription.setPeriodicityMonthDay(15) self.subscription.setPeriodicityMonthDay(15)
self.assertFalse(message in self.getMessageList(self.subscription)) self.assertNotIn(message, self.getMessageList(self.subscription))
self.subscription.setPeriodicityMonthDay(None) self.subscription.setPeriodicityMonthDay(None)
self.assertFalse(message in self.getMessageList(self.subscription)) self.assertNotIn(message, self.getMessageList(self.subscription))
def test_periodicity_property(self): def test_periodicity_property(self):
template = 'Property existence error for property %s, this '\ template = 'Property existence error for property %s, this '\
...@@ -101,16 +101,16 @@ class TestInstanceTree(TestSlapOSConstraintMixin): ...@@ -101,16 +101,16 @@ class TestInstanceTree(TestSlapOSConstraintMixin):
class TestSaleInvoiceTransaction(TestSlapOSConstraintMixin): class TestSaleInvoiceTransaction(TestSlapOSConstraintMixin):
@withAbort @withAbort
def _test_currency(self, invoice, setter, message): def _test_currency(self, invoice, setter, message):
self.assertTrue(message in self.getMessageList(invoice)) self.assertIn(message, self.getMessageList(invoice))
currency = self.portal.currency_module.newContent(portal_type='Currency') currency = self.portal.currency_module.newContent(portal_type='Currency')
setter(currency.getRelativeUrl()) setter(currency.getRelativeUrl())
self.assertFalse(message in self.getMessageList(invoice)) self.assertNotIn(message, self.getMessageList(invoice))
resource = self.portal.service_module.newContent(portal_type='Service') resource = self.portal.service_module.newContent(portal_type='Service')
setter(resource.getRelativeUrl()) setter(resource.getRelativeUrl())
self.assertTrue(message in self.getMessageList(invoice)) self.assertIn(message, self.getMessageList(invoice))
def test_price_currency(self): def test_price_currency(self):
invoice = self.portal.accounting_module.newContent( invoice = self.portal.accounting_module.newContent(
...@@ -133,34 +133,34 @@ class TestSaleInvoiceTransaction(TestSlapOSConstraintMixin): ...@@ -133,34 +133,34 @@ class TestSaleInvoiceTransaction(TestSlapOSConstraintMixin):
setter = invoice.setSpecialise setter = invoice.setSpecialise
message = "Arity Error for Relation ['specialise'] and Type "\ message = "Arity Error for Relation ['specialise'] and Type "\
"('Sale Trade Condition',), arity is equal to 0 but should be at least 1" "('Sale Trade Condition',), arity is equal to 0 but should be at least 1"
self.assertTrue(message in self.getMessageList(invoice)) self.assertIn(message, self.getMessageList(invoice))
sale_condition = self.portal.sale_trade_condition_module.newContent( sale_condition = self.portal.sale_trade_condition_module.newContent(
portal_type='Sale Trade Condition') portal_type='Sale Trade Condition')
setter(sale_condition.getRelativeUrl()) setter(sale_condition.getRelativeUrl())
self.assertFalse(message in self.getMessageList(invoice)) self.assertNotIn(message, self.getMessageList(invoice))
purchase_condition = self.portal.purchase_trade_condition_module.newContent( purchase_condition = self.portal.purchase_trade_condition_module.newContent(
portal_type='Purchase Trade Condition') portal_type='Purchase Trade Condition')
setter(purchase_condition.getRelativeUrl()) setter(purchase_condition.getRelativeUrl())
self.assertTrue(message in self.getMessageList(invoice)) self.assertIn(message, self.getMessageList(invoice))
@withAbort @withAbort
def test_specialise_value(self): def test_specialise_value(self):
invoice = self.portal.accounting_module.newContent( invoice = self.portal.accounting_module.newContent(
portal_type='Sale Invoice Transaction') portal_type='Sale Invoice Transaction')
message = "Only SlapOS trade condition is allowed" message = "Only SlapOS trade condition is allowed"
self.assertTrue(message in self.getMessageList(invoice)) self.assertIn(message, self.getMessageList(invoice))
sale_condition = self.portal.sale_trade_condition_module.newContent( sale_condition = self.portal.sale_trade_condition_module.newContent(
portal_type='Sale Trade Condition') portal_type='Sale Trade Condition')
invoice.setSpecialise(sale_condition.getRelativeUrl()) invoice.setSpecialise(sale_condition.getRelativeUrl())
self.assertTrue(message in self.getMessageList(invoice)) self.assertIn(message, self.getMessageList(invoice))
invoice.setSpecialise('sale_trade_condition_module/slapos_aggregated_trade_condition') invoice.setSpecialise('sale_trade_condition_module/slapos_aggregated_trade_condition')
self.assertFalse(message in self.getMessageList(invoice)) self.assertNotIn(message, self.getMessageList(invoice))
@withAbort @withAbort
def test_total_price_equal_accounting(self): def test_total_price_equal_accounting(self):
...@@ -170,13 +170,13 @@ class TestSaleInvoiceTransaction(TestSlapOSConstraintMixin): ...@@ -170,13 +170,13 @@ class TestSaleInvoiceTransaction(TestSlapOSConstraintMixin):
price_currency='currency_module/EUR') price_currency='currency_module/EUR')
invoice.newContent(portal_type='Invoice Line', quantity=1., price=1.) invoice.newContent(portal_type='Invoice Line', quantity=1., price=1.)
self.assertFalse(message in self.getMessageList(invoice)) self.assertNotIn(message, self.getMessageList(invoice))
self.portal.portal_workflow._jumpToStateFor(invoice, 'confirmed') self.portal.portal_workflow._jumpToStateFor(invoice, 'confirmed')
self.assertTrue(message in self.getMessageList(invoice)) self.assertIn(message, self.getMessageList(invoice))
invoice.receivable.setQuantity(-1.0) invoice.receivable.setQuantity(-1.0)
invoice.income.setQuantity(1.0) invoice.income.setQuantity(1.0)
self.assertFalse(message in self.getMessageList(invoice)) self.assertNotIn(message, self.getMessageList(invoice))
@withAbort @withAbort
def test_trade_model_match_lines(self): def test_trade_model_match_lines(self):
...@@ -188,14 +188,14 @@ class TestSaleInvoiceTransaction(TestSlapOSConstraintMixin): ...@@ -188,14 +188,14 @@ class TestSaleInvoiceTransaction(TestSlapOSConstraintMixin):
invoice.newContent(portal_type='Invoice Line', quantity=1., price=1., invoice.newContent(portal_type='Invoice Line', quantity=1., price=1.,
base_contribution='base_amount/invoicing/taxable') base_contribution='base_amount/invoicing/taxable')
self.assertFalse(message in self.getMessageList(invoice)) self.assertNotIn(message, self.getMessageList(invoice))
self.portal.portal_workflow._jumpToStateFor(invoice, 'confirmed') self.portal.portal_workflow._jumpToStateFor(invoice, 'confirmed')
self.assertTrue(message in self.getMessageList(invoice)) self.assertIn(message, self.getMessageList(invoice))
invoice.newContent(portal_type='Invoice Line', quantity=1., price=.196, invoice.newContent(portal_type='Invoice Line', quantity=1., price=.196,
use='trade/tax', use='trade/tax',
) )
self.assertFalse(message in self.getMessageList(invoice)) self.assertNotIn(message, self.getMessageList(invoice))
@withAbort @withAbort
def test_use_trade_sale_total_price_matches_delivery_constraint(self): def test_use_trade_sale_total_price_matches_delivery_constraint(self):
...@@ -210,16 +210,16 @@ class TestSaleInvoiceTransaction(TestSlapOSConstraintMixin): ...@@ -210,16 +210,16 @@ class TestSaleInvoiceTransaction(TestSlapOSConstraintMixin):
invoice_line = invoice.newContent(portal_type='Invoice Line', quantity=2., invoice_line = invoice.newContent(portal_type='Invoice Line', quantity=2.,
price=1., use='trade/sale') price=1., use='trade/sale')
self.assertFalse(message in self.getMessageList(invoice)) self.assertNotIn(message, self.getMessageList(invoice))
self.portal.portal_workflow._jumpToStateFor(invoice, 'confirmed') self.portal.portal_workflow._jumpToStateFor(invoice, 'confirmed')
self.assertFalse(message in self.getMessageList(invoice)) self.assertNotIn(message, self.getMessageList(invoice))
invoice.setSpecialise('sale_trade_condition_module/slapos_aggregated_trade_condition') invoice.setSpecialise('sale_trade_condition_module/slapos_aggregated_trade_condition')
self.assertTrue(message in self.getMessageList(invoice)) self.assertIn(message, self.getMessageList(invoice))
invoice_line.setQuantity(1.) invoice_line.setQuantity(1.)
self.assertFalse(message in self.getMessageList(invoice)) self.assertNotIn(message, self.getMessageList(invoice))
invoice.newContent(portal_type='Invoice Line', quantity=2., invoice.newContent(portal_type='Invoice Line', quantity=2.,
price=1.) price=1.)
self.assertFalse(message in self.getMessageList(invoice)) self.assertNotIn(message, self.getMessageList(invoice))
class TestSalePackingList(TestSlapOSConstraintMixin): class TestSalePackingList(TestSlapOSConstraintMixin):
@withAbort @withAbort
...@@ -228,9 +228,9 @@ class TestSalePackingList(TestSlapOSConstraintMixin): ...@@ -228,9 +228,9 @@ class TestSalePackingList(TestSlapOSConstraintMixin):
delivery = self.portal.sale_packing_list_module.newContent( delivery = self.portal.sale_packing_list_module.newContent(
portal_type='Sale Packing List') portal_type='Sale Packing List')
self.assertTrue(message in self.getMessageList(delivery)) self.assertIn(message, self.getMessageList(delivery))
delivery.newContent(portal_type='Sale Packing List Line') delivery.newContent(portal_type='Sale Packing List Line')
self.assertFalse(message in self.getMessageList(delivery)) self.assertNotIn(message, self.getMessageList(delivery))
@withAbort @withAbort
def test_reference_not_empty(self): def test_reference_not_empty(self):
...@@ -238,29 +238,29 @@ class TestSalePackingList(TestSlapOSConstraintMixin): ...@@ -238,29 +238,29 @@ class TestSalePackingList(TestSlapOSConstraintMixin):
delivery = self.portal.sale_packing_list_module.newContent( delivery = self.portal.sale_packing_list_module.newContent(
portal_type='Sale Packing List') portal_type='Sale Packing List')
self.assertFalse(message in self.getMessageList(delivery)) self.assertNotIn(message, self.getMessageList(delivery))
delivery.setReference(None) delivery.setReference(None)
self.assertTrue(message in self.getMessageList(delivery)) self.assertIn(message, self.getMessageList(delivery))
@withAbort @withAbort
def test_price_currency(self): def test_price_currency(self):
message = 'Exactly one Currency shall be selected' message = 'Exactly one Currency shall be selected'
delivery = self.portal.sale_packing_list_module.newContent( delivery = self.portal.sale_packing_list_module.newContent(
portal_type='Sale Packing List') portal_type='Sale Packing List')
self.assertTrue(message in self.getMessageList(delivery)) self.assertIn(message, self.getMessageList(delivery))
resource = self.portal.service_module.newContent(portal_type='Service') resource = self.portal.service_module.newContent(portal_type='Service')
delivery.setPriceCurrency(resource.getRelativeUrl()) delivery.setPriceCurrency(resource.getRelativeUrl())
self.assertTrue(message in self.getMessageList(delivery)) self.assertIn(message, self.getMessageList(delivery))
currency_1 = self.portal.currency_module.newContent(portal_type='Currency') currency_1 = self.portal.currency_module.newContent(portal_type='Currency')
currency_2 = self.portal.currency_module.newContent(portal_type='Currency') currency_2 = self.portal.currency_module.newContent(portal_type='Currency')
delivery.setPriceCurrencyList([currency_1.getRelativeUrl(), delivery.setPriceCurrencyList([currency_1.getRelativeUrl(),
currency_2.getRelativeUrl()]) currency_2.getRelativeUrl()])
self.assertTrue(message in self.getMessageList(delivery)) self.assertIn(message, self.getMessageList(delivery))
delivery.setPriceCurrency(currency_1.getRelativeUrl()) delivery.setPriceCurrency(currency_1.getRelativeUrl())
self.assertFalse(message in self.getMessageList(delivery)) self.assertNotIn(message, self.getMessageList(delivery))
@withAbort @withAbort
def _test_category_arrow(self, category): def _test_category_arrow(self, category):
...@@ -278,17 +278,17 @@ class TestSalePackingList(TestSlapOSConstraintMixin): ...@@ -278,17 +278,17 @@ class TestSalePackingList(TestSlapOSConstraintMixin):
portal_type='Organisation').getRelativeUrl() portal_type='Organisation').getRelativeUrl()
key = '%s_list' % category key = '%s_list' % category
self.assertTrue(message in self.getMessageList(delivery)) self.assertIn(message, self.getMessageList(delivery))
delivery.edit(**{key: [resource]}) delivery.edit(**{key: [resource]})
self.assertTrue(message in self.getMessageList(delivery)) self.assertIn(message, self.getMessageList(delivery))
delivery.edit(**{key: [person, organisation]}) delivery.edit(**{key: [person, organisation]})
self.assertTrue(message_2 in self.getMessageList(delivery)) self.assertIn(message_2, self.getMessageList(delivery))
delivery.edit(**{key: [person]}) delivery.edit(**{key: [person]})
self.assertFalse(message in self.getMessageList(delivery)) self.assertNotIn(message, self.getMessageList(delivery))
self.assertFalse(message_2 in self.getMessageList(delivery)) self.assertNotIn(message_2, self.getMessageList(delivery))
delivery.edit(**{key: [organisation]}) delivery.edit(**{key: [organisation]})
self.assertFalse(message in self.getMessageList(delivery)) self.assertNotIn(message, self.getMessageList(delivery))
self.assertFalse(message_2 in self.getMessageList(delivery)) self.assertNotIn(message_2, self.getMessageList(delivery))
def test_destination(self): def test_destination(self):
self._test_category_arrow('destination') self._test_category_arrow('destination')
...@@ -322,23 +322,23 @@ class TestSalePackingList(TestSlapOSConstraintMixin): ...@@ -322,23 +322,23 @@ class TestSalePackingList(TestSlapOSConstraintMixin):
portal_type='Sale Trade Condition').getRelativeUrl() portal_type='Sale Trade Condition').getRelativeUrl()
key = '%s_list' % category key = '%s_list' % category
self.assertTrue(message in self.getMessageList(delivery)) self.assertIn(message, self.getMessageList(delivery))
delivery.edit(**{key: [resource]}) delivery.edit(**{key: [resource]})
self.assertTrue(message in self.getMessageList(delivery)) self.assertIn(message, self.getMessageList(delivery))
delivery.edit(**{key: [stc_1, stc_2]}) delivery.edit(**{key: [stc_1, stc_2]})
self.assertTrue(message_2 in self.getMessageList(delivery)) self.assertIn(message_2, self.getMessageList(delivery))
delivery.edit(**{key: [stc_1]}) delivery.edit(**{key: [stc_1]})
self.assertFalse(message in self.getMessageList(delivery)) self.assertNotIn(message, self.getMessageList(delivery))
self.assertFalse(message_2 in self.getMessageList(delivery)) self.assertNotIn(message_2, self.getMessageList(delivery))
@withAbort @withAbort
def test_start_date(self): def test_start_date(self):
message = 'Property start_date must be defined' message = 'Property start_date must be defined'
delivery = self.portal.sale_packing_list_module.newContent( delivery = self.portal.sale_packing_list_module.newContent(
portal_type='Sale Packing List') portal_type='Sale Packing List')
self.assertTrue(message in self.getMessageList(delivery)) self.assertIn(message, self.getMessageList(delivery))
delivery.setStartDate('2012/01/01') delivery.setStartDate('2012/01/01')
self.assertFalse(message in self.getMessageList(delivery)) self.assertNotIn(message, self.getMessageList(delivery))
class TestSalePackingListLine(TestSlapOSConstraintMixin): class TestSalePackingListLine(TestSlapOSConstraintMixin):
@withAbort @withAbort
...@@ -350,14 +350,14 @@ class TestSalePackingListLine(TestSlapOSConstraintMixin): ...@@ -350,14 +350,14 @@ class TestSalePackingListLine(TestSlapOSConstraintMixin):
delivery_line = self.portal.sale_packing_list_module.newContent( delivery_line = self.portal.sale_packing_list_module.newContent(
portal_type='Sale Packing List').newContent( portal_type='Sale Packing List').newContent(
portal_type='Sale Packing List Line') portal_type='Sale Packing List Line')
self.assertTrue(message_price in self.getMessageList(delivery_line)) self.assertIn(message_price, self.getMessageList(delivery_line))
self.assertTrue(message_quantity in self.getMessageList(delivery_line)) self.assertIn(message_quantity, self.getMessageList(delivery_line))
delivery_line.setQuantity(1.0) delivery_line.setQuantity(1.0)
self.assertTrue(message_price in self.getMessageList(delivery_line)) self.assertIn(message_price, self.getMessageList(delivery_line))
self.assertFalse(message_quantity in self.getMessageList(delivery_line)) self.assertNotIn(message_quantity, self.getMessageList(delivery_line))
delivery_line.setPrice(1.0) delivery_line.setPrice(1.0)
self.assertFalse(message_price in self.getMessageList(delivery_line)) self.assertNotIn(message_price, self.getMessageList(delivery_line))
self.assertFalse(message_quantity in self.getMessageList(delivery_line)) self.assertNotIn(message_quantity, self.getMessageList(delivery_line))
@withAbort @withAbort
def test_resource_arity(self): def test_resource_arity(self):
...@@ -377,14 +377,14 @@ class TestSalePackingListLine(TestSlapOSConstraintMixin): ...@@ -377,14 +377,14 @@ class TestSalePackingListLine(TestSlapOSConstraintMixin):
portal_type='Service').getRelativeUrl() portal_type='Service').getRelativeUrl()
key = '%s_list' % category key = '%s_list' % category
self.assertTrue(message in self.getMessageList(delivery_line)) self.assertIn(message, self.getMessageList(delivery_line))
delivery_line.edit(**{key: [product]}) delivery_line.edit(**{key: [product]})
self.assertTrue(message in self.getMessageList(delivery_line)) self.assertIn(message, self.getMessageList(delivery_line))
delivery_line.edit(**{key: [service_1, service_2]}) delivery_line.edit(**{key: [service_1, service_2]})
self.assertTrue(message_2 in self.getMessageList(delivery_line)) self.assertIn(message_2, self.getMessageList(delivery_line))
delivery_line.edit(**{key: [service_1]}) delivery_line.edit(**{key: [service_1]})
self.assertFalse(message in self.getMessageList(delivery_line)) self.assertNotIn(message, self.getMessageList(delivery_line))
self.assertFalse(message_2 in self.getMessageList(delivery_line)) self.assertNotIn(message_2, self.getMessageList(delivery_line))
class TestSalePackingListLineConsumption(TestSlapOSConstraintMixin): class TestSalePackingListLineConsumption(TestSlapOSConstraintMixin):
@withAbort @withAbort
...@@ -397,15 +397,15 @@ class TestSalePackingListLineConsumption(TestSlapOSConstraintMixin): ...@@ -397,15 +397,15 @@ class TestSalePackingListLineConsumption(TestSlapOSConstraintMixin):
portal_type='Product').getRelativeUrl() portal_type='Product').getRelativeUrl()
key = '%s_list' % category key = '%s_list' % category
self.assertFalse(message in self.getMessageList(delivery_line)) self.assertNotIn(message, self.getMessageList(delivery_line))
delivery.edit(specialise='sale_trade_condition_module/slapos_consumption_trade_condition') delivery.edit(specialise='sale_trade_condition_module/slapos_consumption_trade_condition')
self.assertTrue(message in self.getMessageList(delivery_line)) self.assertIn(message, self.getMessageList(delivery_line))
delivery_line.edit(**{key: [product]}) delivery_line.edit(**{key: [product]})
self.assertTrue(message in self.getMessageList(delivery_line)) self.assertIn(message, self.getMessageList(delivery_line))
delivery_line.edit(**{key: [aggregate_1, aggregate_2]}) delivery_line.edit(**{key: [aggregate_1, aggregate_2]})
self.assertTrue(message in self.getMessageList(delivery_line)) self.assertIn(message, self.getMessageList(delivery_line))
delivery_line.edit(**{key: [aggregate_1]}) delivery_line.edit(**{key: [aggregate_1]})
self.assertFalse(message in self.getMessageList(delivery_line)) self.assertNotIn(message, self.getMessageList(delivery_line))
def test_aggregate_instance_tree(self): def test_aggregate_instance_tree(self):
self._test_aggregate("There should be one Instance Tree related", self._test_aggregate("There should be one Instance Tree related",
......
...@@ -138,7 +138,7 @@ class SlapOSCacheMixin: ...@@ -138,7 +138,7 @@ class SlapOSCacheMixin:
'state': state, 'state': state,
'reference': self.getReference(), 'reference': self.getReference(),
'portal_type': self.getPortalType() 'portal_type': self.getPortalType()
}) }, sort_keys=True)
cache_duration = self._getAccessStatusCacheFactory().cache_duration cache_duration = self._getAccessStatusCacheFactory().cache_duration
self._getAccessStatusPlugin().set(self._getAccessStatusCacheKey(), self._getAccessStatusPlugin().set(self._getAccessStatusCacheKey(),
......
...@@ -125,7 +125,7 @@ class DefaultScenarioMixin(TestSlapOSSecurityMixin): ...@@ -125,7 +125,7 @@ class DefaultScenarioMixin(TestSlapOSSecurityMixin):
def requestComputeNode(self, title): def requestComputeNode(self, title):
requestXml = self.portal.portal_slap.requestComputer(title) requestXml = self.portal.portal_slap.requestComputer(title)
self.tic() self.tic()
self.assertTrue('marshal' in requestXml) self.assertIn('marshal', requestXml)
compute_node = xml_marshaller.xml_marshaller.loads(requestXml) compute_node = xml_marshaller.xml_marshaller.loads(requestXml)
compute_node_id = getattr(compute_node, '_computer_id', None) compute_node_id = getattr(compute_node, '_computer_id', None)
self.assertNotEqual(None, compute_node_id) self.assertNotEqual(None, compute_node_id)
......
...@@ -115,7 +115,9 @@ class TestSlapOSCloudSlapOSCacheMixin( ...@@ -115,7 +115,9 @@ class TestSlapOSCloudSlapOSCacheMixin(
'since': '%s' % since, 'since': '%s' % since,
'state': "", 'state': "",
"text": "#access TEST123 %s" % doc.getUid() "text": "#access TEST123 %s" % doc.getUid()
}) },
sort_keys=True,
)
def getBaseExpectedDict(doc): def getBaseExpectedDict(doc):
return _decode_with_json({ return _decode_with_json({
"portal_type": doc.getPortalType(), "portal_type": doc.getPortalType(),
...@@ -187,7 +189,9 @@ class TestSlapOSCloudSlapOSCacheMixin( ...@@ -187,7 +189,9 @@ class TestSlapOSCloudSlapOSCacheMixin(
'since': '%s' % since, 'since': '%s' % since,
'state': "", 'state': "",
"text": "#access TEST123 %s" % doc.getUid() "text": "#access TEST123 %s" % doc.getUid()
}) },
sort_keys=True,
)
def getBaseExpectedDict(doc): def getBaseExpectedDict(doc):
return _decode_with_json({ return _decode_with_json({
"portal_type": doc.getPortalType(), "portal_type": doc.getPortalType(),
...@@ -267,7 +271,9 @@ class TestSlapOSCloudSlapOSCacheMixin( ...@@ -267,7 +271,9 @@ class TestSlapOSCloudSlapOSCacheMixin(
'since': '%s' % since, 'since': '%s' % since,
'state': "", 'state': "",
"text": "#error TEST123 %s" % doc.getUid() "text": "#error TEST123 %s" % doc.getUid()
}) },
sort_keys=True,
)
def getBaseExpectedDict(doc): def getBaseExpectedDict(doc):
return _decode_with_json({ return _decode_with_json({
"portal_type": doc.getPortalType(), "portal_type": doc.getPortalType(),
...@@ -338,7 +344,9 @@ class TestSlapOSCloudSlapOSCacheMixin( ...@@ -338,7 +344,9 @@ class TestSlapOSCloudSlapOSCacheMixin(
'since': '%s' % since, 'since': '%s' % since,
'state': "", 'state': "",
"text": "#building TEST123 %s" % doc.getUid() "text": "#building TEST123 %s" % doc.getUid()
}) },
sort_keys=True,
)
def getBaseExpectedDict(doc): def getBaseExpectedDict(doc):
return _decode_with_json({ return _decode_with_json({
"portal_type": doc.getPortalType(), "portal_type": doc.getPortalType(),
......
...@@ -17,11 +17,11 @@ class TestSlapOSCoreSlapOSAssertInstanceTreeSuccessorAlarm( ...@@ -17,11 +17,11 @@ class TestSlapOSCoreSlapOSAssertInstanceTreeSuccessorAlarm(
self.tic() self.tic()
# check that no interaction has recreated the instance # check that no interaction has recreated the instance
self.assertFalse(self.instance_tree.getTitle() in self.assertNotIn(self.instance_tree.getTitle(),
self.instance_tree.getSuccessorTitleList()) self.instance_tree.getSuccessorTitleList())
self.instance_tree.InstanceTree_assertSuccessor() self.instance_tree.InstanceTree_assertSuccessor()
self.assertTrue(self.instance_tree.getTitle() in self.assertIn(self.instance_tree.getTitle(),
self.instance_tree.getSuccessorTitleList()) self.instance_tree.getSuccessorTitleList())
def test_InstanceTree_assertSuccessor_stop_requested(self): def test_InstanceTree_assertSuccessor_stop_requested(self):
...@@ -31,11 +31,11 @@ class TestSlapOSCoreSlapOSAssertInstanceTreeSuccessorAlarm( ...@@ -31,11 +31,11 @@ class TestSlapOSCoreSlapOSAssertInstanceTreeSuccessorAlarm(
self.tic() self.tic()
# check that no interaction has recreated the instance # check that no interaction has recreated the instance
self.assertFalse(self.instance_tree.getTitle() in self.assertNotIn(self.instance_tree.getTitle(),
self.instance_tree.getSuccessorTitleList()) self.instance_tree.getSuccessorTitleList())
self.instance_tree.InstanceTree_assertSuccessor() self.instance_tree.InstanceTree_assertSuccessor()
self.assertTrue(self.instance_tree.getTitle() in self.assertIn(self.instance_tree.getTitle(),
self.instance_tree.getSuccessorTitleList()) self.instance_tree.getSuccessorTitleList())
def test_InstanceTree_assertSuccessor_destroy_requested(self): def test_InstanceTree_assertSuccessor_destroy_requested(self):
...@@ -45,11 +45,11 @@ class TestSlapOSCoreSlapOSAssertInstanceTreeSuccessorAlarm( ...@@ -45,11 +45,11 @@ class TestSlapOSCoreSlapOSAssertInstanceTreeSuccessorAlarm(
self.tic() self.tic()
# check that no interaction has recreated the instance # check that no interaction has recreated the instance
self.assertFalse(self.instance_tree.getTitle() in self.assertNotIn(self.instance_tree.getTitle(),
self.instance_tree.getSuccessorTitleList()) self.instance_tree.getSuccessorTitleList())
self.instance_tree.InstanceTree_assertSuccessor() self.instance_tree.InstanceTree_assertSuccessor()
self.assertFalse(self.instance_tree.getTitle() in self.assertNotIn(self.instance_tree.getTitle(),
self.instance_tree.getSuccessorTitleList()) self.instance_tree.getSuccessorTitleList())
def test_InstanceTree_assertSuccessor_archived(self): def test_InstanceTree_assertSuccessor_archived(self):
...@@ -58,11 +58,11 @@ class TestSlapOSCoreSlapOSAssertInstanceTreeSuccessorAlarm( ...@@ -58,11 +58,11 @@ class TestSlapOSCoreSlapOSAssertInstanceTreeSuccessorAlarm(
self.tic() self.tic()
# check that no interaction has recreated the instance # check that no interaction has recreated the instance
self.assertFalse(self.instance_tree.getTitle() in self.assertNotIn(self.instance_tree.getTitle(),
self.instance_tree.getSuccessorTitleList()) self.instance_tree.getSuccessorTitleList())
self.instance_tree.InstanceTree_assertSuccessor() self.instance_tree.InstanceTree_assertSuccessor()
self.assertFalse(self.instance_tree.getTitle() in self.assertNotIn(self.instance_tree.getTitle(),
self.instance_tree.getSuccessorTitleList()) self.instance_tree.getSuccessorTitleList())
def test_alarm_renamed(self): def test_alarm_renamed(self):
......
...@@ -59,8 +59,8 @@ class TestSlapOSCoreComputeNodeSlapInterfaceWorkflow(SlapOSTestCaseMixin): ...@@ -59,8 +59,8 @@ class TestSlapOSCoreComputeNodeSlapInterfaceWorkflow(SlapOSTestCaseMixin):
self.assertNotEqual(certificate_login.getReference(), None) self.assertNotEqual(certificate_login.getReference(), None)
self.assertNotEqual(certificate_login.getDestinationReference(), None) self.assertNotEqual(certificate_login.getDestinationReference(), None)
serial = '0x%x' % int(certificate_login.getDestinationReference(), 16) serial = '0x%x' % int(certificate_login.getDestinationReference(), 16)
self.assertTrue(serial in compute_node_certificate) self.assertIn(serial, compute_node_certificate)
self.assertTrue(certificate_login.getReference() in compute_node_certificate.decode('string_escape')) self.assertIn(certificate_login.getReference(), compute_node_certificate.decode('string_escape'))
def test_generateCertificate_twice(self): def test_generateCertificate_twice(self):
self.login(self.compute_node.getUserId()) self.login(self.compute_node.getUserId())
...@@ -78,8 +78,8 @@ class TestSlapOSCoreComputeNodeSlapInterfaceWorkflow(SlapOSTestCaseMixin): ...@@ -78,8 +78,8 @@ class TestSlapOSCoreComputeNodeSlapInterfaceWorkflow(SlapOSTestCaseMixin):
self.assertNotEqual(certificate_login.getReference(), None) self.assertNotEqual(certificate_login.getReference(), None)
self.assertNotEqual(certificate_login.getDestinationReference(), None) self.assertNotEqual(certificate_login.getDestinationReference(), None)
serial = '0x%x' % int(certificate_login.getDestinationReference(), 16) serial = '0x%x' % int(certificate_login.getDestinationReference(), 16)
self.assertTrue(serial in compute_node_certificate) self.assertIn(serial, compute_node_certificate)
self.assertTrue(certificate_login.getReference() in compute_node_certificate.decode('string_escape')) self.assertIn(certificate_login.getReference(), compute_node_certificate.decode('string_escape'))
self.assertRaises(ValueError, self.compute_node.generateCertificate) self.assertRaises(ValueError, self.compute_node.generateCertificate)
self.assertEqual(None, self.portal.REQUEST.get('compute_node_key')) self.assertEqual(None, self.portal.REQUEST.get('compute_node_key'))
...@@ -271,8 +271,8 @@ class TestSlapOSCoreComputeNodeSlapInterfaceWorkflow(SlapOSTestCaseMixin): ...@@ -271,8 +271,8 @@ class TestSlapOSCoreComputeNodeSlapInterfaceWorkflow(SlapOSTestCaseMixin):
self.assertNotEqual(certificate_login.getReference(), None) self.assertNotEqual(certificate_login.getReference(), None)
self.assertNotEqual(certificate_login.getDestinationReference(), None) self.assertNotEqual(certificate_login.getDestinationReference(), None)
serial = '0x%x' % int(certificate_login.getDestinationReference(), 16) serial = '0x%x' % int(certificate_login.getDestinationReference(), 16)
self.assertTrue(serial in compute_node_certificate) self.assertIn(serial, compute_node_certificate)
self.assertTrue(certificate_login.getReference() in compute_node_certificate.decode('string_escape')) self.assertIn(certificate_login.getReference(), compute_node_certificate.decode('string_escape'))
self.assertNotEqual(certificate_login.getReference(), self.assertNotEqual(certificate_login.getReference(),
self.compute_node.getReference()) self.compute_node.getReference())
...@@ -305,8 +305,8 @@ class TestSlapOSCoreComputeNodeSlapInterfaceWorkflow(SlapOSTestCaseMixin): ...@@ -305,8 +305,8 @@ class TestSlapOSCoreComputeNodeSlapInterfaceWorkflow(SlapOSTestCaseMixin):
self.assertNotEqual(certificate_login.getReference(), None) self.assertNotEqual(certificate_login.getReference(), None)
self.assertNotEqual(certificate_login.getDestinationReference(), None) self.assertNotEqual(certificate_login.getDestinationReference(), None)
serial = '0x%x' % int(certificate_login.getDestinationReference(), 16) serial = '0x%x' % int(certificate_login.getDestinationReference(), 16)
self.assertTrue(serial in compute_node_certificate) self.assertIn(serial, compute_node_certificate)
self.assertTrue(certificate_login.getReference() in compute_node_certificate.decode('string_escape')) self.assertIn(certificate_login.getReference(), compute_node_certificate.decode('string_escape'))
self.assertNotEqual(certificate_login.getReference(), self.assertNotEqual(certificate_login.getReference(),
self.compute_node.getReference()) self.compute_node.getReference())
...@@ -340,8 +340,8 @@ class TestSlapOSCoreComputeNodeSlapInterfaceWorkflow(SlapOSTestCaseMixin): ...@@ -340,8 +340,8 @@ class TestSlapOSCoreComputeNodeSlapInterfaceWorkflow(SlapOSTestCaseMixin):
self.assertNotEqual(certificate_login.getReference(), None) self.assertNotEqual(certificate_login.getReference(), None)
self.assertNotEqual(certificate_login.getDestinationReference(), None) self.assertNotEqual(certificate_login.getDestinationReference(), None)
serial = '0x%x' % int(certificate_login.getDestinationReference(), 16) serial = '0x%x' % int(certificate_login.getDestinationReference(), 16)
self.assertTrue(serial in compute_node_certificate) self.assertIn(serial, compute_node_certificate)
self.assertTrue(certificate_login.getReference() in compute_node_certificate.decode('string_escape')) self.assertIn(certificate_login.getReference(), compute_node_certificate.decode('string_escape'))
self.assertNotEqual(certificate_login.getReference(), self.assertNotEqual(certificate_login.getReference(),
self.compute_node.getReference()) self.compute_node.getReference())
self.assertNotEqual(None, destination_reference) self.assertNotEqual(None, destination_reference)
...@@ -375,9 +375,9 @@ class TestSlapOSCoreComputeNodeSlapInterfaceWorkflow(SlapOSTestCaseMixin): ...@@ -375,9 +375,9 @@ class TestSlapOSCoreComputeNodeSlapInterfaceWorkflow(SlapOSTestCaseMixin):
serial = '0x%x' % int(new_certificate_login.getDestinationReference(), 16) serial = '0x%x' % int(new_certificate_login.getDestinationReference(), 16)
compute_node_certificate = self.portal.REQUEST.get('compute_node_certificate') compute_node_certificate = self.portal.REQUEST.get('compute_node_certificate')
self.assertTrue(serial in compute_node_certificate) self.assertIn(serial, compute_node_certificate)
self.assertTrue(new_certificate_login.getReference() in compute_node_certificate.decode('string_escape')) self.assertIn(new_certificate_login.getReference(), compute_node_certificate.decode('string_escape'))
self.assertFalse(certificate_login.getReference() in compute_node_certificate.decode('string_escape')) self.assertNotIn(certificate_login.getReference(), compute_node_certificate.decode('string_escape'))
self.assertNotEqual(certificate_login.getReference(), self.assertNotEqual(certificate_login.getReference(),
self.compute_node.getReference()) self.compute_node.getReference())
...@@ -399,8 +399,8 @@ class TestSlapOSCoreComputeNodeSlapInterfaceWorkflow(SlapOSTestCaseMixin): ...@@ -399,8 +399,8 @@ class TestSlapOSCoreComputeNodeSlapInterfaceWorkflow(SlapOSTestCaseMixin):
self.assertNotEqual(certificate_login.getReference(), None) self.assertNotEqual(certificate_login.getReference(), None)
self.assertNotEqual(certificate_login.getDestinationReference(), None) self.assertNotEqual(certificate_login.getDestinationReference(), None)
serial = '0x%x' % int(certificate_login.getDestinationReference(), 16) serial = '0x%x' % int(certificate_login.getDestinationReference(), 16)
self.assertTrue(serial in compute_node_certificate) self.assertIn(serial, compute_node_certificate)
self.assertTrue(certificate_login.getReference() in compute_node_certificate.decode('string_escape')) self.assertIn(certificate_login.getReference(), compute_node_certificate.decode('string_escape'))
self.assertNotEqual(certificate_login.getReference(), self.assertNotEqual(certificate_login.getReference(),
self.compute_node.getReference()) self.compute_node.getReference())
self.assertNotEqual(None, destination_reference) self.assertNotEqual(None, destination_reference)
...@@ -434,9 +434,9 @@ class TestSlapOSCoreComputeNodeSlapInterfaceWorkflow(SlapOSTestCaseMixin): ...@@ -434,9 +434,9 @@ class TestSlapOSCoreComputeNodeSlapInterfaceWorkflow(SlapOSTestCaseMixin):
serial = '0x%x' % int(new_certificate_login.getDestinationReference(), 16) serial = '0x%x' % int(new_certificate_login.getDestinationReference(), 16)
compute_node_certificate = self.portal.REQUEST.get('compute_node_certificate') compute_node_certificate = self.portal.REQUEST.get('compute_node_certificate')
self.assertTrue(serial in compute_node_certificate) self.assertIn(serial, compute_node_certificate)
self.assertTrue(new_certificate_login.getReference() in compute_node_certificate.decode('string_escape')) self.assertIn(new_certificate_login.getReference(), compute_node_certificate.decode('string_escape'))
self.assertFalse(certificate_login.getReference() in compute_node_certificate.decode('string_escape')) self.assertNotIn(certificate_login.getReference(), compute_node_certificate.decode('string_escape'))
self.assertNotEqual(certificate_login.getReference(), self.assertNotEqual(certificate_login.getReference(),
self.compute_node.getReference()) self.compute_node.getReference())
...@@ -471,9 +471,9 @@ class TestSlapOSCoreComputeNodeSlapInterfaceWorkflow(SlapOSTestCaseMixin): ...@@ -471,9 +471,9 @@ class TestSlapOSCoreComputeNodeSlapInterfaceWorkflow(SlapOSTestCaseMixin):
serial = '0x%x' % int(third_certificate_login.getDestinationReference(), 16) serial = '0x%x' % int(third_certificate_login.getDestinationReference(), 16)
compute_node_certificate = self.portal.REQUEST.get('compute_node_certificate') compute_node_certificate = self.portal.REQUEST.get('compute_node_certificate')
self.assertTrue(serial in compute_node_certificate) self.assertIn(serial, compute_node_certificate)
self.assertTrue(third_certificate_login.getReference() in compute_node_certificate.decode('string_escape')) self.assertIn(third_certificate_login.getReference(), compute_node_certificate.decode('string_escape'))
self.assertFalse(new_certificate_login.getReference() in compute_node_certificate.decode('string_escape')) self.assertNotIn(new_certificate_login.getReference(), compute_node_certificate.decode('string_escape'))
self.assertNotEqual(third_certificate_login.getReference(), self.assertNotEqual(third_certificate_login.getReference(),
self.compute_node.getReference()) self.compute_node.getReference())
......
...@@ -21,7 +21,7 @@ class TestSlapOSConstraintMixin(SlapOSTestCaseMixin): ...@@ -21,7 +21,7 @@ class TestSlapOSConstraintMixin(SlapOSTestCaseMixin):
current_message_list = self.getMessageList(obj) current_message_list = self.getMessageList(obj)
# test the test: no expected message found # test the test: no expected message found
self.assertFalse(consistency_message in current_message_list) self.assertNotIn(consistency_message, current_message_list)
# required # required
...@@ -33,14 +33,14 @@ class TestSlapOSConstraintMixin(SlapOSTestCaseMixin): ...@@ -33,14 +33,14 @@ class TestSlapOSConstraintMixin(SlapOSTestCaseMixin):
# ...but in case of magic ones (reference->default_reference) # ...but in case of magic ones (reference->default_reference)
# use setter to set it to None # use setter to set it to None
obj.edit(**{property_id:None}) obj.edit(**{property_id:None})
self.assertTrue(consistency_message in self.getMessageList(obj)) self.assertIn(consistency_message, self.getMessageList(obj))
if empty_string: if empty_string:
obj.edit(**{property_id:''}) obj.edit(**{property_id:''})
self.assertTrue(consistency_message in self.getMessageList(obj)) self.assertIn(consistency_message, self.getMessageList(obj))
obj.edit(**{property_id:value}) obj.edit(**{property_id:value})
self.assertFalse(consistency_message in self.getMessageList(obj)) self.assertNotIn(consistency_message, self.getMessageList(obj))
self.assertSameSet(current_message_list, self.getMessageList(obj)) self.assertSameSet(current_message_list, self.getMessageList(obj))
class TestSlapOSComputePartitionConstraint(TestSlapOSConstraintMixin): class TestSlapOSComputePartitionConstraint(TestSlapOSConstraintMixin):
...@@ -63,14 +63,14 @@ class TestSlapOSComputePartitionConstraint(TestSlapOSConstraintMixin): ...@@ -63,14 +63,14 @@ class TestSlapOSComputePartitionConstraint(TestSlapOSConstraintMixin):
# test the test: no expected message found # test the test: no expected message found
current_message_list = self.getMessageList(partition) current_message_list = self.getMessageList(partition)
self.assertFalse(consistency_message in current_message_list) self.assertNotIn(consistency_message, current_message_list)
# check case for Software Instance # check case for Software Instance
software_instance.setAggregate(partition.getRelativeUrl()) software_instance.setAggregate(partition.getRelativeUrl())
software_instance.immediateReindexObject() software_instance.immediateReindexObject()
self.assertTrue(consistency_message in self.getMessageList(partition)) self.assertIn(consistency_message, self.getMessageList(partition))
self.portal.portal_workflow._jumpToStateFor(partition, 'busy') self.portal.portal_workflow._jumpToStateFor(partition, 'busy')
self.assertFalse(consistency_message in self.getMessageList(partition)) self.assertNotIn(consistency_message, self.getMessageList(partition))
self.portal.portal_workflow._jumpToStateFor(partition, 'free') self.portal.portal_workflow._jumpToStateFor(partition, 'free')
software_instance.setAggregate(None) software_instance.setAggregate(None)
software_instance.immediateReindexObject() software_instance.immediateReindexObject()
...@@ -78,9 +78,9 @@ class TestSlapOSComputePartitionConstraint(TestSlapOSConstraintMixin): ...@@ -78,9 +78,9 @@ class TestSlapOSComputePartitionConstraint(TestSlapOSConstraintMixin):
# check case fo Slave Instance # check case fo Slave Instance
slave_instance.setAggregate(partition.getRelativeUrl()) slave_instance.setAggregate(partition.getRelativeUrl())
slave_instance.immediateReindexObject() slave_instance.immediateReindexObject()
self.assertTrue(consistency_message in self.getMessageList(partition)) self.assertIn(consistency_message, self.getMessageList(partition))
self.portal.portal_workflow._jumpToStateFor(partition, 'busy') self.portal.portal_workflow._jumpToStateFor(partition, 'busy')
self.assertFalse(consistency_message in self.getMessageList(partition)) self.assertNotIn(consistency_message, self.getMessageList(partition))
self.portal.portal_workflow._jumpToStateFor(partition, 'free') self.portal.portal_workflow._jumpToStateFor(partition, 'free')
def test_busy_partition_has_one_related_instance(self): def test_busy_partition_has_one_related_instance(self):
...@@ -110,12 +110,12 @@ class TestSlapOSComputePartitionConstraint(TestSlapOSConstraintMixin): ...@@ -110,12 +110,12 @@ class TestSlapOSComputePartitionConstraint(TestSlapOSConstraintMixin):
# test the test: no expected message found # test the test: no expected message found
current_message_list = self.getMessageList(partition) current_message_list = self.getMessageList(partition)
self.assertFalse(consistency_message in current_message_list) self.assertNotIn(consistency_message, current_message_list)
# check case for Software Instance # check case for Software Instance
software_instance.edit(aggregate=None) software_instance.edit(aggregate=None)
software_instance.immediateReindexObject() software_instance.immediateReindexObject()
self.assertTrue(consistency_message in self.getMessageList(partition)) self.assertIn(consistency_message, self.getMessageList(partition))
# check case for many Software Instance # check case for many Software Instance
software_instance.edit(aggregate=partition.getRelativeUrl()) software_instance.edit(aggregate=partition.getRelativeUrl())
...@@ -125,7 +125,7 @@ class TestSlapOSComputePartitionConstraint(TestSlapOSConstraintMixin): ...@@ -125,7 +125,7 @@ class TestSlapOSComputePartitionConstraint(TestSlapOSConstraintMixin):
consistency_message_2 = "Arity Error for Relation ['default_aggregate'] and" \ consistency_message_2 = "Arity Error for Relation ['default_aggregate'] and" \
" Type ('Software Instance',), arity is equal to 2 but should be " \ " Type ('Software Instance',), arity is equal to 2 but should be " \
"between 1 and 1" "between 1 and 1"
self.assertTrue(consistency_message_2 in self.getMessageList(partition)) self.assertIn(consistency_message_2, self.getMessageList(partition))
# check case for many Slave Instane # check case for many Slave Instane
software_instance_2.edit(aggregate=None) software_instance_2.edit(aggregate=None)
...@@ -134,8 +134,8 @@ class TestSlapOSComputePartitionConstraint(TestSlapOSConstraintMixin): ...@@ -134,8 +134,8 @@ class TestSlapOSComputePartitionConstraint(TestSlapOSConstraintMixin):
slave_instance_2.edit(aggregate=partition.getRelativeUrl()) slave_instance_2.edit(aggregate=partition.getRelativeUrl())
slave_instance.immediateReindexObject() slave_instance.immediateReindexObject()
slave_instance_2.immediateReindexObject() slave_instance_2.immediateReindexObject()
self.assertFalse(consistency_message in self.getMessageList(partition)) self.assertNotIn(consistency_message, self.getMessageList(partition))
self.assertFalse(consistency_message_2 in self.getMessageList(partition)) self.assertNotIn(consistency_message_2, self.getMessageList(partition))
class TestSlapOSSoftwareInstanceConstraint(TestSlapOSConstraintMixin): class TestSlapOSSoftwareInstanceConstraint(TestSlapOSConstraintMixin):
def afterSetUp(self): def afterSetUp(self):
...@@ -153,16 +153,16 @@ class TestSlapOSSoftwareInstanceConstraint(TestSlapOSConstraintMixin): ...@@ -153,16 +153,16 @@ class TestSlapOSSoftwareInstanceConstraint(TestSlapOSConstraintMixin):
"found, line 1, column 1 (line 1)" "found, line 1, column 1 (line 1)"
# test the test: no expected message found # test the test: no expected message found
self.assertFalse(consistency_message in current_message_list) self.assertNotIn(consistency_message, current_message_list)
# connection_xml is optional # connection_xml is optional
self.software_instance.edit(connection_xml=None) self.software_instance.edit(connection_xml=None)
self.assertFalse(consistency_message in self.getMessageList(self.software_instance)) self.assertNotIn(consistency_message, self.getMessageList(self.software_instance))
self.assertSameSet(current_message_list, self.getMessageList(self.software_instance)) self.assertSameSet(current_message_list, self.getMessageList(self.software_instance))
self.software_instance.edit(connection_xml='') self.software_instance.edit(connection_xml='')
self.assertFalse(consistency_message in self.getMessageList(self.software_instance)) self.assertNotIn(consistency_message, self.getMessageList(self.software_instance))
self.assertSameSet(current_message_list, self.getMessageList(self.software_instance)) self.assertSameSet(current_message_list, self.getMessageList(self.software_instance))
# if available shall be correct XML # if available shall be correct XML
...@@ -172,7 +172,7 @@ class TestSlapOSSoftwareInstanceConstraint(TestSlapOSConstraintMixin): ...@@ -172,7 +172,7 @@ class TestSlapOSSoftwareInstanceConstraint(TestSlapOSConstraintMixin):
self.getMessageList(self.software_instance))) self.getMessageList(self.software_instance)))
self.software_instance.edit(connection_xml=self.generateEmptyXml()) self.software_instance.edit(connection_xml=self.generateEmptyXml())
self.assertFalse(consistency_message in self.getMessageList(self.software_instance)) self.assertNotIn(consistency_message, self.getMessageList(self.software_instance))
self.assertSameSet(current_message_list, self.getMessageList(self.software_instance)) self.assertSameSet(current_message_list, self.getMessageList(self.software_instance))
def test_property_existence_source_reference(self): def test_property_existence_source_reference(self):
...@@ -182,10 +182,10 @@ class TestSlapOSSoftwareInstanceConstraint(TestSlapOSConstraintMixin): ...@@ -182,10 +182,10 @@ class TestSlapOSSoftwareInstanceConstraint(TestSlapOSConstraintMixin):
'has never been set' 'has never been set'
# not required in draft state # not required in draft state
self.software_instance.edit(**{property_id:None}) self.software_instance.edit(**{property_id:None})
self.assertFalse(consistency_message in self.getMessageList(self.software_instance)) self.assertNotIn(consistency_message, self.getMessageList(self.software_instance))
self.software_instance.edit(**{property_id:''}) self.software_instance.edit(**{property_id:''})
self.assertFalse(consistency_message in self.getMessageList(self.software_instance)) self.assertNotIn(consistency_message, self.getMessageList(self.software_instance))
self.portal.portal_workflow._jumpToStateFor(self.software_instance, self.portal.portal_workflow._jumpToStateFor(self.software_instance,
'start_requested') 'start_requested')
...@@ -208,10 +208,10 @@ class TestSlapOSSoftwareInstanceConstraint(TestSlapOSConstraintMixin): ...@@ -208,10 +208,10 @@ class TestSlapOSSoftwareInstanceConstraint(TestSlapOSConstraintMixin):
self.portal.portal_workflow._jumpToStateFor(self.software_instance, self.portal.portal_workflow._jumpToStateFor(self.software_instance,
'destroy_requested') 'destroy_requested')
self.software_instance.edit(**{property_id:None}) self.software_instance.edit(**{property_id:None})
self.assertFalse(consistency_message in self.getMessageList(self.software_instance)) self.assertNotIn(consistency_message, self.getMessageList(self.software_instance))
self.software_instance.edit(**{property_id:''}) self.software_instance.edit(**{property_id:''})
self.assertFalse(consistency_message in self.getMessageList(self.software_instance)) self.assertNotIn(consistency_message, self.getMessageList(self.software_instance))
def test_property_existence_ssl_key(self): def test_property_existence_ssl_key(self):
property_id = 'ssl_key' property_id = 'ssl_key'
...@@ -224,10 +224,10 @@ class TestSlapOSSoftwareInstanceConstraint(TestSlapOSConstraintMixin): ...@@ -224,10 +224,10 @@ class TestSlapOSSoftwareInstanceConstraint(TestSlapOSConstraintMixin):
self.portal.portal_workflow._jumpToStateFor(self.software_instance, self.portal.portal_workflow._jumpToStateFor(self.software_instance,
'destroy_requested') 'destroy_requested')
self.software_instance.edit(**{property_id:None}) self.software_instance.edit(**{property_id:None})
self.assertFalse(consistency_message in self.getMessageList(self.software_instance)) self.assertNotIn(consistency_message, self.getMessageList(self.software_instance))
self.software_instance.edit(**{property_id:''}) self.software_instance.edit(**{property_id:''})
self.assertFalse(consistency_message in self.getMessageList(self.software_instance)) self.assertNotIn(consistency_message, self.getMessageList(self.software_instance))
def test_successor_related(self): def test_successor_related(self):
software_instance2 = self.portal.software_instance_module.newContent( software_instance2 = self.portal.software_instance_module.newContent(
...@@ -243,24 +243,24 @@ class TestSlapOSSoftwareInstanceConstraint(TestSlapOSConstraintMixin): ...@@ -243,24 +243,24 @@ class TestSlapOSSoftwareInstanceConstraint(TestSlapOSConstraintMixin):
consistency_message = "There is more then one related successor" consistency_message = "There is more then one related successor"
# test the test: no expected message found # test the test: no expected message found
self.assertFalse(consistency_message in current_message_list) self.assertNotIn(consistency_message, current_message_list)
# if too many, it shall cry # if too many, it shall cry
software_instance2.edit(successor=self.software_instance.getRelativeUrl()) software_instance2.edit(successor=self.software_instance.getRelativeUrl())
software_instance3.edit(successor=self.software_instance.getRelativeUrl()) software_instance3.edit(successor=self.software_instance.getRelativeUrl())
self.tic() self.tic()
self.assertTrue(consistency_message in self.getMessageList(self.software_instance)) self.assertIn(consistency_message, self.getMessageList(self.software_instance))
# one is good # one is good
software_instance2.edit(successor=None) software_instance2.edit(successor=None)
self.tic() self.tic()
self.assertFalse(consistency_message in self.getMessageList(self.software_instance)) self.assertNotIn(consistency_message, self.getMessageList(self.software_instance))
self.assertSameSet(current_message_list, self.getMessageList(self.software_instance)) self.assertSameSet(current_message_list, self.getMessageList(self.software_instance))
# none is good # none is good
software_instance3.edit(successor=None) software_instance3.edit(successor=None)
self.tic() self.tic()
self.assertFalse(consistency_message in self.getMessageList(self.software_instance)) self.assertNotIn(consistency_message, self.getMessageList(self.software_instance))
self.assertSameSet(current_message_list, self.getMessageList(self.software_instance)) self.assertSameSet(current_message_list, self.getMessageList(self.software_instance))
def test_sla_xml(self): def test_sla_xml(self):
...@@ -271,16 +271,16 @@ class TestSlapOSSoftwareInstanceConstraint(TestSlapOSConstraintMixin): ...@@ -271,16 +271,16 @@ class TestSlapOSSoftwareInstanceConstraint(TestSlapOSConstraintMixin):
"found, line 1, column 1 (line 1)" "found, line 1, column 1 (line 1)"
# test the test: no expected message found # test the test: no expected message found
self.assertFalse(consistency_message in current_message_list) self.assertNotIn(consistency_message, current_message_list)
# sla_xml is optional # sla_xml is optional
self.software_instance.edit(sla_xml=None) self.software_instance.edit(sla_xml=None)
self.assertFalse(consistency_message in self.getMessageList(self.software_instance)) self.assertNotIn(consistency_message, self.getMessageList(self.software_instance))
self.assertSameSet(current_message_list, self.getMessageList(self.software_instance)) self.assertSameSet(current_message_list, self.getMessageList(self.software_instance))
self.software_instance.edit(sla_xml='') self.software_instance.edit(sla_xml='')
self.assertFalse(consistency_message in self.getMessageList(self.software_instance)) self.assertNotIn(consistency_message, self.getMessageList(self.software_instance))
self.assertSameSet(current_message_list, self.getMessageList(self.software_instance)) self.assertSameSet(current_message_list, self.getMessageList(self.software_instance))
# if available shall be correct XML # if available shall be correct XML
...@@ -290,7 +290,7 @@ class TestSlapOSSoftwareInstanceConstraint(TestSlapOSConstraintMixin): ...@@ -290,7 +290,7 @@ class TestSlapOSSoftwareInstanceConstraint(TestSlapOSConstraintMixin):
self.getMessageList(self.software_instance))) self.getMessageList(self.software_instance)))
self.software_instance.edit(sla_xml=self.generateEmptyXml()) self.software_instance.edit(sla_xml=self.generateEmptyXml())
self.assertFalse(consistency_message in self.getMessageList(self.software_instance)) self.assertNotIn(consistency_message, self.getMessageList(self.software_instance))
self.assertSameSet(current_message_list, self.getMessageList(self.software_instance)) self.assertSameSet(current_message_list, self.getMessageList(self.software_instance))
def test_text_content(self): def test_text_content(self):
...@@ -301,16 +301,16 @@ class TestSlapOSSoftwareInstanceConstraint(TestSlapOSConstraintMixin): ...@@ -301,16 +301,16 @@ class TestSlapOSSoftwareInstanceConstraint(TestSlapOSConstraintMixin):
"found, line 1, column 1 (line 1)" "found, line 1, column 1 (line 1)"
# test the test: no expected message found # test the test: no expected message found
self.assertFalse(consistency_message in current_message_list) self.assertNotIn(consistency_message, current_message_list)
# text_content is optional # text_content is optional
self.software_instance.edit(text_content=None) self.software_instance.edit(text_content=None)
self.assertFalse(consistency_message in self.getMessageList(self.software_instance)) self.assertNotIn(consistency_message, self.getMessageList(self.software_instance))
self.assertSameSet(current_message_list, self.getMessageList(self.software_instance)) self.assertSameSet(current_message_list, self.getMessageList(self.software_instance))
self.software_instance.edit(text_content='') self.software_instance.edit(text_content='')
self.assertFalse(consistency_message in self.getMessageList(self.software_instance)) self.assertNotIn(consistency_message, self.getMessageList(self.software_instance))
self.assertSameSet(current_message_list, self.getMessageList(self.software_instance)) self.assertSameSet(current_message_list, self.getMessageList(self.software_instance))
# if available shall be correct XML # if available shall be correct XML
...@@ -320,7 +320,7 @@ class TestSlapOSSoftwareInstanceConstraint(TestSlapOSConstraintMixin): ...@@ -320,7 +320,7 @@ class TestSlapOSSoftwareInstanceConstraint(TestSlapOSConstraintMixin):
self.getMessageList(self.software_instance))) self.getMessageList(self.software_instance)))
self.software_instance.edit(text_content=self.generateEmptyXml()) self.software_instance.edit(text_content=self.generateEmptyXml())
self.assertFalse(consistency_message in self.getMessageList(self.software_instance)) self.assertNotIn(consistency_message, self.getMessageList(self.software_instance))
self.assertSameSet(current_message_list, self.getMessageList(self.software_instance)) self.assertSameSet(current_message_list, self.getMessageList(self.software_instance))
class TestSlapOSSlaveInstanceConstraint(TestSlapOSConstraintMixin): class TestSlapOSSlaveInstanceConstraint(TestSlapOSConstraintMixin):
...@@ -338,10 +338,10 @@ class TestSlapOSSlaveInstanceConstraint(TestSlapOSConstraintMixin): ...@@ -338,10 +338,10 @@ class TestSlapOSSlaveInstanceConstraint(TestSlapOSConstraintMixin):
property_id = 'source_reference' property_id = 'source_reference'
# not required in draft state # not required in draft state
self.software_instance.edit(**{property_id:None}) self.software_instance.edit(**{property_id:None})
self.assertFalse(consistency_message in self.getMessageList(self.software_instance)) self.assertNotIn(consistency_message, self.getMessageList(self.software_instance))
self.software_instance.edit(**{property_id:''}) self.software_instance.edit(**{property_id:''})
self.assertFalse(consistency_message in self.getMessageList(self.software_instance)) self.assertNotIn(consistency_message, self.getMessageList(self.software_instance))
self.portal.portal_workflow._jumpToStateFor(self.software_instance, self.portal.portal_workflow._jumpToStateFor(self.software_instance,
'start_requested') 'start_requested')
...@@ -355,10 +355,10 @@ class TestSlapOSSlaveInstanceConstraint(TestSlapOSConstraintMixin): ...@@ -355,10 +355,10 @@ class TestSlapOSSlaveInstanceConstraint(TestSlapOSConstraintMixin):
property_id = 'text_content' property_id = 'text_content'
# not required in draft state # not required in draft state
self.software_instance.edit(**{property_id:None}) self.software_instance.edit(**{property_id:None})
self.assertFalse(consistency_message in self.getMessageList(self.software_instance)) self.assertNotIn(consistency_message, self.getMessageList(self.software_instance))
self.software_instance.edit(**{property_id:''}) self.software_instance.edit(**{property_id:''})
self.assertFalse(consistency_message in self.getMessageList(self.software_instance)) self.assertNotIn(consistency_message, self.getMessageList(self.software_instance))
self.portal.portal_workflow._jumpToStateFor(self.software_instance, self.portal.portal_workflow._jumpToStateFor(self.software_instance,
'start_requested') 'start_requested')
...@@ -384,24 +384,24 @@ class TestSlapOSSlaveInstanceConstraint(TestSlapOSConstraintMixin): ...@@ -384,24 +384,24 @@ class TestSlapOSSlaveInstanceConstraint(TestSlapOSConstraintMixin):
consistency_message = "There is more then one related successor" consistency_message = "There is more then one related successor"
# test the test: no expected message found # test the test: no expected message found
self.assertFalse(consistency_message in current_message_list) self.assertNotIn(consistency_message, current_message_list)
# if too many, it shall cry # if too many, it shall cry
software_instance2.edit(successor=self.software_instance.getRelativeUrl()) software_instance2.edit(successor=self.software_instance.getRelativeUrl())
software_instance3.edit(successor=self.software_instance.getRelativeUrl()) software_instance3.edit(successor=self.software_instance.getRelativeUrl())
self.tic() self.tic()
self.assertTrue(consistency_message in self.getMessageList(self.software_instance)) self.assertIn(consistency_message, self.getMessageList(self.software_instance))
# one is good # one is good
software_instance2.edit(successor=None) software_instance2.edit(successor=None)
self.tic() self.tic()
self.assertFalse(consistency_message in self.getMessageList(self.software_instance)) self.assertNotIn(consistency_message, self.getMessageList(self.software_instance))
self.assertSameSet(current_message_list, self.getMessageList(self.software_instance)) self.assertSameSet(current_message_list, self.getMessageList(self.software_instance))
# none is good # none is good
software_instance3.edit(successor=None) software_instance3.edit(successor=None)
self.tic() self.tic()
self.assertFalse(consistency_message in self.getMessageList(self.software_instance)) self.assertNotIn(consistency_message, self.getMessageList(self.software_instance))
self.assertSameSet(current_message_list, self.getMessageList(self.software_instance)) self.assertSameSet(current_message_list, self.getMessageList(self.software_instance))
class TestSlapOSInstanceTreeConstraint(TestSlapOSConstraintMixin): class TestSlapOSInstanceTreeConstraint(TestSlapOSConstraintMixin):
...@@ -429,10 +429,10 @@ class TestSlapOSInstanceTreeConstraint(TestSlapOSConstraintMixin): ...@@ -429,10 +429,10 @@ class TestSlapOSInstanceTreeConstraint(TestSlapOSConstraintMixin):
'has never been set' 'has never been set'
# not required in draft state # not required in draft state
self.software_instance.edit(**{property_id:None}) self.software_instance.edit(**{property_id:None})
self.assertFalse(consistency_message in self.getMessageList(self.software_instance)) self.assertNotIn(consistency_message, self.getMessageList(self.software_instance))
self.software_instance.edit(**{property_id:''}) self.software_instance.edit(**{property_id:''})
self.assertFalse(consistency_message in self.getMessageList(self.software_instance)) self.assertNotIn(consistency_message, self.getMessageList(self.software_instance))
self.portal.portal_workflow._jumpToStateFor(self.software_instance, self.portal.portal_workflow._jumpToStateFor(self.software_instance,
'start_requested') 'start_requested')
...@@ -446,10 +446,10 @@ class TestSlapOSInstanceTreeConstraint(TestSlapOSConstraintMixin): ...@@ -446,10 +446,10 @@ class TestSlapOSInstanceTreeConstraint(TestSlapOSConstraintMixin):
'has never been set' 'has never been set'
# not required in draft state # not required in draft state
self.software_instance.edit(**{property_id:None}) self.software_instance.edit(**{property_id:None})
self.assertFalse(consistency_message in self.getMessageList(self.software_instance)) self.assertNotIn(consistency_message, self.getMessageList(self.software_instance))
self.software_instance.edit(**{property_id:''}) self.software_instance.edit(**{property_id:''})
self.assertFalse(consistency_message in self.getMessageList(self.software_instance)) self.assertNotIn(consistency_message, self.getMessageList(self.software_instance))
self.portal.portal_workflow._jumpToStateFor(self.software_instance, self.portal.portal_workflow._jumpToStateFor(self.software_instance,
'start_requested') 'start_requested')
...@@ -463,10 +463,10 @@ class TestSlapOSInstanceTreeConstraint(TestSlapOSConstraintMixin): ...@@ -463,10 +463,10 @@ class TestSlapOSInstanceTreeConstraint(TestSlapOSConstraintMixin):
'has never been set' 'has never been set'
# not required in draft state # not required in draft state
self.software_instance.edit(**{property_id:None}) self.software_instance.edit(**{property_id:None})
self.assertFalse(consistency_message in self.getMessageList(self.software_instance)) self.assertNotIn(consistency_message, self.getMessageList(self.software_instance))
self.software_instance.edit(**{property_id:''}) self.software_instance.edit(**{property_id:''})
self.assertFalse(consistency_message in self.getMessageList(self.software_instance)) self.assertNotIn(consistency_message, self.getMessageList(self.software_instance))
self.portal.portal_workflow._jumpToStateFor(self.software_instance, self.portal.portal_workflow._jumpToStateFor(self.software_instance,
'start_requested') 'start_requested')
...@@ -478,17 +478,17 @@ class TestSlapOSPersonConstraint(TestSlapOSConstraintMixin): ...@@ -478,17 +478,17 @@ class TestSlapOSPersonConstraint(TestSlapOSConstraintMixin):
def test_role(self): def test_role(self):
person = self.portal.person_module.newContent(portal_type='Person') person = self.portal.person_module.newContent(portal_type='Person')
consistency_message = 'One role should be defined' consistency_message = 'One role should be defined'
self.assertTrue(consistency_message in self.getMessageList(person)) self.assertIn(consistency_message, self.getMessageList(person))
role_id_list = list(self.portal.portal_categories.role.objectIds()) role_id_list = list(self.portal.portal_categories.role.objectIds())
self.assertTrue(len(role_id_list) >= 2) self.assertTrue(len(role_id_list) >= 2)
person.setRole(role_id_list[0]) person.setRole(role_id_list[0])
self.assertFalse(consistency_message in self.getMessageList(person)) self.assertNotIn(consistency_message, self.getMessageList(person))
person.setRoleList(role_id_list) person.setRoleList(role_id_list)
self.assertTrue(consistency_message in self.getMessageList(person)) self.assertIn(consistency_message, self.getMessageList(person))
person.setRole(role_id_list[0]) person.setRole(role_id_list[0])
self.assertFalse(consistency_message in self.getMessageList(person)) self.assertNotIn(consistency_message, self.getMessageList(person))
def test_subordination_state(self): def test_subordination_state(self):
organisation = self.portal.organisation_module.newContent( organisation = self.portal.organisation_module.newContent(
...@@ -497,21 +497,21 @@ class TestSlapOSPersonConstraint(TestSlapOSConstraintMixin): ...@@ -497,21 +497,21 @@ class TestSlapOSPersonConstraint(TestSlapOSConstraintMixin):
subordination=organisation.getRelativeUrl()) subordination=organisation.getRelativeUrl())
consistency_message = 'The Organisation is not validated' consistency_message = 'The Organisation is not validated'
self.assertTrue(consistency_message in self.getMessageList(person)) self.assertIn(consistency_message, self.getMessageList(person))
organisation.validate() organisation.validate()
self.assertFalse(consistency_message in self.getMessageList(person)) self.assertNotIn(consistency_message, self.getMessageList(person))
def test_email(self): def test_email(self):
person = self.portal.person_module.newContent(portal_type='Person') person = self.portal.person_module.newContent(portal_type='Person')
consistency_message = 'Person have to contain an Email' consistency_message = 'Person have to contain an Email'
self.assertTrue(consistency_message in self.getMessageList(person)) self.assertIn(consistency_message, self.getMessageList(person))
person.newContent(portal_type='Email') person.newContent(portal_type='Email')
self.assertFalse(consistency_message in self.getMessageList(person)) self.assertNotIn(consistency_message, self.getMessageList(person))
class TestSlapOSAssignmentConstraint(TestSlapOSConstraintMixin): class TestSlapOSAssignmentConstraint(TestSlapOSConstraintMixin):
def test_parent_person_validated(self): def test_parent_person_validated(self):
...@@ -520,11 +520,11 @@ class TestSlapOSAssignmentConstraint(TestSlapOSConstraintMixin): ...@@ -520,11 +520,11 @@ class TestSlapOSAssignmentConstraint(TestSlapOSConstraintMixin):
consistency_message = 'The person document has to be validated to start '\ consistency_message = 'The person document has to be validated to start '\
'assignment' 'assignment'
self.assertTrue(consistency_message in self.getMessageList(assignment)) self.assertIn(consistency_message, self.getMessageList(assignment))
person.validate() person.validate()
self.assertFalse(consistency_message in self.getMessageList(assignment)) self.assertNotIn(consistency_message, self.getMessageList(assignment))
class TestSlapOSEmailConstraint(TestSlapOSConstraintMixin): class TestSlapOSEmailConstraint(TestSlapOSConstraintMixin):
def test_url_string_not_empty(self): def test_url_string_not_empty(self):
...@@ -532,20 +532,20 @@ class TestSlapOSEmailConstraint(TestSlapOSConstraintMixin): ...@@ -532,20 +532,20 @@ class TestSlapOSEmailConstraint(TestSlapOSConstraintMixin):
).newContent(portal_type='Email') ).newContent(portal_type='Email')
consistency_message = 'Email must be defined' consistency_message = 'Email must be defined'
self.assertTrue(consistency_message in self.getMessageList(email)) self.assertIn(consistency_message, self.getMessageList(email))
email.setUrlString(self.generateNewId()) email.setUrlString(self.generateNewId())
self.assertFalse(consistency_message in self.getMessageList(email)) self.assertNotIn(consistency_message, self.getMessageList(email))
class TestSlapOSComputeNodeConstraint(TestSlapOSConstraintMixin): class TestSlapOSComputeNodeConstraint(TestSlapOSConstraintMixin):
def test_title_not_empty(self): def test_title_not_empty(self):
compute_node = self.portal.compute_node_module.newContent(portal_type='Compute Node') compute_node = self.portal.compute_node_module.newContent(portal_type='Compute Node')
consistency_message = 'Title must be defined' consistency_message = 'Title must be defined'
self.assertTrue(consistency_message in self.getMessageList(compute_node)) self.assertIn(consistency_message, self.getMessageList(compute_node))
compute_node.setTitle(self.generateNewId()) compute_node.setTitle(self.generateNewId())
self.assertFalse(consistency_message in self.getMessageList(compute_node)) self.assertNotIn(consistency_message, self.getMessageList(compute_node))
class TestSlapOSReferenceConstraint(TestSlapOSConstraintMixin): class TestSlapOSReferenceConstraint(TestSlapOSConstraintMixin):
......
...@@ -1337,8 +1337,8 @@ class TestSlapOSCoreInstanceSlapInterfaceWorkflowTransfer(SlapOSTestCaseMixin): ...@@ -1337,8 +1337,8 @@ class TestSlapOSCoreInstanceSlapInterfaceWorkflowTransfer(SlapOSTestCaseMixin):
self.assertNotEqual(certificate_login.getReference(), None) self.assertNotEqual(certificate_login.getReference(), None)
self.assertNotEqual(certificate_login.getDestinationReference(), None) self.assertNotEqual(certificate_login.getDestinationReference(), None)
serial = '0x%x' % int(certificate_login.getDestinationReference(), 16) serial = '0x%x' % int(certificate_login.getDestinationReference(), 16)
self.assertTrue(serial in self.software_instance.getSslCertificate()) self.assertIn(serial, self.software_instance.getSslCertificate())
self.assertTrue(certificate_login.getReference() in \ self.assertIn(certificate_login.getReference(), \
self.software_instance.getSslCertificate().decode('string_escape')) self.software_instance.getSslCertificate().decode('string_escape'))
self.assertRaises(ValueError, self.software_instance.generateCertificate) self.assertRaises(ValueError, self.software_instance.generateCertificate)
......
...@@ -100,7 +100,7 @@ class TestSlapOSComputeNodeSecurity(TestSlapOSSecurityMixin): ...@@ -100,7 +100,7 @@ class TestSlapOSComputeNodeSecurity(TestSlapOSSecurityMixin):
self.login(user_id) self.login(user_id)
user = getSecurityManager().getUser() user = getSecurityManager().getUser()
self.assertTrue('Authenticated' in user.getRoles()) self.assertIn('Authenticated', user.getRoles())
self.assertSameSet(['R-COMPUTER'], self.assertSameSet(['R-COMPUTER'],
user.getGroups()) user.getGroups())
...@@ -136,7 +136,7 @@ class TestSlapOSSoftwareInstanceSecurity(TestSlapOSSecurityMixin): ...@@ -136,7 +136,7 @@ class TestSlapOSSoftwareInstanceSecurity(TestSlapOSSecurityMixin):
# instance w/o subscription is loggable and it has some roles # instance w/o subscription is loggable and it has some roles
self.login(user_id) self.login(user_id)
user = getSecurityManager().getUser() user = getSecurityManager().getUser()
self.assertTrue('Authenticated' in user.getRoles()) self.assertIn('Authenticated', user.getRoles())
self.assertSameSet(['R-INSTANCE'], self.assertSameSet(['R-INSTANCE'],
user.getGroups()) user.getGroups())
...@@ -154,7 +154,7 @@ class TestSlapOSSoftwareInstanceSecurity(TestSlapOSSecurityMixin): ...@@ -154,7 +154,7 @@ class TestSlapOSSoftwareInstanceSecurity(TestSlapOSSecurityMixin):
self.portal.portal_caches.clearAllCache() self.portal.portal_caches.clearAllCache()
self.login(user_id) self.login(user_id)
user = getSecurityManager().getUser() user = getSecurityManager().getUser()
self.assertTrue('Authenticated' in user.getRoles()) self.assertIn('Authenticated', user.getRoles())
self.assertSameSet(['R-INSTANCE', subscription_reference], self.assertSameSet(['R-INSTANCE', subscription_reference],
user.getGroups()) user.getGroups())
...@@ -196,7 +196,7 @@ class TestSlapOSPersonSecurity(TestSlapOSSecurityMixin): ...@@ -196,7 +196,7 @@ class TestSlapOSPersonSecurity(TestSlapOSSecurityMixin):
self.login(person.getUserId()) self.login(person.getUserId())
user = getSecurityManager().getUser() user = getSecurityManager().getUser()
self.assertTrue('Authenticated' in user.getRoles()) self.assertIn('Authenticated', user.getRoles())
self.assertSameSet([], user.getGroups()) self.assertSameSet([], user.getGroups())
...@@ -209,7 +209,7 @@ class TestSlapOSPersonSecurity(TestSlapOSSecurityMixin): ...@@ -209,7 +209,7 @@ class TestSlapOSPersonSecurity(TestSlapOSSecurityMixin):
self.portal.portal_caches.clearAllCache() self.portal.portal_caches.clearAllCache()
self.login(person.getUserId()) self.login(person.getUserId())
user = getSecurityManager().getUser() user = getSecurityManager().getUser()
self.assertTrue('Authenticated' in user.getRoles()) self.assertIn('Authenticated', user.getRoles())
self.assertSameSet(['G-COMPANY'], user.getGroups()) self.assertSameSet(['G-COMPANY'], user.getGroups())
# add to role category # add to role category
...@@ -220,7 +220,7 @@ class TestSlapOSPersonSecurity(TestSlapOSSecurityMixin): ...@@ -220,7 +220,7 @@ class TestSlapOSPersonSecurity(TestSlapOSSecurityMixin):
self.portal.portal_caches.clearAllCache() self.portal.portal_caches.clearAllCache()
self.login(person.getUserId()) self.login(person.getUserId())
user = getSecurityManager().getUser() user = getSecurityManager().getUser()
self.assertTrue('Authenticated' in user.getRoles()) self.assertIn('Authenticated', user.getRoles())
self.assertSameSet(['R-MEMBER', 'G-COMPANY'], user.getGroups()) self.assertSameSet(['R-MEMBER', 'G-COMPANY'], user.getGroups())
# add to role for project # add to role for project
...@@ -236,7 +236,7 @@ class TestSlapOSPersonSecurity(TestSlapOSSecurityMixin): ...@@ -236,7 +236,7 @@ class TestSlapOSPersonSecurity(TestSlapOSSecurityMixin):
self.portal.portal_caches.clearAllCache() self.portal.portal_caches.clearAllCache()
self.login(person.getUserId()) self.login(person.getUserId())
user = getSecurityManager().getUser() user = getSecurityManager().getUser()
self.assertTrue('Authenticated' in user.getRoles()) self.assertIn('Authenticated', user.getRoles())
self.assertSameSet(['R-MEMBER', 'G-COMPANY', project.getReference()], user.getGroups()) self.assertSameSet(['R-MEMBER', 'G-COMPANY', project.getReference()], user.getGroups())
# add to role for project # add to role for project
...@@ -253,7 +253,7 @@ class TestSlapOSPersonSecurity(TestSlapOSSecurityMixin): ...@@ -253,7 +253,7 @@ class TestSlapOSPersonSecurity(TestSlapOSSecurityMixin):
self.portal.portal_caches.clearAllCache() self.portal.portal_caches.clearAllCache()
self.login(person.getUserId()) self.login(person.getUserId())
user = getSecurityManager().getUser() user = getSecurityManager().getUser()
self.assertTrue('Authenticated' in user.getRoles()) self.assertIn('Authenticated', user.getRoles())
self.assertSameSet(['R-MEMBER', 'G-COMPANY', organisation.getReference(), self.assertSameSet(['R-MEMBER', 'G-COMPANY', organisation.getReference(),
project.getReference()], user.getGroups()) project.getReference()], user.getGroups())
......
...@@ -54,7 +54,7 @@ class TestSlapOSShadowPerson(TestSlapOSSecurityMixin): ...@@ -54,7 +54,7 @@ class TestSlapOSShadowPerson(TestSlapOSSecurityMixin):
self.login(shadow_user_id) self.login(shadow_user_id)
user = getSecurityManager().getUser() user = getSecurityManager().getUser()
self.assertTrue('Authenticated' in user.getRoles()) self.assertIn('Authenticated', user.getRoles())
self.assertSameSet(['R-SHADOW-PERSON', 'SHADOW-%s' % user_id], self.assertSameSet(['R-SHADOW-PERSON', 'SHADOW-%s' % user_id],
user.getGroups()) user.getGroups())
...@@ -95,7 +95,7 @@ class TestSlapOSShadowComputeNode(TestSlapOSSecurityMixin): ...@@ -95,7 +95,7 @@ class TestSlapOSShadowComputeNode(TestSlapOSSecurityMixin):
self.login(shadow_user_id) self.login(shadow_user_id)
user = getSecurityManager().getUser() user = getSecurityManager().getUser()
self.assertTrue('Authenticated' in user.getRoles()) self.assertIn('Authenticated', user.getRoles())
self.assertSameSet(['R-SHADOW-COMPUTENODE', 'SHADOW-%s' % user_id], self.assertSameSet(['R-SHADOW-COMPUTENODE', 'SHADOW-%s' % user_id],
user.getGroups()) user.getGroups())
...@@ -135,7 +135,7 @@ class TestSlapOSShadowSoftwareInstance(TestSlapOSSecurityMixin): ...@@ -135,7 +135,7 @@ class TestSlapOSShadowSoftwareInstance(TestSlapOSSecurityMixin):
self.login(shadow_user_id) self.login(shadow_user_id)
user = getSecurityManager().getUser() user = getSecurityManager().getUser()
self.assertTrue('Authenticated' in user.getRoles()) self.assertIn('Authenticated', user.getRoles())
self.assertSameSet(['R-SHADOW-SOFTWAREINSTANCE', 'SHADOW-%s' % user_id], self.assertSameSet(['R-SHADOW-SOFTWAREINSTANCE', 'SHADOW-%s' % user_id],
user.getGroups()) user.getGroups())
......
...@@ -32,29 +32,29 @@ class TestSlapOSCloudUpgrader(SlapOSTestCaseMixin): ...@@ -32,29 +32,29 @@ class TestSlapOSCloudUpgrader(SlapOSTestCaseMixin):
) )
# Nothing to migrate # Nothing to migrate
self.assertFalse(migration_message in getMessageList(instance_nothing_to_migrate)) self.assertNotIn(migration_message, getMessageList(instance_nothing_to_migrate))
self.assertFalse(error_message in getMessageList(instance_nothing_to_migrate)) self.assertNotIn(error_message, getMessageList(instance_nothing_to_migrate))
# Migrate # Migrate
self.assertTrue(migration_message in getMessageList(instance_to_migrate)) self.assertIn(migration_message, getMessageList(instance_to_migrate))
self.assertFalse(error_message in getMessageList(instance_to_migrate)) self.assertNotIn(error_message, getMessageList(instance_to_migrate))
instance_to_migrate.fixConsistency() instance_to_migrate.fixConsistency()
self.assertEqual(None, instance_to_migrate.getPredecessor()) self.assertEqual(None, instance_to_migrate.getPredecessor())
self.assertEqual(instance_nothing_to_migrate.getRelativeUrl(), self.assertEqual(instance_nothing_to_migrate.getRelativeUrl(),
instance_to_migrate.getSuccessor()) instance_to_migrate.getSuccessor())
self.assertFalse(migration_message in getMessageList(instance_to_migrate)) self.assertNotIn(migration_message, getMessageList(instance_to_migrate))
self.assertFalse(error_message in getMessageList(instance_to_migrate)) self.assertNotIn(error_message, getMessageList(instance_to_migrate))
# Error # Error
self.assertFalse(migration_message in getMessageList(instance_badly_migrated)) self.assertNotIn(migration_message, getMessageList(instance_badly_migrated))
self.assertTrue(error_message in getMessageList(instance_badly_migrated)) self.assertIn(error_message, getMessageList(instance_badly_migrated))
instance_badly_migrated.fixConsistency() instance_badly_migrated.fixConsistency()
self.assertEqual(instance_nothing_to_migrate.getRelativeUrl(), self.assertEqual(instance_nothing_to_migrate.getRelativeUrl(),
instance_badly_migrated.getPredecessor()) instance_badly_migrated.getPredecessor())
self.assertEqual(instance_nothing_to_migrate.getRelativeUrl(), self.assertEqual(instance_nothing_to_migrate.getRelativeUrl(),
instance_badly_migrated.getSuccessor()) instance_badly_migrated.getSuccessor())
self.assertFalse(migration_message in getMessageList(instance_badly_migrated)) self.assertNotIn(migration_message, getMessageList(instance_badly_migrated))
self.assertTrue(error_message in getMessageList(instance_badly_migrated)) self.assertIn(error_message, getMessageList(instance_badly_migrated))
def test_upgrade_software_instance_predecessor(self): def test_upgrade_software_instance_predecessor(self):
return self.check_upgrade_instance_predecessor('Software Instance') return self.check_upgrade_instance_predecessor('Software Instance')
...@@ -107,10 +107,10 @@ class TestSlapOSCloudUpgrader(SlapOSTestCaseMixin): ...@@ -107,10 +107,10 @@ class TestSlapOSCloudUpgrader(SlapOSTestCaseMixin):
self.tic() self.tic()
# Nothing to migrate # Nothing to migrate
self.assertFalse(migration_message in getMessageList(hosting_subscription_nothing_to_migrate)) self.assertNotIn(migration_message, getMessageList(hosting_subscription_nothing_to_migrate))
# To migrate # To migrate
self.assertTrue(migration_message in getMessageList(hosting_subscription_to_migrate)) self.assertIn(migration_message, getMessageList(hosting_subscription_to_migrate))
hosting_subscription_to_migrate.fixConsistency() hosting_subscription_to_migrate.fixConsistency()
self.commit() self.commit()
...@@ -145,8 +145,8 @@ class TestSlapOSCloudUpgrader(SlapOSTestCaseMixin): ...@@ -145,8 +145,8 @@ class TestSlapOSCloudUpgrader(SlapOSTestCaseMixin):
migrated_instance_tree.getCreationDate()) migrated_instance_tree.getCreationDate())
# self.assertEqual(modification_date, # self.assertEqual(modification_date,
# migrated_instance_tree.getModificationDate()) # migrated_instance_tree.getModificationDate())
self.assertFalse('hosting_subscription_workflow' in migrated_instance_tree.workflow_history) self.assertNotIn('hosting_subscription_workflow', migrated_instance_tree.workflow_history)
self.assertFalse(migration_message in getMessageList(migrated_instance_tree)) self.assertNotIn(migration_message, getMessageList(migrated_instance_tree))
self.assertEqual(migrated_instance_tree.getRelativeUrl(), self.assertEqual(migrated_instance_tree.getRelativeUrl(),
software_instance.getAggregate()) software_instance.getAggregate())
self.assertEqual(1, len(self.portal.portal_catalog(uid=migrated_instance_tree.getUid()))) self.assertEqual(1, len(self.portal.portal_catalog(uid=migrated_instance_tree.getUid())))
...@@ -213,10 +213,10 @@ class TestSlapOSCloudUpgrader(SlapOSTestCaseMixin): ...@@ -213,10 +213,10 @@ class TestSlapOSCloudUpgrader(SlapOSTestCaseMixin):
self.tic() self.tic()
# Nothing to migrate # Nothing to migrate
self.assertFalse(migration_message in getMessageList(computer_nothing_to_migrate)) self.assertNotIn(migration_message, getMessageList(computer_nothing_to_migrate))
# To migrate # To migrate
self.assertTrue(migration_message in getMessageList(computer_to_migrate)) self.assertIn(migration_message, getMessageList(computer_to_migrate))
computer_to_migrate.fixConsistency() computer_to_migrate.fixConsistency()
self.commit() self.commit()
...@@ -258,9 +258,9 @@ class TestSlapOSCloudUpgrader(SlapOSTestCaseMixin): ...@@ -258,9 +258,9 @@ class TestSlapOSCloudUpgrader(SlapOSTestCaseMixin):
migrated_compute_node.getCreationDate()) migrated_compute_node.getCreationDate())
# self.assertEqual(modification_date, # self.assertEqual(modification_date,
# migrated_compute_node.getModificationDate()) # migrated_compute_node.getModificationDate())
self.assertFalse('computer_slap_interface_workflow' in migrated_compute_node.workflow_history) self.assertNotIn('computer_slap_interface_workflow', migrated_compute_node.workflow_history)
self.assertFalse(migration_message in getMessageList(migrated_compute_node)) self.assertNotIn(migration_message, getMessageList(migrated_compute_node))
self.assertEqual(migrated_compute_node.getRelativeUrl(), self.assertEqual(migrated_compute_node.getRelativeUrl(),
software_installation.getAggregate()) software_installation.getAggregate())
self.assertEqual(migrated_computer_partition.getRelativeUrl(), self.assertEqual(migrated_computer_partition.getRelativeUrl(),
...@@ -318,10 +318,10 @@ class TestSlapOSCloudUpgrader(SlapOSTestCaseMixin): ...@@ -318,10 +318,10 @@ class TestSlapOSCloudUpgrader(SlapOSTestCaseMixin):
self.tic() self.tic()
# Nothing to migrate # Nothing to migrate
self.assertFalse(migration_message in getMessageList(computer_nothing_to_migrate)) self.assertNotIn(migration_message, getMessageList(computer_nothing_to_migrate))
# To migrate # To migrate
self.assertTrue(migration_message in getMessageList(computer_partition_to_migrate)) self.assertIn(migration_message, getMessageList(computer_partition_to_migrate))
computer_partition_to_migrate.fixConsistency() computer_partition_to_migrate.fixConsistency()
self.commit() self.commit()
...@@ -344,8 +344,8 @@ class TestSlapOSCloudUpgrader(SlapOSTestCaseMixin): ...@@ -344,8 +344,8 @@ class TestSlapOSCloudUpgrader(SlapOSTestCaseMixin):
migrated_computer_partition.getCreationDate()) migrated_computer_partition.getCreationDate())
# self.assertEqual(modification_date, # self.assertEqual(modification_date,
# migrated_compute_node.getModificationDate()) # migrated_compute_node.getModificationDate())
self.assertFalse('computer_partition_slap_interface_workflow' in migrated_computer_partition.workflow_history) self.assertNotIn('computer_partition_slap_interface_workflow', migrated_computer_partition.workflow_history)
self.assertFalse(migration_message in getMessageList(computer_partition_to_migrate)) self.assertNotIn(migration_message, getMessageList(computer_partition_to_migrate))
self.assertEqual(1, len(self.portal.portal_catalog(uid=migrated_computer_partition.getUid()))) self.assertEqual(1, len(self.portal.portal_catalog(uid=migrated_computer_partition.getUid())))
...@@ -28,6 +28,8 @@ from Products.ERP5Type.Cache import DEFAULT_CACHE_SCOPE ...@@ -28,6 +28,8 @@ from Products.ERP5Type.Cache import DEFAULT_CACHE_SCOPE
from DateTime import DateTime from DateTime import DateTime
import json import json
import transaction import transaction
from six.moves import urllib
def _decode_with_json(value): def _decode_with_json(value):
# Ensure value is serisalisable as json # Ensure value is serisalisable as json
...@@ -62,6 +64,18 @@ class TestSlapOSHalJsonStyleMixin(SlapOSTestCaseMixinWithAbort): ...@@ -62,6 +64,18 @@ class TestSlapOSHalJsonStyleMixin(SlapOSTestCaseMixinWithAbort):
return 'https://monitor.app.officejs.com/#/?username=testuser&url=softinst-monitored/public/feeds&password=testpass&page=ojsm_dispatch&query=portal_type%3A%22Instance%20Tree%22%20AND%20title%3A%22Template%20Instance%20Tree%22' return 'https://monitor.app.officejs.com/#/?username=testuser&url=softinst-monitored/public/feeds&password=testpass&page=ojsm_dispatch&query=portal_type%3A%22Instance%20Tree%22%20AND%20title%3A%22Template%20Instance%20Tree%22'
return '' return ''
def assertMonitorURLEqual(self, first, second):
first_url_parsed = urllib.parse.urlparse(first)
second_url_parsed = urllib.parse.urlparse(second)
self.assertEqual(first_url_parsed._replace(fragment=''), second_url_parsed._replace(fragment=''))
self.assertEqual(first_url_parsed.fragment[:2], second_url_parsed.fragment[:2])
if first_url_parsed.fragment:
# in monitoring url, the fragment is /? and the parameters encoded like a query string
self.assertEqual(first_url_parsed.fragment[:2], '/?')
self.assertEqual(
urllib.parse.parse_qs(first_url_parsed.fragment[2:]),
urllib.parse.parse_qs(second_url_parsed.fragment[2:]))
maxDiff = None maxDiff = None
def afterSetUp(self): def afterSetUp(self):
SlapOSTestCaseMixinWithAbort.afterSetUp(self) SlapOSTestCaseMixinWithAbort.afterSetUp(self)
...@@ -182,12 +196,14 @@ class TestInstanceTree_getNewsDict(TestSlapOSHalJsonStyleMixin): ...@@ -182,12 +196,14 @@ class TestInstanceTree_getNewsDict(TestSlapOSHalJsonStyleMixin):
def test(self): def test(self):
instance_tree = self._makeInstanceTree() instance_tree = self._makeInstanceTree()
news_dict = instance_tree.InstanceTree_getNewsDict() news_dict = instance_tree.InstanceTree_getNewsDict()
self.assertMonitorURLEqual(
news_dict.pop('monitor_url'),
self.getMonitorUrl(instance_tree))
expected_news_dict = { expected_news_dict = {
'instance': [], 'instance': [],
'portal_type': instance_tree.getPortalType(), 'portal_type': instance_tree.getPortalType(),
'reference': instance_tree.getReference(), 'reference': instance_tree.getReference(),
'title': instance_tree.getTitle(), 'title': instance_tree.getTitle(),
'monitor_url': self.getMonitorUrl(instance_tree)
} }
self.assertEqual(_decode_with_json(news_dict), self.assertEqual(_decode_with_json(news_dict),
_decode_with_json(expected_news_dict)) _decode_with_json(expected_news_dict))
...@@ -196,11 +212,13 @@ class TestInstanceTree_getNewsDict(TestSlapOSHalJsonStyleMixin): ...@@ -196,11 +212,13 @@ class TestInstanceTree_getNewsDict(TestSlapOSHalJsonStyleMixin):
instance_tree = self._makeInstanceTree() instance_tree = self._makeInstanceTree()
instance_tree.setRootSlave(1) instance_tree.setRootSlave(1)
news_dict = instance_tree.InstanceTree_getNewsDict() news_dict = instance_tree.InstanceTree_getNewsDict()
self.assertMonitorURLEqual(
news_dict.pop('monitor_url'),
self.getMonitorUrl(instance_tree))
expected_news_dict = {'instance': [], expected_news_dict = {'instance': [],
'portal_type': instance_tree.getPortalType(), 'portal_type': instance_tree.getPortalType(),
'reference': instance_tree.getReference(), 'reference': instance_tree.getReference(),
'title': instance_tree.getTitle(), 'title': instance_tree.getTitle(),
'monitor_url': self.getMonitorUrl(instance_tree),
'is_slave': 1 'is_slave': 1
} }
self.assertEqual(news_dict, self.assertEqual(news_dict,
...@@ -210,11 +228,13 @@ class TestInstanceTree_getNewsDict(TestSlapOSHalJsonStyleMixin): ...@@ -210,11 +228,13 @@ class TestInstanceTree_getNewsDict(TestSlapOSHalJsonStyleMixin):
instance_tree = self._makeInstanceTree() instance_tree = self._makeInstanceTree()
instance_tree.getSlapState = fakeStopRequestedSlapState instance_tree.getSlapState = fakeStopRequestedSlapState
news_dict = instance_tree.InstanceTree_getNewsDict() news_dict = instance_tree.InstanceTree_getNewsDict()
self.assertMonitorURLEqual(
news_dict.pop('monitor_url'),
self.getMonitorUrl(instance_tree))
expected_news_dict = {'instance': [], expected_news_dict = {'instance': [],
'portal_type': instance_tree.getPortalType(), 'portal_type': instance_tree.getPortalType(),
'reference': instance_tree.getReference(), 'reference': instance_tree.getReference(),
'title': instance_tree.getTitle(), 'title': instance_tree.getTitle(),
'monitor_url': self.getMonitorUrl(instance_tree),
'is_stopped': 1 'is_stopped': 1
} }
self.assertEqual(_decode_with_json(news_dict), self.assertEqual(_decode_with_json(news_dict),
...@@ -224,11 +244,13 @@ class TestInstanceTree_getNewsDict(TestSlapOSHalJsonStyleMixin): ...@@ -224,11 +244,13 @@ class TestInstanceTree_getNewsDict(TestSlapOSHalJsonStyleMixin):
instance_tree = self._makeInstanceTree() instance_tree = self._makeInstanceTree()
instance_tree.getSlapState = fakeDestroyRequestedSlapState instance_tree.getSlapState = fakeDestroyRequestedSlapState
news_dict = instance_tree.InstanceTree_getNewsDict() news_dict = instance_tree.InstanceTree_getNewsDict()
self.assertMonitorURLEqual(
news_dict.pop('monitor_url'),
self.getMonitorUrl(instance_tree))
expected_news_dict = {'instance': [], expected_news_dict = {'instance': [],
'portal_type': instance_tree.getPortalType(), 'portal_type': instance_tree.getPortalType(),
'reference': instance_tree.getReference(), 'reference': instance_tree.getReference(),
'title': instance_tree.getTitle(), 'title': instance_tree.getTitle(),
'monitor_url': self.getMonitorUrl(instance_tree),
'is_destroyed': 1 'is_destroyed': 1
} }
self.assertEqual(_decode_with_json(news_dict), self.assertEqual(_decode_with_json(news_dict),
...@@ -242,17 +264,21 @@ class TestInstanceTree_getNewsDict(TestSlapOSHalJsonStyleMixin): ...@@ -242,17 +264,21 @@ class TestInstanceTree_getNewsDict(TestSlapOSHalJsonStyleMixin):
self.tic() self.tic()
self.changeSkin('Hal') self.changeSkin('Hal')
news_dict = instance_tree.InstanceTree_getNewsDict() news_dict = instance_tree.InstanceTree_getNewsDict()
self.assertMonitorURLEqual(
news_dict.pop('monitor_url'),
self.getMonitorUrl(instance_tree))
self.assertMonitorURLEqual(
news_dict['instance'][0].pop('monitor_url'),
self.getMonitorUrl(instance))
expected_news_dict = { expected_news_dict = {
'portal_type': instance_tree.getPortalType(), 'portal_type': instance_tree.getPortalType(),
'reference': instance_tree.getReference(), 'reference': instance_tree.getReference(),
'title': instance_tree.getTitle(), 'title': instance_tree.getTitle(),
'monitor_url': self.getMonitorUrl(instance_tree),
'instance': [{'created_at': self.created_at, 'instance': [{'created_at': self.created_at,
'no_data': 1, 'no_data': 1,
'portal_type': instance.getPortalType(), 'portal_type': instance.getPortalType(),
'reference': instance.getReference(), 'reference': instance.getReference(),
'since': self.created_at, 'since': self.created_at,
'monitor_url': self.getMonitorUrl(instance),
'state': '', 'state': '',
'text': '#error no data found for %s' % instance.getReference(), 'text': '#error no data found for %s' % instance.getReference(),
'user': 'SlapOS Master'}] 'user': 'SlapOS Master'}]
...@@ -268,12 +294,14 @@ class TestInstanceTree_getNewsDict(TestSlapOSHalJsonStyleMixin): ...@@ -268,12 +294,14 @@ class TestInstanceTree_getNewsDict(TestSlapOSHalJsonStyleMixin):
self.tic() self.tic()
self.changeSkin('Hal') self.changeSkin('Hal')
news_dict = instance_tree.InstanceTree_getNewsDict() news_dict = instance_tree.InstanceTree_getNewsDict()
self.assertMonitorURLEqual(
news_dict.pop('monitor_url'),
self.getMonitorUrl(instance_tree))
expected_news_dict = { expected_news_dict = {
'portal_type': instance_tree.getPortalType(), 'portal_type': instance_tree.getPortalType(),
'reference': instance_tree.getReference(), 'reference': instance_tree.getReference(),
'title': instance_tree.getTitle(), 'title': instance_tree.getTitle(),
'instance': [], 'instance': [],
'monitor_url': self.getMonitorUrl(instance_tree)
} }
self.assertEqual(_decode_with_json(news_dict), self.assertEqual(_decode_with_json(news_dict),
_decode_with_json(expected_news_dict)) _decode_with_json(expected_news_dict))
...@@ -288,18 +316,25 @@ class TestInstanceTree_getNewsDict(TestSlapOSHalJsonStyleMixin): ...@@ -288,18 +316,25 @@ class TestInstanceTree_getNewsDict(TestSlapOSHalJsonStyleMixin):
self.tic() self.tic()
self.changeSkin('Hal') self.changeSkin('Hal')
news_dict = instance_tree.InstanceTree_getNewsDict() news_dict = instance_tree.InstanceTree_getNewsDict()
self.assertMonitorURLEqual(
news_dict.pop('monitor_url'),
self.getMonitorUrl(instance_tree))
self.assertMonitorURLEqual(
news_dict['instance'][0].pop('monitor_url'),
self.getMonitorUrl(instance0))
self.assertMonitorURLEqual(
news_dict['instance'][1].pop('monitor_url'),
self.getMonitorUrl(instance))
expected_news_dict = { expected_news_dict = {
'portal_type': instance_tree.getPortalType(), 'portal_type': instance_tree.getPortalType(),
'reference': instance_tree.getReference(), 'reference': instance_tree.getReference(),
'title': instance_tree.getTitle(), 'title': instance_tree.getTitle(),
'monitor_url': self.getMonitorUrl(instance_tree),
'instance': [ 'instance': [
{'created_at': self.created_at, {'created_at': self.created_at,
'no_data': 1, 'no_data': 1,
'portal_type': instance0.getPortalType(), 'portal_type': instance0.getPortalType(),
'reference': instance0.getReference(), 'reference': instance0.getReference(),
'since': self.created_at, 'since': self.created_at,
'monitor_url': self.getMonitorUrl(instance0),
'state': '', 'state': '',
'text': '#error no data found for %s' % instance0.getReference(), 'text': '#error no data found for %s' % instance0.getReference(),
'user': 'SlapOS Master'}, 'user': 'SlapOS Master'},
...@@ -308,7 +343,6 @@ class TestInstanceTree_getNewsDict(TestSlapOSHalJsonStyleMixin): ...@@ -308,7 +343,6 @@ class TestInstanceTree_getNewsDict(TestSlapOSHalJsonStyleMixin):
'portal_type': instance.getPortalType(), 'portal_type': instance.getPortalType(),
'reference': instance.getReference(), 'reference': instance.getReference(),
'since': self.created_at, 'since': self.created_at,
'monitor_url': self.getMonitorUrl(instance),
'state': '', 'state': '',
'text': '#error no data found for %s' % instance.getReference(), 'text': '#error no data found for %s' % instance.getReference(),
'user': 'SlapOS Master'}]} 'user': 'SlapOS Master'}]}
...@@ -325,12 +359,14 @@ class TestSoftwareInstance_getNewsDict(TestSlapOSHalJsonStyleMixin): ...@@ -325,12 +359,14 @@ class TestSoftwareInstance_getNewsDict(TestSlapOSHalJsonStyleMixin):
instance_tree.edit(successor_value=instance) instance_tree.edit(successor_value=instance)
self._logFakeAccess(instance) self._logFakeAccess(instance)
news_dict = instance.SoftwareInstance_getNewsDict() news_dict = instance.SoftwareInstance_getNewsDict()
self.assertMonitorURLEqual(
news_dict.pop('monitor_url'),
self.getMonitorUrl(instance))
expected_news_dict = {'created_at': self.created_at, expected_news_dict = {'created_at': self.created_at,
'no_data_since_15_minutes': 0, 'no_data_since_15_minutes': 0,
'no_data_since_5_minutes': 0, 'no_data_since_5_minutes': 0,
'portal_type': instance.getPortalType(), 'portal_type': instance.getPortalType(),
'reference': instance.getReference(), 'reference': instance.getReference(),
'monitor_url': self.getMonitorUrl(instance),
'since': self.created_at, 'since': self.created_at,
'state': 'start_requested', 'state': 'start_requested',
'text': '#access OK', 'text': '#access OK',
...@@ -347,6 +383,9 @@ class TestSoftwareInstance_getNewsDict(TestSlapOSHalJsonStyleMixin): ...@@ -347,6 +383,9 @@ class TestSoftwareInstance_getNewsDict(TestSlapOSHalJsonStyleMixin):
self.changeSkin('Hal') self.changeSkin('Hal')
news_dict = instance.SoftwareInstance_getNewsDict() news_dict = instance.SoftwareInstance_getNewsDict()
self.assertMonitorURLEqual(
news_dict.pop('monitor_url'),
self.getMonitorUrl(instance))
expected_news_dict = {'created_at': self.created_at, expected_news_dict = {'created_at': self.created_at,
'no_data': 1, 'no_data': 1,
'portal_type': instance.getPortalType(), 'portal_type': instance.getPortalType(),
...@@ -354,7 +393,6 @@ class TestSoftwareInstance_getNewsDict(TestSlapOSHalJsonStyleMixin): ...@@ -354,7 +393,6 @@ class TestSoftwareInstance_getNewsDict(TestSlapOSHalJsonStyleMixin):
'since': self.created_at, 'since': self.created_at,
'state': '', 'state': '',
'text': '#error no data found for %s' % instance.getReference(), 'text': '#error no data found for %s' % instance.getReference(),
'monitor_url': self.getMonitorUrl(instance),
'user': 'SlapOS Master'} 'user': 'SlapOS Master'}
self.assertEqual(_decode_with_json(news_dict), self.assertEqual(_decode_with_json(news_dict),
...@@ -366,12 +404,14 @@ class TestSoftwareInstance_getNewsDict(TestSlapOSHalJsonStyleMixin): ...@@ -366,12 +404,14 @@ class TestSoftwareInstance_getNewsDict(TestSlapOSHalJsonStyleMixin):
instance.edit(specialise_value=instance_tree) instance.edit(specialise_value=instance_tree)
instance_tree.edit(successor_value=instance) instance_tree.edit(successor_value=instance)
news_dict = instance.SoftwareInstance_getNewsDict() news_dict = instance.SoftwareInstance_getNewsDict()
self.assertMonitorURLEqual(
news_dict.pop('monitor_url'),
'https://monitor.app.officejs.com/#/?username=testuser&url=softinst-monitored/public/feeds&password=testpass&page=ojsm_dispatch&query=portal_type%3A%22Software%20Instance%22%20AND%20title%3A%22Template%20Slave%20Instance%22%20AND%20specialise_title%3A%22Template%20Instance%20Tree%22')
expected_news_dict = { expected_news_dict = {
'portal_type': instance.getPortalType(), 'portal_type': instance.getPortalType(),
'reference': instance.getReference(), 'reference': instance.getReference(),
'is_slave': 1, 'is_slave': 1,
'text': '#nodata is a slave %s' % instance.getReference(), 'text': '#nodata is a slave %s' % instance.getReference(),
'monitor_url': 'https://monitor.app.officejs.com/#/?username=testuser&url=softinst-monitored/public/feeds&password=testpass&page=ojsm_dispatch&query=portal_type%3A%22Software%20Instance%22%20AND%20title%3A%22Template%20Slave%20Instance%22%20AND%20specialise_title%3A%22Template%20Instance%20Tree%22',
'user': 'SlapOS Master'} 'user': 'SlapOS Master'}
self.assertEqual(_decode_with_json(news_dict), self.assertEqual(_decode_with_json(news_dict),
_decode_with_json(expected_news_dict)) _decode_with_json(expected_news_dict))
...@@ -383,12 +423,14 @@ class TestSoftwareInstance_getNewsDict(TestSlapOSHalJsonStyleMixin): ...@@ -383,12 +423,14 @@ class TestSoftwareInstance_getNewsDict(TestSlapOSHalJsonStyleMixin):
instance_tree.edit(successor_value=instance) instance_tree.edit(successor_value=instance)
instance.getSlapState = fakeStopRequestedSlapState instance.getSlapState = fakeStopRequestedSlapState
news_dict = instance.SoftwareInstance_getNewsDict() news_dict = instance.SoftwareInstance_getNewsDict()
self.assertMonitorURLEqual(
news_dict.pop('monitor_url'),
self.getMonitorUrl(instance))
expected_news_dict = { expected_news_dict = {
"portal_type": instance.getPortalType(), "portal_type": instance.getPortalType(),
"reference": instance.getReference(), "reference": instance.getReference(),
"user": "SlapOS Master", "user": "SlapOS Master",
"text": "#nodata is an stopped instance %s" % instance.getReference(), "text": "#nodata is an stopped instance %s" % instance.getReference(),
'monitor_url': self.getMonitorUrl(instance),
"is_stopped": 1 "is_stopped": 1
} }
self.assertEqual(_decode_with_json(news_dict), self.assertEqual(_decode_with_json(news_dict),
...@@ -400,12 +442,14 @@ class TestSoftwareInstance_getNewsDict(TestSlapOSHalJsonStyleMixin): ...@@ -400,12 +442,14 @@ class TestSoftwareInstance_getNewsDict(TestSlapOSHalJsonStyleMixin):
instance.edit(specialise_value=instance_tree) instance.edit(specialise_value=instance_tree)
instance.getSlapState = fakeDestroyRequestedSlapState instance.getSlapState = fakeDestroyRequestedSlapState
news_dict = instance.SoftwareInstance_getNewsDict() news_dict = instance.SoftwareInstance_getNewsDict()
self.assertMonitorURLEqual(
news_dict.pop('monitor_url'),
self.getMonitorUrl(instance))
expected_news_dict = { expected_news_dict = {
"portal_type": instance.getPortalType(), "portal_type": instance.getPortalType(),
"reference": instance.getReference(), "reference": instance.getReference(),
"user": "SlapOS Master", "user": "SlapOS Master",
"text": "#nodata is an destroyed instance %s" % instance.getReference(), "text": "#nodata is an destroyed instance %s" % instance.getReference(),
'monitor_url': self.getMonitorUrl(instance),
"is_destroyed": 1 "is_destroyed": 1
} }
self.assertEqual(_decode_with_json(news_dict), self.assertEqual(_decode_with_json(news_dict),
......
...@@ -37,7 +37,9 @@ class TestSlapOSRenderJSOSSUIHalStyle(SlapOSTestCaseMixin, ERP5TypeFunctionalTes ...@@ -37,7 +37,9 @@ class TestSlapOSRenderJSOSSUIHalStyle(SlapOSTestCaseMixin, ERP5TypeFunctionalTes
ERP5TypeFunctionalTestCase.afterSetUp(self) ERP5TypeFunctionalTestCase.afterSetUp(self)
SlapOSTestCaseMixin.afterSetUp(self) SlapOSTestCaseMixin.afterSetUp(self)
# Ensuring the default available language is "en" for English UI test # Ensuring the default available language is "en" for English UI test
self.getPortalObject().web_site_module.renderjs_oss.setDefaultAvailableLanguage('en') self.portal.web_site_module.renderjs_oss.setDefaultAvailableLanguage('en')
# fix consistency to update translation
self.portal.web_site_module.renderjs_oss.fixConsistency()
self.tic() self.tic()
def test_suite(): def test_suite():
......
...@@ -37,7 +37,9 @@ class TestSlapOSUIZHHalStyle(SlapOSTestCaseMixin, ERP5TypeFunctionalTestCase): ...@@ -37,7 +37,9 @@ class TestSlapOSUIZHHalStyle(SlapOSTestCaseMixin, ERP5TypeFunctionalTestCase):
ERP5TypeFunctionalTestCase.afterSetUp(self) ERP5TypeFunctionalTestCase.afterSetUp(self)
SlapOSTestCaseMixin.afterSetUp(self) SlapOSTestCaseMixin.afterSetUp(self)
# set default available language as "zh" for Chinese UI test # set default available language as "zh" for Chinese UI test
self.getPortalObject().web_site_module.hostingjs.setDefaultAvailableLanguage('zh') self.portal.web_site_module.hostingjs.setDefaultAvailableLanguage('zh')
# fix consistency to update translation
self.portal.web_site_module.hostingjs.fixConsistency()
self.tic() self.tic()
def getBusinessTemplateList(self): def getBusinessTemplateList(self):
......
...@@ -241,11 +241,11 @@ class TestSlapOSDestroySoftwareInstallationWithArchivedSoftwareReleaseAlarm(Slap ...@@ -241,11 +241,11 @@ class TestSlapOSDestroySoftwareInstallationWithArchivedSoftwareReleaseAlarm(Slap
self.tic() self.tic()
v = 'Visited by SoftwareRelease_findAndDestroySoftwareInstallation' v = 'Visited by SoftwareRelease_findAndDestroySoftwareInstallation'
self.assertFalse(v in self.assertNotIn(v,
[q['comment'] for q in published_software_release.workflow_history['edit_workflow']]) [q['comment'] for q in published_software_release.workflow_history['edit_workflow']])
self.assertTrue(v in self.assertIn(v,
[q['comment'] for q in archived_cleaned_software_release.workflow_history['edit_workflow']]) [q['comment'] for q in archived_cleaned_software_release.workflow_history['edit_workflow']])
self.assertTrue(v in self.assertIn(v,
[q['comment'] for q in archived_software_release.workflow_history['edit_workflow']]) [q['comment'] for q in archived_software_release.workflow_history['edit_workflow']])
@simulateByEditWorkflowMark('SoftwareInstallation_destroyWithSoftwareReleaseArchived') @simulateByEditWorkflowMark('SoftwareInstallation_destroyWithSoftwareReleaseArchived')
...@@ -304,9 +304,9 @@ class TestSlapOSDestroySoftwareInstallationWithArchivedSoftwareReleaseAlarm(Slap ...@@ -304,9 +304,9 @@ class TestSlapOSDestroySoftwareInstallationWithArchivedSoftwareReleaseAlarm(Slap
self.tic() self.tic()
v = 'Visited by SoftwareInstallation_destroyWithSoftwareReleaseArchived' v = 'Visited by SoftwareInstallation_destroyWithSoftwareReleaseArchived'
self.assertTrue(v in self.assertIn(v,
[q['comment'] for q in software_installation_validated_request_start.workflow_history['edit_workflow']]) [q['comment'] for q in software_installation_validated_request_start.workflow_history['edit_workflow']])
self.assertFalse(v in self.assertNotIn(v,
[q['comment'] for q in software_installation_validated_request_destroy.workflow_history['edit_workflow']]) [q['comment'] for q in software_installation_validated_request_destroy.workflow_history['edit_workflow']])
self.assertFalse(v in self.assertNotIn(v,
[q['comment'] for q in software_installation_invalidated_request_destroy.workflow_history['edit_workflow']]) [q['comment'] for q in software_installation_invalidated_request_destroy.workflow_history['edit_workflow']])
\ No newline at end of file
...@@ -127,7 +127,7 @@ class TestSlapOSEvent_getRSSTextContent(TestRSSSyleSkinsMixin): ...@@ -127,7 +127,7 @@ class TestSlapOSEvent_getRSSTextContent(TestRSSSyleSkinsMixin):
self.portal.portal_skins.changeSkin('RSS') self.portal.portal_skins.changeSkin('RSS')
text_content = event.Event_getRSSTextContent() text_content = event.Event_getRSSTextContent()
self.assertTrue(event.getTextContent() in text_content) self.assertIn(event.getTextContent(), text_content)
self.assertTrue("Sender: " in text_content, "Sender: not in %s" % text_content) self.assertTrue("Sender: " in text_content, "Sender: not in %s" % text_content)
self.assertTrue("Recipient: " in text_content, "Recipient: not in %s" % text_content) self.assertTrue("Recipient: " in text_content, "Recipient: not in %s" % text_content)
self.assertTrue("Content:" in text_content, "Content: not in %s" % text_content) self.assertTrue("Content:" in text_content, "Content: not in %s" % text_content)
......
...@@ -12,7 +12,6 @@ import time ...@@ -12,7 +12,6 @@ import time
# blurb to make nice XML comparisions # blurb to make nice XML comparisions
from lxml import etree from lxml import etree
import difflib
import hashlib import hashlib
import json import json
from binascii import hexlify from binascii import hexlify
...@@ -38,7 +37,16 @@ class Simulator: ...@@ -38,7 +37,16 @@ class Simulator:
l.append({'recmethod': self.method, l.append({'recmethod': self.method,
'recargs': args, 'recargs': args,
'reckwargs': kwargs}) 'reckwargs': kwargs})
open(self.outfile, 'w').write(repr(l)) with open(self.outfile, 'w') as f:
f.write(repr(l))
def canonical_xml(xml):
return etree.tostring(
etree.fromstring(xml),
method="c14n",
).decode('utf-8')
class TestSlapOSSlapToolMixin(SlapOSTestCaseMixin): class TestSlapOSSlapToolMixin(SlapOSTestCaseMixin):
def afterSetUp(self): def afterSetUp(self):
...@@ -69,6 +77,9 @@ class TestSlapOSSlapToolMixin(SlapOSTestCaseMixin): ...@@ -69,6 +77,9 @@ class TestSlapOSSlapToolMixin(SlapOSTestCaseMixin):
self.unpinDateTime() self.unpinDateTime()
self._cleaupREQUEST() self._cleaupREQUEST()
def assertXMLEqual(self, first, second):
self.assertEqual(canonical_xml(first), canonical_xml(second))
class TestSlapOSSlapToolgetFullComputerInformation(TestSlapOSSlapToolMixin): class TestSlapOSSlapToolgetFullComputerInformation(TestSlapOSSlapToolMixin):
def test_activate_getFullComputerInformation_first_access(self): def test_activate_getFullComputerInformation_first_access(self):
...@@ -92,7 +103,7 @@ class TestSlapOSSlapToolgetFullComputerInformation(TestSlapOSSlapToolMixin): ...@@ -92,7 +103,7 @@ class TestSlapOSSlapToolgetFullComputerInformation(TestSlapOSSlapToolMixin):
) )
) )
self.assertEqual(200, response.status) self.assertEqual(200, response.status)
self.assertTrue('last-modified' not in response.headers) self.assertNotIn('last-modified', response.headers)
self.assertEqual(first_etag, response.headers.get('etag')) self.assertEqual(first_etag, response.headers.get('etag'))
self.assertEqual(first_body_fingerprint, hashData(response.body)) self.assertEqual(first_body_fingerprint, hashData(response.body))
self.assertEqual(0, len(self.portal.portal_activities.getMessageList())) self.assertEqual(0, len(self.portal.portal_activities.getMessageList()))
...@@ -108,7 +119,7 @@ class TestSlapOSSlapToolgetFullComputerInformation(TestSlapOSSlapToolMixin): ...@@ -108,7 +119,7 @@ class TestSlapOSSlapToolgetFullComputerInformation(TestSlapOSSlapToolMixin):
response = self.portal_slap.getFullComputerInformation(self.compute_node_id) response = self.portal_slap.getFullComputerInformation(self.compute_node_id)
self.commit() self.commit()
self.assertEqual(200, response.status) self.assertEqual(200, response.status)
self.assertTrue('last-modified' not in response.headers) self.assertNotIn('last-modified', response.headers)
self.assertEqual(first_etag, response.headers.get('etag')) self.assertEqual(first_etag, response.headers.get('etag'))
self.assertEqual(first_body_fingerprint, hashData(response.body)) self.assertEqual(first_body_fingerprint, hashData(response.body))
self.assertEqual(current_activity_count, len(self.portal.portal_activities.getMessageList())) self.assertEqual(current_activity_count, len(self.portal.portal_activities.getMessageList()))
...@@ -121,7 +132,7 @@ class TestSlapOSSlapToolgetFullComputerInformation(TestSlapOSSlapToolMixin): ...@@ -121,7 +132,7 @@ class TestSlapOSSlapToolgetFullComputerInformation(TestSlapOSSlapToolMixin):
response = self.portal_slap.getFullComputerInformation(self.compute_node_id) response = self.portal_slap.getFullComputerInformation(self.compute_node_id)
self.commit() self.commit()
self.assertEqual(200, response.status) self.assertEqual(200, response.status)
self.assertTrue('last-modified' not in response.headers) self.assertNotIn('last-modified', response.headers)
second_etag = self.compute_node._calculateRefreshEtag() second_etag = self.compute_node._calculateRefreshEtag()
second_body_fingerprint = hashData( second_body_fingerprint = hashData(
self.portal_slap._getSlapComputeNodeXMLFromDict( self.portal_slap._getSlapComputeNodeXMLFromDict(
...@@ -143,7 +154,7 @@ class TestSlapOSSlapToolgetFullComputerInformation(TestSlapOSSlapToolMixin): ...@@ -143,7 +154,7 @@ class TestSlapOSSlapToolgetFullComputerInformation(TestSlapOSSlapToolMixin):
response = self.portal_slap.getFullComputerInformation(self.compute_node_id) response = self.portal_slap.getFullComputerInformation(self.compute_node_id)
self.commit() self.commit()
self.assertEqual(200, response.status) self.assertEqual(200, response.status)
self.assertTrue('last-modified' not in response.headers) self.assertNotIn('last-modified', response.headers)
self.assertEqual(second_etag, response.headers.get('etag')) self.assertEqual(second_etag, response.headers.get('etag'))
self.assertEqual(first_body_fingerprint, hashData(response.body)) self.assertEqual(first_body_fingerprint, hashData(response.body))
self.assertEqual(0, len(self.portal.portal_activities.getMessageList())) self.assertEqual(0, len(self.portal.portal_activities.getMessageList()))
...@@ -168,7 +179,7 @@ class TestSlapOSSlapToolgetFullComputerInformation(TestSlapOSSlapToolMixin): ...@@ -168,7 +179,7 @@ class TestSlapOSSlapToolgetFullComputerInformation(TestSlapOSSlapToolMixin):
response = self.portal_slap.getFullComputerInformation(self.compute_node_id) response = self.portal_slap.getFullComputerInformation(self.compute_node_id)
self.commit() self.commit()
self.assertEqual(200, response.status) self.assertEqual(200, response.status)
self.assertTrue('last-modified' not in response.headers) self.assertNotIn('last-modified', response.headers)
self.assertEqual(second_etag, response.headers.get('etag')) self.assertEqual(second_etag, response.headers.get('etag'))
self.assertEqual(first_body_fingerprint, hashData(response.body)) self.assertEqual(first_body_fingerprint, hashData(response.body))
self.assertEqual(current_activity_count, len(self.portal.portal_activities.getMessageList())) self.assertEqual(current_activity_count, len(self.portal.portal_activities.getMessageList()))
...@@ -182,7 +193,7 @@ class TestSlapOSSlapToolgetFullComputerInformation(TestSlapOSSlapToolMixin): ...@@ -182,7 +193,7 @@ class TestSlapOSSlapToolgetFullComputerInformation(TestSlapOSSlapToolMixin):
response = self.portal_slap.getFullComputerInformation(self.compute_node_id) response = self.portal_slap.getFullComputerInformation(self.compute_node_id)
self.commit() self.commit()
self.assertEqual(200, response.status) self.assertEqual(200, response.status)
self.assertTrue('last-modified' not in response.headers) self.assertNotIn('last-modified', response.headers)
third_etag = self.compute_node._calculateRefreshEtag() third_etag = self.compute_node._calculateRefreshEtag()
self.assertNotEqual(second_etag, third_etag) self.assertNotEqual(second_etag, third_etag)
self.assertEqual(third_etag, response.headers.get('etag')) self.assertEqual(third_etag, response.headers.get('etag'))
...@@ -209,7 +220,7 @@ class TestSlapOSSlapToolgetFullComputerInformation(TestSlapOSSlapToolMixin): ...@@ -209,7 +220,7 @@ class TestSlapOSSlapToolgetFullComputerInformation(TestSlapOSSlapToolMixin):
response = self.portal_slap.getFullComputerInformation(self.compute_node_id) response = self.portal_slap.getFullComputerInformation(self.compute_node_id)
self.commit() self.commit()
self.assertEqual(200, response.status) self.assertEqual(200, response.status)
self.assertTrue('last-modified' not in response.headers) self.assertNotIn('last-modified', response.headers)
self.assertEqual(third_etag, response.headers.get('etag')) self.assertEqual(third_etag, response.headers.get('etag'))
self.assertEqual(third_body_fingerprint, hashData(response.body)) self.assertEqual(third_body_fingerprint, hashData(response.body))
self.assertEqual(current_activity_count, len(self.portal.portal_activities.getMessageList())) self.assertEqual(current_activity_count, len(self.portal.portal_activities.getMessageList()))
...@@ -225,7 +236,7 @@ class TestSlapOSSlapToolgetFullComputerInformation(TestSlapOSSlapToolMixin): ...@@ -225,7 +236,7 @@ class TestSlapOSSlapToolgetFullComputerInformation(TestSlapOSSlapToolMixin):
response = self.portal_slap.getFullComputerInformation(self.compute_node_id) response = self.portal_slap.getFullComputerInformation(self.compute_node_id)
self.commit() self.commit()
self.assertEqual(200, response.status) self.assertEqual(200, response.status)
self.assertTrue('last-modified' not in response.headers) self.assertNotIn('last-modified', response.headers)
fourth_etag = self.compute_node._calculateRefreshEtag() fourth_etag = self.compute_node._calculateRefreshEtag()
fourth_body_fingerprint = hashData( fourth_body_fingerprint = hashData(
self.portal_slap._getSlapComputeNodeXMLFromDict( self.portal_slap._getSlapComputeNodeXMLFromDict(
...@@ -258,7 +269,7 @@ class TestSlapOSSlapToolComputeNodeAccess(TestSlapOSSlapToolMixin): ...@@ -258,7 +269,7 @@ class TestSlapOSSlapToolComputeNodeAccess(TestSlapOSSlapToolMixin):
response.headers.get('cache-control')) response.headers.get('cache-control'))
self.assertEqual('REMOTE_USER', self.assertEqual('REMOTE_USER',
response.headers.get('vary')) response.headers.get('vary'))
self.assertFalse('etag' in response.headers) self.assertNotIn('etag', response.headers)
self.assertEqual('text/xml; charset=utf-8', self.assertEqual('text/xml; charset=utf-8',
response.headers.get('content-type')) response.headers.get('content-type'))
...@@ -618,8 +629,7 @@ class TestSlapOSSlapToolComputeNodeAccess(TestSlapOSSlapToolMixin): ...@@ -618,8 +629,7 @@ class TestSlapOSSlapToolComputeNodeAccess(TestSlapOSSlapToolMixin):
start_requested_url=self.start_requested_software_installation.getUrlString(), start_requested_url=self.start_requested_software_installation.getUrlString(),
access_status="#error no data found!", access_status="#error no data found!",
) )
self.assertEqual(expected_xml, got_xml, self.assertXMLEqual(expected_xml, got_xml)
'\n'.join([q for q in difflib.unified_diff(expected_xml.split('\n'), got_xml.split('\n'))]))
def test_getComputeNodeInformation(self): def test_getComputeNodeInformation(self):
self.assertEqual('getFullComputerInformation', self.assertEqual('getFullComputerInformation',
...@@ -635,7 +645,7 @@ class TestSlapOSSlapToolComputeNodeAccess(TestSlapOSSlapToolMixin): ...@@ -635,7 +645,7 @@ class TestSlapOSSlapToolComputeNodeAccess(TestSlapOSSlapToolMixin):
response.headers.get('cache-control')) response.headers.get('cache-control'))
self.assertEqual('REMOTE_USER', self.assertEqual('REMOTE_USER',
response.headers.get('vary')) response.headers.get('vary'))
self.assertTrue('last-modified' in response.headers) self.assertIn('last-modified', response.headers)
self.assertEqual('text/xml; charset=utf-8', self.assertEqual('text/xml; charset=utf-8',
response.headers.get('content-type')) response.headers.get('content-type'))
# check returned XML # check returned XML
...@@ -669,8 +679,7 @@ class TestSlapOSSlapToolComputeNodeAccess(TestSlapOSSlapToolMixin): ...@@ -669,8 +679,7 @@ class TestSlapOSSlapToolComputeNodeAccess(TestSlapOSSlapToolMixin):
since=since, since=since,
compute_node_id=self.compute_node_id compute_node_id=self.compute_node_id
) )
self.assertEqual(expected_xml, got_xml, self.assertXMLEqual(expected_xml, got_xml)
'\n'.join([q for q in difflib.unified_diff(expected_xml.split('\n'), got_xml.split('\n'))]))
def test_accessed_getComputerStatus(self): def test_accessed_getComputerStatus(self):
self.login(self.compute_node_user_id) self.login(self.compute_node_user_id)
...@@ -684,7 +693,7 @@ class TestSlapOSSlapToolComputeNodeAccess(TestSlapOSSlapToolMixin): ...@@ -684,7 +693,7 @@ class TestSlapOSSlapToolComputeNodeAccess(TestSlapOSSlapToolMixin):
response.headers.get('cache-control')) response.headers.get('cache-control'))
self.assertEqual('REMOTE_USER', self.assertEqual('REMOTE_USER',
response.headers.get('vary')) response.headers.get('vary'))
self.assertTrue('last-modified' in response.headers) self.assertIn('last-modified', response.headers)
self.assertEqual('text/xml; charset=utf-8', self.assertEqual('text/xml; charset=utf-8',
response.headers.get('content-type')) response.headers.get('content-type'))
...@@ -721,8 +730,7 @@ class TestSlapOSSlapToolComputeNodeAccess(TestSlapOSSlapToolMixin): ...@@ -721,8 +730,7 @@ class TestSlapOSSlapToolComputeNodeAccess(TestSlapOSSlapToolMixin):
since=since, since=since,
compute_node_id=self.compute_node_id compute_node_id=self.compute_node_id
) )
self.assertEqual(expected_xml, got_xml, self.assertXMLEqual(expected_xml, got_xml)
'\n'.join([q for q in difflib.unified_diff(expected_xml.split('\n'), got_xml.split('\n'))]))
def assertComputeNodeBangSimulator(self, args, kwargs): def assertComputeNodeBangSimulator(self, args, kwargs):
stored = eval(open(self.compute_node_bang_simulator).read()) #pylint: disable=eval-used stored = eval(open(self.compute_node_bang_simulator).read()) #pylint: disable=eval-used
...@@ -799,7 +807,7 @@ class TestSlapOSSlapToolComputeNodeAccess(TestSlapOSSlapToolMixin): ...@@ -799,7 +807,7 @@ class TestSlapOSSlapToolComputeNodeAccess(TestSlapOSSlapToolMixin):
response.headers.get('cache-control')) response.headers.get('cache-control'))
self.assertEqual('REMOTE_USER', self.assertEqual('REMOTE_USER',
response.headers.get('vary')) response.headers.get('vary'))
self.assertTrue('last-modified' in response.headers) self.assertIn('last-modified', response.headers)
self.assertEqual('text/xml; charset=utf-8', self.assertEqual('text/xml; charset=utf-8',
response.headers.get('content-type')) response.headers.get('content-type'))
# check returned XML # check returned XML
...@@ -833,8 +841,7 @@ class TestSlapOSSlapToolComputeNodeAccess(TestSlapOSSlapToolMixin): ...@@ -833,8 +841,7 @@ class TestSlapOSSlapToolComputeNodeAccess(TestSlapOSSlapToolMixin):
since=since, since=since,
reference=software_installation.getReference() reference=software_installation.getReference()
) )
self.assertEqual(expected_xml, got_xml, self.assertXMLEqual(expected_xml, got_xml)
'\n'.join([q for q in difflib.unified_diff(expected_xml.split('\n'), got_xml.split('\n'))]))
def test_destroyedSoftwareRelease_noSoftwareInstallation(self): def test_destroyedSoftwareRelease_noSoftwareInstallation(self):
...@@ -907,8 +914,7 @@ class TestSlapOSSlapToolComputeNodeAccess(TestSlapOSSlapToolMixin): ...@@ -907,8 +914,7 @@ class TestSlapOSSlapToolComputeNodeAccess(TestSlapOSSlapToolMixin):
compute_node_id=self.compute_node_id, compute_node_id=self.compute_node_id,
reference=software_installation.getReference() reference=software_installation.getReference()
) )
self.assertEqual(expected_xml, got_xml, self.assertXMLEqual(expected_xml, got_xml)
'\n'.join([q for q in difflib.unified_diff(expected_xml.split('\n'), got_xml.split('\n'))]))
def test_buildingSoftwareRelease(self): def test_buildingSoftwareRelease(self):
self._makeComplexComputeNode() self._makeComplexComputeNode()
...@@ -957,8 +963,7 @@ class TestSlapOSSlapToolComputeNodeAccess(TestSlapOSSlapToolMixin): ...@@ -957,8 +963,7 @@ class TestSlapOSSlapToolComputeNodeAccess(TestSlapOSSlapToolMixin):
compute_node_id=self.compute_node_id, compute_node_id=self.compute_node_id,
reference=software_installation.getReference() reference=software_installation.getReference()
) )
self.assertEqual(expected_xml, got_xml, self.assertXMLEqual(expected_xml, got_xml)
'\n'.join([q for q in difflib.unified_diff(expected_xml.split('\n'), got_xml.split('\n'))]))
def test_softwareReleaseError(self): def test_softwareReleaseError(self):
self._makeComplexComputeNode() self._makeComplexComputeNode()
...@@ -1007,8 +1012,7 @@ class TestSlapOSSlapToolComputeNodeAccess(TestSlapOSSlapToolMixin): ...@@ -1007,8 +1012,7 @@ class TestSlapOSSlapToolComputeNodeAccess(TestSlapOSSlapToolMixin):
compute_node_id=self.compute_node_id, compute_node_id=self.compute_node_id,
reference=software_installation.getReference() reference=software_installation.getReference()
) )
self.assertEqual(expected_xml, got_xml, self.assertXMLEqual(expected_xml, got_xml)
'\n'.join([q for q in difflib.unified_diff(expected_xml.split('\n'), got_xml.split('\n'))]))
def test_useComputer_wrong_xml(self): def test_useComputer_wrong_xml(self):
self.login(self.compute_node_user_id) self.login(self.compute_node_user_id)
...@@ -1126,7 +1130,7 @@ class TestSlapOSSlapToolInstanceAccess(TestSlapOSSlapToolMixin): ...@@ -1126,7 +1130,7 @@ class TestSlapOSSlapToolInstanceAccess(TestSlapOSSlapToolMixin):
response.headers.get('cache-control')) response.headers.get('cache-control'))
self.assertEqual('REMOTE_USER', self.assertEqual('REMOTE_USER',
response.headers.get('vary')) response.headers.get('vary'))
self.assertTrue('last-modified' in response.headers) self.assertIn('last-modified', response.headers)
self.assertEqual('text/xml; charset=utf-8', self.assertEqual('text/xml; charset=utf-8',
response.headers.get('content-type')) response.headers.get('content-type'))
# check returned XML # check returned XML
...@@ -1146,8 +1150,7 @@ class TestSlapOSSlapToolInstanceAccess(TestSlapOSSlapToolMixin): ...@@ -1146,8 +1150,7 @@ class TestSlapOSSlapToolInstanceAccess(TestSlapOSSlapToolMixin):
instance_certificate=self.start_requested_software_instance.getSslCertificate(), instance_certificate=self.start_requested_software_instance.getSslCertificate(),
instance_key=self.start_requested_software_instance.getSslKey() instance_key=self.start_requested_software_instance.getSslKey()
) )
self.assertEqual(expected_xml, got_xml, self.assertXMLEqual(expected_xml, got_xml)
'\n'.join([q for q in difflib.unified_diff(expected_xml.split('\n'), got_xml.split('\n'))]))
def test_getFullComputerInformation(self): def test_getFullComputerInformation(self):
self._makeComplexComputeNode(with_slave=True) self._makeComplexComputeNode(with_slave=True)
...@@ -1158,7 +1161,7 @@ class TestSlapOSSlapToolInstanceAccess(TestSlapOSSlapToolMixin): ...@@ -1158,7 +1161,7 @@ class TestSlapOSSlapToolInstanceAccess(TestSlapOSSlapToolMixin):
response.headers.get('cache-control')) response.headers.get('cache-control'))
self.assertEqual('REMOTE_USER', self.assertEqual('REMOTE_USER',
response.headers.get('vary')) response.headers.get('vary'))
self.assertFalse('etag' in response.headers) self.assertNotIn('etag', response.headers)
self.assertEqual('text/xml; charset=utf-8', self.assertEqual('text/xml; charset=utf-8',
response.headers.get('content-type')) response.headers.get('content-type'))
# check returned XML # check returned XML
...@@ -1288,8 +1291,7 @@ class TestSlapOSSlapToolInstanceAccess(TestSlapOSSlapToolMixin): ...@@ -1288,8 +1291,7 @@ class TestSlapOSSlapToolInstanceAccess(TestSlapOSSlapToolMixin):
slave_1_title=self.start_requested_slave_instance.getTitle(), slave_1_title=self.start_requested_slave_instance.getTitle(),
access_status="#error no data found for %s" % self.start_requested_software_instance.getReference(), access_status="#error no data found for %s" % self.start_requested_software_instance.getReference(),
) )
self.assertEqual(expected_xml, got_xml, self.assertXMLEqual(expected_xml, got_xml)
'\n'.join([q for q in difflib.unified_diff(expected_xml.split('\n'), got_xml.split('\n'))]))
def test_getComputerPartitionStatus(self): def test_getComputerPartitionStatus(self):
self._makeComplexComputeNode() self._makeComplexComputeNode()
...@@ -1305,7 +1307,7 @@ class TestSlapOSSlapToolInstanceAccess(TestSlapOSSlapToolMixin): ...@@ -1305,7 +1307,7 @@ class TestSlapOSSlapToolInstanceAccess(TestSlapOSSlapToolMixin):
response.headers.get('cache-control')) response.headers.get('cache-control'))
self.assertEqual('REMOTE_USER', self.assertEqual('REMOTE_USER',
response.headers.get('vary')) response.headers.get('vary'))
self.assertTrue('last-modified' in response.headers) self.assertIn('last-modified', response.headers)
self.assertEqual('text/xml; charset=utf-8', self.assertEqual('text/xml; charset=utf-8',
response.headers.get('content-type')) response.headers.get('content-type'))
# check returned XML # check returned XML
...@@ -1338,8 +1340,7 @@ class TestSlapOSSlapToolInstanceAccess(TestSlapOSSlapToolMixin): ...@@ -1338,8 +1340,7 @@ class TestSlapOSSlapToolInstanceAccess(TestSlapOSSlapToolMixin):
since=since, since=since,
instance_guid=self.start_requested_software_instance.getReference(), instance_guid=self.start_requested_software_instance.getReference(),
) )
self.assertEqual(expected_xml, got_xml, self.assertXMLEqual(expected_xml, got_xml)
'\n'.join([q for q in difflib.unified_diff(expected_xml.split('\n'), got_xml.split('\n'))]))
def test_getComputerPartitionStatus_visited(self): def test_getComputerPartitionStatus_visited(self):
self._makeComplexComputeNode() self._makeComplexComputeNode()
...@@ -1356,7 +1357,7 @@ class TestSlapOSSlapToolInstanceAccess(TestSlapOSSlapToolMixin): ...@@ -1356,7 +1357,7 @@ class TestSlapOSSlapToolInstanceAccess(TestSlapOSSlapToolMixin):
response.headers.get('cache-control')) response.headers.get('cache-control'))
self.assertEqual('REMOTE_USER', self.assertEqual('REMOTE_USER',
response.headers.get('vary')) response.headers.get('vary'))
self.assertTrue('last-modified' in response.headers) self.assertIn('last-modified', response.headers)
self.assertEqual('text/xml; charset=utf-8', self.assertEqual('text/xml; charset=utf-8',
response.headers.get('content-type')) response.headers.get('content-type'))
# check returned XML # check returned XML
...@@ -1391,8 +1392,7 @@ class TestSlapOSSlapToolInstanceAccess(TestSlapOSSlapToolMixin): ...@@ -1391,8 +1392,7 @@ class TestSlapOSSlapToolInstanceAccess(TestSlapOSSlapToolMixin):
compute_node_id=self.compute_node_id, compute_node_id=self.compute_node_id,
partition_id=partition_id partition_id=partition_id
) )
self.assertEqual(expected_xml, got_xml, self.assertXMLEqual(expected_xml, got_xml)
'\n'.join([q for q in difflib.unified_diff(expected_xml.split('\n'), got_xml.split('\n'))]))
def test_registerComputerPartition_withSlave(self): def test_registerComputerPartition_withSlave(self):
self._makeComplexComputeNode(with_slave=True) self._makeComplexComputeNode(with_slave=True)
...@@ -1405,7 +1405,7 @@ class TestSlapOSSlapToolInstanceAccess(TestSlapOSSlapToolMixin): ...@@ -1405,7 +1405,7 @@ class TestSlapOSSlapToolInstanceAccess(TestSlapOSSlapToolMixin):
response.headers.get('cache-control')) response.headers.get('cache-control'))
self.assertEqual('REMOTE_USER', self.assertEqual('REMOTE_USER',
response.headers.get('vary')) response.headers.get('vary'))
self.assertTrue('last-modified' in response.headers) self.assertIn('last-modified', response.headers)
self.assertEqual('text/xml; charset=utf-8', self.assertEqual('text/xml; charset=utf-8',
response.headers.get('content-type')) response.headers.get('content-type'))
# check returned XML # check returned XML
...@@ -1522,8 +1522,7 @@ class TestSlapOSSlapToolInstanceAccess(TestSlapOSSlapToolMixin): ...@@ -1522,8 +1522,7 @@ class TestSlapOSSlapToolInstanceAccess(TestSlapOSSlapToolMixin):
slave_1_instance_guid=self.start_requested_slave_instance.getReference(), slave_1_instance_guid=self.start_requested_slave_instance.getReference(),
slave_1_title=self.start_requested_slave_instance.getTitle(), slave_1_title=self.start_requested_slave_instance.getTitle(),
) )
self.assertEqual(expected_xml, got_xml, self.assertXMLEqual(expected_xml, got_xml)
'\n'.join([q for q in difflib.unified_diff(expected_xml.split('\n'), got_xml.split('\n'))]))
def test_registerComputerPartition(self): def test_registerComputerPartition(self):
self._makeComplexComputeNode() self._makeComplexComputeNode()
...@@ -1536,7 +1535,7 @@ class TestSlapOSSlapToolInstanceAccess(TestSlapOSSlapToolMixin): ...@@ -1536,7 +1535,7 @@ class TestSlapOSSlapToolInstanceAccess(TestSlapOSSlapToolMixin):
response.headers.get('cache-control')) response.headers.get('cache-control'))
self.assertEqual('REMOTE_USER', self.assertEqual('REMOTE_USER',
response.headers.get('vary')) response.headers.get('vary'))
self.assertTrue('last-modified' in response.headers) self.assertIn('last-modified', response.headers)
self.assertEqual('text/xml; charset=utf-8', self.assertEqual('text/xml; charset=utf-8',
response.headers.get('content-type')) response.headers.get('content-type'))
# check returned XML # check returned XML
...@@ -1634,8 +1633,7 @@ class TestSlapOSSlapToolInstanceAccess(TestSlapOSSlapToolMixin): ...@@ -1634,8 +1633,7 @@ class TestSlapOSSlapToolInstanceAccess(TestSlapOSSlapToolMixin):
root_instance_title=self.start_requested_software_instance.getSpecialiseValue().getTitle(), root_instance_title=self.start_requested_software_instance.getSpecialiseValue().getTitle(),
software_type=self.start_requested_software_instance.getSourceReference() software_type=self.start_requested_software_instance.getSourceReference()
) )
self.assertEqual(expected_xml, got_xml, self.assertXMLEqual(expected_xml, got_xml)
'\n'.join([q for q in difflib.unified_diff(expected_xml.split('\n'), got_xml.split('\n'))]))
def assertInstanceUpdateConnectionSimulator(self, args, kwargs): def assertInstanceUpdateConnectionSimulator(self, args, kwargs):
stored = eval(open(self.instance_update_connection_simulator).read()) #pylint: disable=eval-used stored = eval(open(self.instance_update_connection_simulator).read()) #pylint: disable=eval-used
...@@ -1757,8 +1755,7 @@ class TestSlapOSSlapToolInstanceAccess(TestSlapOSSlapToolMixin): ...@@ -1757,8 +1755,7 @@ class TestSlapOSSlapToolInstanceAccess(TestSlapOSSlapToolMixin):
since = since, since = since,
instance_guid=self.start_requested_software_instance.getReference(), instance_guid=self.start_requested_software_instance.getReference(),
) )
self.assertEqual(expected_xml, got_xml, self.assertXMLEqual(expected_xml, got_xml)
'\n'.join([q for q in difflib.unified_diff(expected_xml.split('\n'), got_xml.split('\n'))]))
def test_softwareInstanceError_twice(self): def test_softwareInstanceError_twice(self):
self._makeComplexComputeNode() self._makeComplexComputeNode()
...@@ -1805,8 +1802,7 @@ class TestSlapOSSlapToolInstanceAccess(TestSlapOSSlapToolMixin): ...@@ -1805,8 +1802,7 @@ class TestSlapOSSlapToolInstanceAccess(TestSlapOSSlapToolMixin):
since = since, since = since,
instance_guid=self.start_requested_software_instance.getReference(), instance_guid=self.start_requested_software_instance.getReference(),
) )
self.assertEqual(expected_xml, got_xml, self.assertXMLEqual(expected_xml, got_xml)
'\n'.join([q for q in difflib.unified_diff(expected_xml.split('\n'), got_xml.split('\n'))]))
self.unpinDateTime() self.unpinDateTime()
time.sleep(1) time.sleep(1)
...@@ -1855,8 +1851,7 @@ class TestSlapOSSlapToolInstanceAccess(TestSlapOSSlapToolMixin): ...@@ -1855,8 +1851,7 @@ class TestSlapOSSlapToolInstanceAccess(TestSlapOSSlapToolMixin):
since = since, since = since,
instance_guid=self.start_requested_software_instance.getReference(), instance_guid=self.start_requested_software_instance.getReference(),
) )
self.assertEqual(expected_xml, got_xml, self.assertXMLEqual(expected_xml, got_xml)
'\n'.join([q for q in difflib.unified_diff(expected_xml.split('\n'), got_xml.split('\n'))]))
def assertInstanceBangSimulator(self, args, kwargs): def assertInstanceBangSimulator(self, args, kwargs):
stored = eval(open(self.instance_bang_simulator).read()) #pylint: disable=eval-used stored = eval(open(self.instance_bang_simulator).read()) #pylint: disable=eval-used
...@@ -1915,8 +1910,7 @@ class TestSlapOSSlapToolInstanceAccess(TestSlapOSSlapToolMixin): ...@@ -1915,8 +1910,7 @@ class TestSlapOSSlapToolInstanceAccess(TestSlapOSSlapToolMixin):
since=since, since=since,
instance_guid=self.start_requested_software_instance.getReference(), instance_guid=self.start_requested_software_instance.getReference(),
) )
self.assertEqual(expected_xml, got_xml, self.assertXMLEqual(expected_xml, got_xml)
'\n'.join([q for q in difflib.unified_diff(expected_xml.split('\n'), got_xml.split('\n'))]))
self.assertInstanceBangSimulator((), {'comment': error_log, 'bang_tree': True}) self.assertInstanceBangSimulator((), {'comment': error_log, 'bang_tree': True})
finally: finally:
if os.path.exists(self.instance_bang_simulator): if os.path.exists(self.instance_bang_simulator):
...@@ -2254,8 +2248,7 @@ class TestSlapOSSlapToolInstanceAccess(TestSlapOSSlapToolMixin): ...@@ -2254,8 +2248,7 @@ class TestSlapOSSlapToolInstanceAccess(TestSlapOSSlapToolMixin):
since=since, since=since,
instance_guid=self.start_requested_software_instance.getReference(), instance_guid=self.start_requested_software_instance.getReference(),
) )
self.assertEqual(expected_xml, got_xml, self.assertXMLEqual(expected_xml, got_xml)
'\n'.join([q for q in difflib.unified_diff(expected_xml.split('\n'), got_xml.split('\n'))]))
def test_startedComputePartition(self): def test_startedComputePartition(self):
self._makeComplexComputeNode() self._makeComplexComputeNode()
...@@ -2301,8 +2294,7 @@ class TestSlapOSSlapToolInstanceAccess(TestSlapOSSlapToolMixin): ...@@ -2301,8 +2294,7 @@ class TestSlapOSSlapToolInstanceAccess(TestSlapOSSlapToolMixin):
since=since, since=since,
instance_guid=self.start_requested_software_instance.getReference(), instance_guid=self.start_requested_software_instance.getReference(),
) )
self.assertEqual(expected_xml, got_xml, self.assertXMLEqual(expected_xml, got_xml)
'\n'.join([q for q in difflib.unified_diff(expected_xml.split('\n'), got_xml.split('\n'))]))
def test_getSoftwareReleaseListFromSoftwareProduct(self): def test_getSoftwareReleaseListFromSoftwareProduct(self):
new_id = self.generateNewId() new_id = self.generateNewId()
...@@ -2344,8 +2336,7 @@ class TestSlapOSSlapToolInstanceAccess(TestSlapOSSlapToolMixin): ...@@ -2344,8 +2336,7 @@ class TestSlapOSSlapToolInstanceAccess(TestSlapOSSlapToolMixin):
</list> </list>
</marshal> </marshal>
""" % (software_release2.getUrlString(), software_release1.getUrlString()) """ % (software_release2.getUrlString(), software_release1.getUrlString())
self.assertEqual(expected_xml, got_xml, self.assertXMLEqual(expected_xml, got_xml)
'\n'.join([q for q in difflib.unified_diff(expected_xml.split('\n'), got_xml.split('\n'))]))
def test_getSoftwareReleaseListFromSoftwareProduct_effectiveDate(self): def test_getSoftwareReleaseListFromSoftwareProduct_effectiveDate(self):
new_id = self.generateNewId() new_id = self.generateNewId()
...@@ -2391,8 +2382,7 @@ class TestSlapOSSlapToolInstanceAccess(TestSlapOSSlapToolMixin): ...@@ -2391,8 +2382,7 @@ class TestSlapOSSlapToolInstanceAccess(TestSlapOSSlapToolMixin):
</marshal> </marshal>
""" % (software_release3.getUrlString(), software_release1.getUrlString(), """ % (software_release3.getUrlString(), software_release1.getUrlString(),
software_release2.getUrlString()) software_release2.getUrlString())
self.assertEqual(expected_xml, got_xml, self.assertXMLEqual(expected_xml, got_xml)
'\n'.join([q for q in difflib.unified_diff(expected_xml.split('\n'), got_xml.split('\n'))]))
def test_getSoftwareReleaseListFromSoftwareProduct_emptySoftwareProduct(self): def test_getSoftwareReleaseListFromSoftwareProduct_emptySoftwareProduct(self):
new_id = self.generateNewId() new_id = self.generateNewId()
...@@ -2408,8 +2398,7 @@ class TestSlapOSSlapToolInstanceAccess(TestSlapOSSlapToolMixin): ...@@ -2408,8 +2398,7 @@ class TestSlapOSSlapToolInstanceAccess(TestSlapOSSlapToolMixin):
<list id="i2"/> <list id="i2"/>
</marshal> </marshal>
""" """
self.assertEqual(expected_xml, got_xml, self.assertXMLEqual(expected_xml, got_xml)
'\n'.join([q for q in difflib.unified_diff(expected_xml.split('\n'), got_xml.split('\n'))]))
def test_getSoftwareReleaseListFromSoftwareProduct_NoSoftwareProduct(self): def test_getSoftwareReleaseListFromSoftwareProduct_NoSoftwareProduct(self):
response = self.portal_slap.getSoftwareReleaseListFromSoftwareProduct( response = self.portal_slap.getSoftwareReleaseListFromSoftwareProduct(
...@@ -2422,8 +2411,7 @@ class TestSlapOSSlapToolInstanceAccess(TestSlapOSSlapToolMixin): ...@@ -2422,8 +2411,7 @@ class TestSlapOSSlapToolInstanceAccess(TestSlapOSSlapToolMixin):
<list id="i2"/> <list id="i2"/>
</marshal> </marshal>
""" """
self.assertEqual(expected_xml, got_xml, self.assertXMLEqual(expected_xml, got_xml)
'\n'.join([q for q in difflib.unified_diff(expected_xml.split('\n'), got_xml.split('\n'))]))
def test_getSoftwareReleaseListFromSoftwareProduct_fromUrl(self): def test_getSoftwareReleaseListFromSoftwareProduct_fromUrl(self):
new_id = self.generateNewId() new_id = self.generateNewId()
...@@ -2464,8 +2452,7 @@ class TestSlapOSSlapToolInstanceAccess(TestSlapOSSlapToolMixin): ...@@ -2464,8 +2452,7 @@ class TestSlapOSSlapToolInstanceAccess(TestSlapOSSlapToolMixin):
</list> </list>
</marshal> </marshal>
""" % (software_release2.getUrlString(), software_release1.getUrlString()) """ % (software_release2.getUrlString(), software_release1.getUrlString())
self.assertEqual(expected_xml, got_xml, self.assertXMLEqual(expected_xml, got_xml)
'\n'.join([q for q in difflib.unified_diff(expected_xml.split('\n'), got_xml.split('\n'))]))
class TestSlapOSSlapToolPersonAccess(TestSlapOSSlapToolMixin): class TestSlapOSSlapToolPersonAccess(TestSlapOSSlapToolMixin):
...@@ -2495,7 +2482,7 @@ class TestSlapOSSlapToolPersonAccess(TestSlapOSSlapToolMixin): ...@@ -2495,7 +2482,7 @@ class TestSlapOSSlapToolPersonAccess(TestSlapOSSlapToolMixin):
response.headers.get('cache-control')) response.headers.get('cache-control'))
self.assertEqual('REMOTE_USER', self.assertEqual('REMOTE_USER',
response.headers.get('vary')) response.headers.get('vary'))
self.assertTrue('last-modified' in response.headers) self.assertIn('last-modified', response.headers)
self.assertEqual('text/xml; charset=utf-8', self.assertEqual('text/xml; charset=utf-8',
response.headers.get('content-type')) response.headers.get('content-type'))
# check returned XML # check returned XML
...@@ -2529,8 +2516,7 @@ class TestSlapOSSlapToolPersonAccess(TestSlapOSSlapToolMixin): ...@@ -2529,8 +2516,7 @@ class TestSlapOSSlapToolPersonAccess(TestSlapOSSlapToolMixin):
since=since, since=since,
compute_node_id=self.compute_node_id compute_node_id=self.compute_node_id
) )
self.assertEqual(expected_xml, got_xml, self.assertXMLEqual(expected_xml, got_xml)
'\n'.join([q for q in difflib.unified_diff(expected_xml.split('\n'), got_xml.split('\n'))]))
def test_accessed_getComputerStatus(self): def test_accessed_getComputerStatus(self):
self.login(self.compute_node_user_id) self.login(self.compute_node_user_id)
...@@ -2544,7 +2530,7 @@ class TestSlapOSSlapToolPersonAccess(TestSlapOSSlapToolMixin): ...@@ -2544,7 +2530,7 @@ class TestSlapOSSlapToolPersonAccess(TestSlapOSSlapToolMixin):
response.headers.get('cache-control')) response.headers.get('cache-control'))
self.assertEqual('REMOTE_USER', self.assertEqual('REMOTE_USER',
response.headers.get('vary')) response.headers.get('vary'))
self.assertTrue('last-modified' in response.headers) self.assertIn('last-modified', response.headers)
self.assertEqual('text/xml; charset=utf-8', self.assertEqual('text/xml; charset=utf-8',
response.headers.get('content-type')) response.headers.get('content-type'))
...@@ -2581,8 +2567,7 @@ class TestSlapOSSlapToolPersonAccess(TestSlapOSSlapToolMixin): ...@@ -2581,8 +2567,7 @@ class TestSlapOSSlapToolPersonAccess(TestSlapOSSlapToolMixin):
since=since, since=since,
compute_node_id=self.compute_node_id compute_node_id=self.compute_node_id
) )
self.assertEqual(expected_xml, got_xml, self.assertXMLEqual(expected_xml, got_xml)
'\n'.join([q for q in difflib.unified_diff(expected_xml.split('\n'), got_xml.split('\n'))]))
def assertComputeNodeBangSimulator(self, args, kwargs): def assertComputeNodeBangSimulator(self, args, kwargs):
stored = eval(open(self.compute_node_bang_simulator).read()) #pylint: disable=eval-used stored = eval(open(self.compute_node_bang_simulator).read()) #pylint: disable=eval-used
...@@ -2625,7 +2610,7 @@ class TestSlapOSSlapToolPersonAccess(TestSlapOSSlapToolMixin): ...@@ -2625,7 +2610,7 @@ class TestSlapOSSlapToolPersonAccess(TestSlapOSSlapToolMixin):
response.headers.get('cache-control')) response.headers.get('cache-control'))
self.assertEqual('REMOTE_USER', self.assertEqual('REMOTE_USER',
response.headers.get('vary')) response.headers.get('vary'))
self.assertTrue('last-modified' in response.headers) self.assertIn('last-modified', response.headers)
self.assertEqual('text/xml; charset=utf-8', self.assertEqual('text/xml; charset=utf-8',
response.headers.get('content-type')) response.headers.get('content-type'))
# check returned XML # check returned XML
...@@ -2658,8 +2643,7 @@ class TestSlapOSSlapToolPersonAccess(TestSlapOSSlapToolMixin): ...@@ -2658,8 +2643,7 @@ class TestSlapOSSlapToolPersonAccess(TestSlapOSSlapToolMixin):
since=since, since=since,
instance_guid=self.start_requested_software_instance.getReference(), instance_guid=self.start_requested_software_instance.getReference(),
) )
self.assertEqual(expected_xml, got_xml, self.assertXMLEqual(expected_xml, got_xml)
'\n'.join([q for q in difflib.unified_diff(expected_xml.split('\n'), got_xml.split('\n'))]))
def test_getComputerPartitionStatus_visited(self): def test_getComputerPartitionStatus_visited(self):
self._makeComplexComputeNode(person=self.person) self._makeComplexComputeNode(person=self.person)
...@@ -2678,7 +2662,7 @@ class TestSlapOSSlapToolPersonAccess(TestSlapOSSlapToolMixin): ...@@ -2678,7 +2662,7 @@ class TestSlapOSSlapToolPersonAccess(TestSlapOSSlapToolMixin):
response.headers.get('cache-control')) response.headers.get('cache-control'))
self.assertEqual('REMOTE_USER', self.assertEqual('REMOTE_USER',
response.headers.get('vary')) response.headers.get('vary'))
self.assertTrue('last-modified' in response.headers) self.assertIn('last-modified', response.headers)
self.assertEqual('text/xml; charset=utf-8', self.assertEqual('text/xml; charset=utf-8',
response.headers.get('content-type')) response.headers.get('content-type'))
# check returned XML # check returned XML
...@@ -2713,8 +2697,7 @@ class TestSlapOSSlapToolPersonAccess(TestSlapOSSlapToolMixin): ...@@ -2713,8 +2697,7 @@ class TestSlapOSSlapToolPersonAccess(TestSlapOSSlapToolMixin):
compute_node_id=self.compute_node_id, compute_node_id=self.compute_node_id,
partition_id=partition_id partition_id=partition_id
) )
self.assertEqual(expected_xml, got_xml, self.assertXMLEqual(expected_xml, got_xml)
'\n'.join([q for q in difflib.unified_diff(expected_xml.split('\n'), got_xml.split('\n'))]))
def test_registerComputerPartition_withSlave(self): def test_registerComputerPartition_withSlave(self):
self._makeComplexComputeNode(person=self.person, with_slave=True) self._makeComplexComputeNode(person=self.person, with_slave=True)
...@@ -2727,7 +2710,7 @@ class TestSlapOSSlapToolPersonAccess(TestSlapOSSlapToolMixin): ...@@ -2727,7 +2710,7 @@ class TestSlapOSSlapToolPersonAccess(TestSlapOSSlapToolMixin):
response.headers.get('cache-control')) response.headers.get('cache-control'))
self.assertEqual('REMOTE_USER', self.assertEqual('REMOTE_USER',
response.headers.get('vary')) response.headers.get('vary'))
self.assertTrue('last-modified' in response.headers) self.assertIn('last-modified', response.headers)
self.assertEqual('text/xml; charset=utf-8', self.assertEqual('text/xml; charset=utf-8',
response.headers.get('content-type')) response.headers.get('content-type'))
# check returned XML # check returned XML
...@@ -2844,8 +2827,7 @@ class TestSlapOSSlapToolPersonAccess(TestSlapOSSlapToolMixin): ...@@ -2844,8 +2827,7 @@ class TestSlapOSSlapToolPersonAccess(TestSlapOSSlapToolMixin):
slave_1_instance_guid=self.start_requested_slave_instance.getReference(), slave_1_instance_guid=self.start_requested_slave_instance.getReference(),
slave_1_title=self.start_requested_slave_instance.getTitle(), slave_1_title=self.start_requested_slave_instance.getTitle(),
) )
self.assertEqual(expected_xml, got_xml, self.assertXMLEqual(expected_xml, got_xml)
'\n'.join([q for q in difflib.unified_diff(expected_xml.split('\n'), got_xml.split('\n'))]))
def test_registerComputerPartition(self): def test_registerComputerPartition(self):
self._makeComplexComputeNode(person=self.person) self._makeComplexComputeNode(person=self.person)
...@@ -2858,7 +2840,7 @@ class TestSlapOSSlapToolPersonAccess(TestSlapOSSlapToolMixin): ...@@ -2858,7 +2840,7 @@ class TestSlapOSSlapToolPersonAccess(TestSlapOSSlapToolMixin):
response.headers.get('cache-control')) response.headers.get('cache-control'))
self.assertEqual('REMOTE_USER', self.assertEqual('REMOTE_USER',
response.headers.get('vary')) response.headers.get('vary'))
self.assertTrue('last-modified' in response.headers) self.assertIn('last-modified', response.headers)
self.assertEqual('text/xml; charset=utf-8', self.assertEqual('text/xml; charset=utf-8',
response.headers.get('content-type')) response.headers.get('content-type'))
# check returned XML # check returned XML
...@@ -2956,8 +2938,7 @@ class TestSlapOSSlapToolPersonAccess(TestSlapOSSlapToolMixin): ...@@ -2956,8 +2938,7 @@ class TestSlapOSSlapToolPersonAccess(TestSlapOSSlapToolMixin):
root_instance_title=self.start_requested_software_instance.getSpecialiseValue().getTitle(), root_instance_title=self.start_requested_software_instance.getSpecialiseValue().getTitle(),
software_type=self.start_requested_software_instance.getSourceReference() software_type=self.start_requested_software_instance.getSourceReference()
) )
self.assertEqual(expected_xml, got_xml, self.assertXMLEqual(expected_xml, got_xml)
'\n'.join([q for q in difflib.unified_diff(expected_xml.split('\n'), got_xml.split('\n'))]))
def assertInstanceBangSimulator(self, args, kwargs): def assertInstanceBangSimulator(self, args, kwargs):
stored = eval(open(self.instance_bang_simulator).read()) #pylint: disable=eval-used stored = eval(open(self.instance_bang_simulator).read()) #pylint: disable=eval-used
...@@ -3018,8 +2999,7 @@ class TestSlapOSSlapToolPersonAccess(TestSlapOSSlapToolMixin): ...@@ -3018,8 +2999,7 @@ class TestSlapOSSlapToolPersonAccess(TestSlapOSSlapToolMixin):
person_reference=self.person_reference, person_reference=self.person_reference,
instance_guid=self.start_requested_software_instance.getReference() instance_guid=self.start_requested_software_instance.getReference()
) )
self.assertEqual(expected_xml, got_xml, self.assertXMLEqual(expected_xml, got_xml)
'\n'.join([q for q in difflib.unified_diff(expected_xml.split('\n'), got_xml.split('\n'))]))
self.assertInstanceBangSimulator((), {'comment': error_log, 'bang_tree': True}) self.assertInstanceBangSimulator((), {'comment': error_log, 'bang_tree': True})
finally: finally:
if os.path.exists(self.instance_bang_simulator): if os.path.exists(self.instance_bang_simulator):
...@@ -3201,9 +3181,7 @@ class TestSlapOSSlapToolPersonAccess(TestSlapOSSlapToolMixin): ...@@ -3201,9 +3181,7 @@ class TestSlapOSSlapToolPersonAccess(TestSlapOSSlapToolMixin):
ip=self.start_requested_software_instance.getAggregateValue()\ ip=self.start_requested_software_instance.getAggregateValue()\
.getDefaultNetworkAddressIpAddress(), .getDefaultNetworkAddressIpAddress(),
) )
self.assertEqual(expected_xml, got_xml, self.assertXMLEqual(expected_xml, got_xml)
'\n'.join([q for q in difflib.unified_diff(expected_xml.split('\n'),
got_xml.split('\n'))]))
def assertSupplySimulator(self, args, kwargs): def assertSupplySimulator(self, args, kwargs):
stored = eval(open(self.compute_node_supply_simulator).read()) #pylint: disable=eval-used stored = eval(open(self.compute_node_supply_simulator).read()) #pylint: disable=eval-used
...@@ -3269,8 +3247,7 @@ class TestSlapOSSlapToolPersonAccess(TestSlapOSSlapToolMixin): ...@@ -3269,8 +3247,7 @@ class TestSlapOSSlapToolPersonAccess(TestSlapOSSlapToolMixin):
</marshal> </marshal>
""" % {'compute_node_id': compute_node_reference} """ % {'compute_node_id': compute_node_reference}
self.assertEqual(expected_xml, got_xml, self.assertXMLEqual(expected_xml, got_xml)
'\n'.join([q for q in difflib.unified_diff(expected_xml.split('\n'), got_xml.split('\n'))]))
self.assertRequestComputeNodeSimulator((), {'compute_node_title': compute_node_id}) self.assertRequestComputeNodeSimulator((), {'compute_node_title': compute_node_id})
finally: finally:
if os.path.exists(self.compute_node_request_compute_node_simulator): if os.path.exists(self.compute_node_request_compute_node_simulator):
...@@ -3310,8 +3287,7 @@ class TestSlapOSSlapToolPersonAccess(TestSlapOSSlapToolMixin): ...@@ -3310,8 +3287,7 @@ class TestSlapOSSlapToolPersonAccess(TestSlapOSSlapToolMixin):
</marshal> </marshal>
""" % {'compute_node_key': compute_node_key, 'compute_node_certificate': compute_node_certificate} """ % {'compute_node_key': compute_node_key, 'compute_node_certificate': compute_node_certificate}
self.assertEqual(expected_xml, got_xml, self.assertXMLEqual(expected_xml, got_xml)
'\n'.join([q for q in difflib.unified_diff(expected_xml.split('\n'), got_xml.split('\n'))]))
self.assertGenerateComputeNodeCertificateSimulator((), {}) self.assertGenerateComputeNodeCertificateSimulator((), {})
finally: finally:
if os.path.exists(self.generate_compute_node_certificate_simulator): if os.path.exists(self.generate_compute_node_certificate_simulator):
......
...@@ -88,7 +88,7 @@ class TestSlapOSCoreComputeNodeUpdateFromDict(SlapOSTestCaseMixinWithAbort): ...@@ -88,7 +88,7 @@ class TestSlapOSCoreComputeNodeUpdateFromDict(SlapOSTestCaseMixinWithAbort):
self.assertEqual(address.getIpAddress(), 'e') self.assertEqual(address.getIpAddress(), 'e')
self.assertEqual(address.getNetmask(), 'f') self.assertEqual(address.getNetmask(), 'f')
# Existing document should be edited if possible # Existing document should be edited if possible
self.assertTrue(address.getId() in ('foo', 'bar')) self.assertIn(address.getId(), ('foo', 'bar'))
############################################# #############################################
# Compute Partition network information # Compute Partition network information
......
...@@ -35,6 +35,11 @@ for i in range(amount): ...@@ -35,6 +35,11 @@ for i in range(amount):
xml_parameter = """<?xml version="1.0" encoding="utf-8"?> xml_parameter = """<?xml version="1.0" encoding="utf-8"?>
<instance> <instance>
<parameter id="_">%s</parameter> <parameter id="_">%s</parameter>
</instance>""" % json.dumps(json_parameter, indent=2) </instance>""" % json.dumps(json_parameter,
indent=2,
sort_keys=True,
# BBB PY2 https://github.com/python/cpython/issues/60537#issuecomment-1093598422
separators=(',', ': '),
)
return xml_parameter return xml_parameter
...@@ -966,9 +966,9 @@ return dict(vads_url_already_registered="%s/already_registered" % (payment_trans ...@@ -966,9 +966,9 @@ return dict(vads_url_already_registered="%s/already_registered" % (payment_trans
"TestSubscriptionSkins Notification Message %s %s" % ( "TestSubscriptionSkins Notification Message %s %s" % (
subscription_request.getLanguage(), notification_message), subscription_request.getLanguage(), notification_message),
mail_message.getTitle()) mail_message.getTitle())
self.assertTrue(subscription_request.getDefaultEmailText() in \ self.assertIn(subscription_request.getDefaultEmailText(), \
mail_message.getTextContent()) mail_message.getTextContent())
self.assertTrue(subscription_request.getDestinationSectionTitle() in \ self.assertIn(subscription_request.getDestinationSectionTitle(), \
mail_message.getTextContent()) mail_message.getTextContent())
def checkEmailPaymentNotification(self, subscription_request, def checkEmailPaymentNotification(self, subscription_request,
...@@ -984,9 +984,9 @@ return dict(vads_url_already_registered="%s/already_registered" % (payment_trans ...@@ -984,9 +984,9 @@ return dict(vads_url_already_registered="%s/already_registered" % (payment_trans
mail_message.getTitle()) mail_message.getTitle())
invoice = subscription_request.SubscriptionRequest_verifyPaymentBalanceIsReady() invoice = subscription_request.SubscriptionRequest_verifyPaymentBalanceIsReady()
self.assertEqual(invoice.getSimulationState(), 'stopped') self.assertEqual(invoice.getSimulationState(), 'stopped')
self.assertTrue(invoice.getRelativeUrl() in \ self.assertIn(invoice.getRelativeUrl(), \
mail_message.getTextContent()) mail_message.getTextContent())
self.assertTrue(subscription_request.getDestinationSectionTitle() in \ self.assertIn(subscription_request.getDestinationSectionTitle(), \
mail_message.getTextContent()) mail_message.getTextContent())
def checkEmailInstanceNotification(self, subscription_request, def checkEmailInstanceNotification(self, subscription_request,
...@@ -1002,9 +1002,9 @@ return dict(vads_url_already_registered="%s/already_registered" % (payment_trans ...@@ -1002,9 +1002,9 @@ return dict(vads_url_already_registered="%s/already_registered" % (payment_trans
mail_message.getTitle()) mail_message.getTitle())
instance_tree = subscription_request.getAggregateValue() instance_tree = subscription_request.getAggregateValue()
self.assertEqual(instance_tree.getSlapState(), 'start_requested') self.assertEqual(instance_tree.getSlapState(), 'start_requested')
self.assertTrue(instance_tree.getRelativeUrl() in \ self.assertIn(instance_tree.getRelativeUrl(), \
mail_message.getTextContent()) mail_message.getTextContent())
self.assertTrue(subscription_request.getDestinationSectionTitle() in \ self.assertIn(subscription_request.getDestinationSectionTitle(), \
mail_message.getTextContent()) mail_message.getTextContent())
def checkRelatedInstance(self, subscription_request): def checkRelatedInstance(self, subscription_request):
......
...@@ -122,11 +122,11 @@ class TestSubscriptionCondition_renderKVMClusterParameter(TestSubscriptionSkinsM ...@@ -122,11 +122,11 @@ class TestSubscriptionCondition_renderKVMClusterParameter(TestSubscriptionSkinsM
"KVM0": { "KVM0": {
"cpu-count": 40, "cpu-count": 40,
"cpu-max-count": 41, "cpu-max-count": 41,
"ram-size": 245760, "disable-ansible-promise": true,
"ram-max-size": 245761,
"disk-device-path": "/dev/sdb", "disk-device-path": "/dev/sdb",
"project-guid": "PROJ-XXXX", "project-guid": "PROJ-XXXX",
"disable-ansible-promise": true "ram-max-size": 245761,
"ram-size": 245760
} }
} }
}</parameter> }</parameter>
...@@ -144,13 +144,13 @@ class TestSubscriptionCondition_renderKVMClusterParameter(TestSubscriptionSkinsM ...@@ -144,13 +144,13 @@ class TestSubscriptionCondition_renderKVMClusterParameter(TestSubscriptionSkinsM
<parameter id="_">{ <parameter id="_">{
"kvm-partition-dict": { "kvm-partition-dict": {
"KVM0": { "KVM0": {
"cpu-count": 40,
"cpu-max-count": 41,
"disable-ansible-promise": true, "disable-ansible-promise": true,
"disk-device-path": "/dev/sdb", "disk-device-path": "/dev/sdb",
"cpu-count": 40, "project-guid": "PROJ-XXXX",
"ram-max-size": 245761, "ram-max-size": 245761,
"ram-size": 245760, "ram-size": 245760,
"project-guid": "PROJ-XXXX",
"cpu-max-count": 41,
"sticky-computer": true "sticky-computer": true
} }
} }
...@@ -163,23 +163,23 @@ class TestSubscriptionCondition_renderKVMClusterParameter(TestSubscriptionSkinsM ...@@ -163,23 +163,23 @@ class TestSubscriptionCondition_renderKVMClusterParameter(TestSubscriptionSkinsM
<parameter id="_">{ <parameter id="_">{
"kvm-partition-dict": { "kvm-partition-dict": {
"KVM0": { "KVM0": {
"cpu-count": 40,
"cpu-max-count": 41,
"disable-ansible-promise": true, "disable-ansible-promise": true,
"disk-device-path": "/dev/sdb", "disk-device-path": "/dev/sdb",
"cpu-count": 40, "project-guid": "PROJ-XXXX",
"ram-max-size": 245761, "ram-max-size": 245761,
"ram-size": 245760, "ram-size": 245760,
"project-guid": "PROJ-XXXX",
"cpu-max-count": 41,
"sticky-computer": true "sticky-computer": true
}, },
"KVM1": { "KVM1": {
"disk-device-path": "/dev/sdb",
"cpu-count": 40, "cpu-count": 40,
"ram-max-size": 245761,
"cpu-max-count": 41, "cpu-max-count": 41,
"disable-ansible-promise": true, "disable-ansible-promise": true,
"ram-size": 245760, "disk-device-path": "/dev/sdb",
"project-guid": "PROJ-XXXX" "project-guid": "PROJ-XXXX",
"ram-max-size": 245761,
"ram-size": 245760
} }
} }
}</parameter> }</parameter>
......
...@@ -664,7 +664,7 @@ class RunPromise(GenericPromise): ...@@ -664,7 +664,7 @@ class RunPromise(GenericPromise):
def test_method(result): def test_method(result):
self.assertTrue(isinstance(result, PromiseQueueResult)) self.assertTrue(isinstance(result, PromiseQueueResult))
self.assertTrue(isinstance(result.item, TestResult)) self.assertTrue(isinstance(result.item, TestResult))
self.assertTrue(result.name in [promise_failed, promise_name]) self.assertIn(result.name, [promise_failed, promise_name])
if result.name == promise_failed: if result.name == promise_failed:
self.assertEqual(result.item.hasFailed(), True) self.assertEqual(result.item.hasFailed(), True)
self.assertEqual(result.item.message, "failed") self.assertEqual(result.item.message, "failed")
...@@ -705,7 +705,7 @@ class RunPromise(GenericPromise): ...@@ -705,7 +705,7 @@ class RunPromise(GenericPromise):
def test_method(result): def test_method(result):
self.assertTrue(isinstance(result, PromiseQueueResult)) self.assertTrue(isinstance(result, PromiseQueueResult))
self.assertTrue(isinstance(result.item, TestResult)) self.assertTrue(isinstance(result.item, TestResult))
self.assertTrue(result.name in [first_promise, second_promise, third_promise]) self.assertIn(result.name, [first_promise, second_promise, third_promise])
self.assertEqual(result.item.hasFailed(), False) self.assertEqual(result.item.hasFailed(), False)
self.assertEqual(result.item.message, "success") self.assertEqual(result.item.message, "success")
self.counter += 1 self.counter += 1
...@@ -771,7 +771,7 @@ class RunPromise(GenericPromise): ...@@ -771,7 +771,7 @@ class RunPromise(GenericPromise):
self.counter = 0 self.counter = 0
def test_method_first(result): def test_method_first(result):
self.assertTrue(result.name in [first_promise, second_promise]) self.assertIn(result.name, [first_promise, second_promise])
self.assertEqual(result.item.hasFailed(), False) self.assertEqual(result.item.hasFailed(), False)
self.assertEqual(result.item.message, "success") self.assertEqual(result.item.message, "success")
self.counter += 1 self.counter += 1
...@@ -809,7 +809,7 @@ class RunPromise(GenericPromise): ...@@ -809,7 +809,7 @@ class RunPromise(GenericPromise):
self.counter = 0 self.counter = 0
def test_method(result): def test_method(result):
self.assertTrue(result.name in [first_promise, second_promise]) self.assertIn(result.name, [first_promise, second_promise])
self.assertEqual(result.item.hasFailed(), False) self.assertEqual(result.item.hasFailed(), False)
self.assertEqual(result.item.message, "success") self.assertEqual(result.item.message, "success")
self.counter += 1 self.counter += 1
...@@ -956,7 +956,7 @@ class RunPromise(GenericPromise): ...@@ -956,7 +956,7 @@ class RunPromise(GenericPromise):
self.counter = 0 self.counter = 0
def test_method(result): def test_method(result):
self.assertTrue(result.name in [first_promise, second_promise]) self.assertIn(result.name, [first_promise, second_promise])
self.assertEqual(result.item.hasFailed(), False) self.assertEqual(result.item.hasFailed(), False)
self.assertEqual(result.item.message, "success") self.assertEqual(result.item.message, "success")
self.counter += 1 self.counter += 1
...@@ -1082,7 +1082,7 @@ exit 0 ...@@ -1082,7 +1082,7 @@ exit 0
self.counter = 0 self.counter = 0
self.check_list = [first_promise, second_promise, third_promise] self.check_list = [first_promise, second_promise, third_promise]
def test_method(result): def test_method(result):
self.assertTrue(result.name in self.check_list) self.assertIn(result.name, self.check_list)
self.assertEqual(result.item.hasFailed(), False) self.assertEqual(result.item.hasFailed(), False)
self.assertEqual(result.item.message, "success") self.assertEqual(result.item.message, "success")
self.counter += 1 self.counter += 1
...@@ -1110,7 +1110,7 @@ exit 0 ...@@ -1110,7 +1110,7 @@ exit 0
self.counter = 0 self.counter = 0
self.check_list = [first_promise, second_promise, third_promise] self.check_list = [first_promise, second_promise, third_promise]
def test_method(result): def test_method(result):
self.assertTrue(result.name in self.check_list) self.assertIn(result.name, self.check_list)
self.assertEqual(result.item.hasFailed(), False) self.assertEqual(result.item.hasFailed(), False)
self.assertEqual(result.item.message, "success") self.assertEqual(result.item.message, "success")
self.counter += 1 self.counter += 1
...@@ -1186,7 +1186,7 @@ exit 0 ...@@ -1186,7 +1186,7 @@ exit 0
self.assertTrue(result.execution_time >= 1) self.assertTrue(result.execution_time >= 1)
self.assertEqual(result.title, 'my_promise') self.assertEqual(result.title, 'my_promise')
self.assertEqual(result.name, promise_name) self.assertEqual(result.name, promise_name)
self.assertTrue("Promise timed out after" in result.item.message) self.assertIn("Promise timed out after", result.item.message)
self.assertEqual(result.item.hasFailed(), True) self.assertEqual(result.item.hasFailed(), True)
self.configureLauncher(save_method=test_method, enable_anomaly=True, timeout=1) self.configureLauncher(save_method=test_method, enable_anomaly=True, timeout=1)
...@@ -1218,7 +1218,7 @@ echo "success" ...@@ -1218,7 +1218,7 @@ echo "success"
self.assertEqual(result.title, promise_name) self.assertEqual(result.title, promise_name)
self.assertEqual(result.name, promise_name) self.assertEqual(result.name, promise_name)
self.assertEqual(result.path, promise_path) self.assertEqual(result.path, promise_path)
self.assertTrue("Promise timed out after" in result.item.message) self.assertIn("Promise timed out after", result.item.message)
self.assertEqual(result.item.hasFailed(), True) self.assertEqual(result.item.hasFailed(), True)
self.assertTrue(isinstance(result.item.date, datetime)) self.assertTrue(isinstance(result.item.date, datetime))
......
...@@ -2392,7 +2392,7 @@ class TestSlapgridCPWithMasterPromise(MasterMixin, unittest.TestCase): ...@@ -2392,7 +2392,7 @@ class TestSlapgridCPWithMasterPromise(MasterMixin, unittest.TestCase):
log_file = '%s/.slapgrid/log/instance.log' % instance.partition_path log_file = '%s/.slapgrid/log/instance.log' % instance.partition_path
with open(log_file) as f: with open(log_file) as f:
self.assertTrue('Error Promise 254554802' in f.read()) self.assertIn('Error Promise 254554802', f.read())
self.assertTrue(instance.error) self.assertTrue(instance.error)
self.assertIsNone(instance.state) self.assertIsNone(instance.state)
...@@ -3135,7 +3135,7 @@ exit 0 ...@@ -3135,7 +3135,7 @@ exit 0
self._wait_prerm_script_finished(partition.partition_path) self._wait_prerm_script_finished(partition.partition_path)
with open(os.path.join(partition.partition_path, '.0-prerm_slapos_pre_delete.log')) as f: with open(os.path.join(partition.partition_path, '.0-prerm_slapos_pre_delete.log')) as f:
# the script is well finished... # the script is well finished...
self.assertTrue("finished prerm script." in f.read()) self.assertIn("finished prerm script.", f.read())
self.assertEqual(self.grid.agregateAndSendUsage(), slapgrid.SLAPGRID_SUCCESS) self.assertEqual(self.grid.agregateAndSendUsage(), slapgrid.SLAPGRID_SUCCESS)
# Assert partition directory is empty # Assert partition directory is empty
......
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