Commit 9299d4f2 authored by Pere Cortes's avatar Pere Cortes

improve readability and make sure to remove all patch when needed

parent c680c691
...@@ -400,8 +400,6 @@ branch = foo ...@@ -400,8 +400,6 @@ branch = foo
def test_11_run(self): def test_11_run(self):
def doNothing(self, *args, **kw): def doNothing(self, *args, **kw):
pass pass
def patch_killPrevious():
pass
test_self = self test_self = self
test_result_path_root = os.path.join(test_self._temp_dir,'test/results') test_result_path_root = os.path.join(test_self._temp_dir,'test/results')
os.makedirs(test_result_path_root) os.makedirs(test_result_path_root)
...@@ -417,22 +415,21 @@ branch = foo ...@@ -417,22 +415,21 @@ branch = foo
test_self.assertTrue(os.path.exists(os.path.join( test_self.assertTrue(os.path.exists(os.path.join(
test_node.config["working_directory"],x)),True) test_node.config["working_directory"],x)),True)
if counter == 0: if counter == 0:
config_list.append(test_self.getTestSuiteData()[0]) config_list.append(test_self.getTestSuiteData(reference='foo')[0])
config_list.append(test_self.getTestSuiteData(reference='bar')[0]) config_list.append(test_self.getTestSuiteData(reference='bar')[0])
elif counter == 1: elif counter == 1:
_checkExistingTestSuite(set(['foo'])) _checkExistingTestSuite(set(['foo']))
config_list.append(test_self.getTestSuiteData(reference='bar')[0]) config_list.append(test_self.getTestSuiteData(reference='bar')[0])
config_list.append(test_self.getTestSuiteData()[0]) config_list.append(test_self.getTestSuiteData(reference='foo')[0])
elif counter == 2: elif counter == 2:
_checkExistingTestSuite(set(['foo','bar'])) _checkExistingTestSuite(set(['foo','bar']))
config_list.append(test_self.getTestSuiteData()[0]) config_list.append(test_self.getTestSuiteData(reference='foo')[0])
config_list.append(test_self.getTestSuiteData(reference='qux')[0]) config_list.append(test_self.getTestSuiteData(reference='qux')[0])
elif counter == 3: elif counter == 3:
_checkExistingTestSuite(set(['foo','qux'])) _checkExistingTestSuite(set(['foo','qux']))
test_node.process_manager.under_cancellation = True
config_list.append(test_self.getTestSuiteData(reference='foox')[0]) config_list.append(test_self.getTestSuiteData(reference='foox')[0])
elif counter == 4: elif counter == 4:
test_node.process_manager.under_cancellation = False _checkExistingTestSuite(set(['foox']))
config_list.append(test_self.getTestSuiteData(reference='bax')[0]) config_list.append(test_self.getTestSuiteData(reference='bax')[0])
elif counter == 5: elif counter == 5:
_checkExistingTestSuite(set(['bax'])) _checkExistingTestSuite(set(['bax']))
...@@ -442,6 +439,7 @@ branch = foo ...@@ -442,6 +439,7 @@ branch = foo
def patch_createTestResult(self, revision, test_name_list, node_title, def patch_createTestResult(self, revision, test_name_list, node_title,
allow_restart=False, test_title=None, project_title=None): allow_restart=False, test_title=None, project_title=None):
global counter global counter
# return no test to check if run method will run the next test suite
if counter == 3 and project_title != 'qux': if counter == 3 and project_title != 'qux':
result = None result = None
else: else:
...@@ -452,19 +450,26 @@ branch = foo ...@@ -452,19 +450,26 @@ branch = foo
original_sleep = time.sleep original_sleep = time.sleep
time.sleep = doNothing time.sleep = doNothing
self.generateTestRepositoryList() self.generateTestRepositoryList()
original_startTestSuite = TaskDistributor.startTestSuite
TaskDistributor.startTestSuite = patch_startTestSuite TaskDistributor.startTestSuite = patch_startTestSuite
original_createTestResult = TaskDistributionTool.createTestResult
TaskDistributionTool.createTestResult = patch_createTestResult TaskDistributionTool.createTestResult = patch_createTestResult
test_node = self.getTestNode() test_node = self.getTestNode()
original_prepareSlapOS = test_node._prepareSlapOS
test_node._prepareSlapOS = doNothing test_node._prepareSlapOS = doNothing
original_runTestSuite = test_node.runTestSuite
test_node.runTestSuite = doNothing test_node.runTestSuite = doNothing
SlapOSControler.initializeSlapOSControler = doNothing SlapOSControler.initializeSlapOSControler = doNothing
test_node.process_manager.killPreviousRun = patch_killPrevious
try: try:
test_node.run() test_node.run()
except Exception as e: except Exception as e:
self.assertEqual(type(e),StopIteration) self.assertEqual(type(e),StopIteration)
finally: finally:
time.sleep = original_sleep time.sleep = original_sleep
TaskDistributor.startTestSuite = original_startTestSuite
TaskDistributionTool.createTestResult = original_createTestResult
test_node._prepareSlapOS = original_prepareSlapOS
test_node.runTestSuite = original_runTestSuite
def test_12_spawn(self): def test_12_spawn(self):
def _checkCorrectStatus(expected_status,*args): def _checkCorrectStatus(expected_status,*args):
......
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