Commit 366b0144 authored by Benjamin Blanc's avatar Benjamin Blanc

Improve testERP5testnode, still not working

parent d1d0c449
...@@ -460,6 +460,8 @@ branch = foo ...@@ -460,6 +460,8 @@ branch = foo
def test_11_run(self, my_type_test='UnitTest'): def test_11_run(self, my_type_test='UnitTest'):
def doNothing(self, *args, **kw): def doNothing(self, *args, **kw):
pass pass
def patch_getTestType(self):
return my_type_test
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)
...@@ -514,8 +516,10 @@ branch = foo ...@@ -514,8 +516,10 @@ branch = foo
# Patch # Patch
original_startTestSuite = TaskDistributor.startTestSuite original_startTestSuite = TaskDistributor.startTestSuite
original_subscribeNode = TaskDistributor.subscribeNode original_subscribeNode = TaskDistributor.subscribeNode
original_getTestType = TaskDistributor.getTestType
TaskDistributor.startTestSuite = patch_startTestSuite TaskDistributor.startTestSuite = patch_startTestSuite
TaskDistributor.subscribeNode = doNothing TaskDistributor.subscribeNode = doNothing
TaskDistributor.getTestType = patch_getTestType
original_createTestResult = TaskDistributionTool.createTestResult original_createTestResult = TaskDistributionTool.createTestResult
TaskDistributionTool.createTestResult = patch_createTestResult TaskDistributionTool.createTestResult = patch_createTestResult
# TestNode # TestNode
...@@ -527,13 +531,14 @@ branch = foo ...@@ -527,13 +531,14 @@ branch = foo
RunnerClass.runTestSuite = doNothing RunnerClass.runTestSuite = doNothing
SlapOSControler.initializeSlapOSControler = doNothing SlapOSControler.initializeSlapOSControler = doNothing
# Inside test_node a runner is created using new UnitTestRunner methods # Inside test_node a runner is created using new UnitTestRunner methods
test_node.run(my_type_test) test_node.run()
self.assertEquals(5, counter) self.assertEquals(5, counter)
time.sleep = original_sleep time.sleep = original_sleep
# Restore old class methods # Restore old class methods
TaskDistributor.startTestSuite = original_startTestSuite TaskDistributor.startTestSuite = original_startTestSuite
TaskDistributionTool.createTestResult = original_createTestResult TaskDistributionTool.createTestResult = original_createTestResult
TaskDistributionTool.subscribeNode = original_subscribeNode TaskDistributionTool.subscribeNode = original_subscribeNode
TaskDistributionTool.getTestType = original_getTestType
RunnerClass._prepareSlapOS = original_prepareSlapOS RunnerClass._prepareSlapOS = original_prepareSlapOS
RunnerClass.runTestSuite = original_runTestSuite RunnerClass.runTestSuite = original_runTestSuite
...@@ -577,6 +582,8 @@ branch = foo ...@@ -577,6 +582,8 @@ branch = foo
def test_15_suite_log_directory(self, my_type_test='UnitTest'): def test_15_suite_log_directory(self, my_type_test='UnitTest'):
def doNothing(self, *args, **kw): def doNothing(self, *args, **kw):
pass pass
def patch_getTestType(self):
return my_type_test
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)
...@@ -624,8 +631,10 @@ branch = foo ...@@ -624,8 +631,10 @@ branch = foo
self.generateTestRepositoryList() self.generateTestRepositoryList()
original_startTestSuite = TaskDistributor.startTestSuite original_startTestSuite = TaskDistributor.startTestSuite
original_subscribeNode = TaskDistributor.subscribeNode original_subscribeNode = TaskDistributor.subscribeNode
original_getTestType = TaskDistributor.getTestType
TaskDistributor.startTestSuite = patch_startTestSuite TaskDistributor.startTestSuite = patch_startTestSuite
TaskDistributor.subscribeNode = doNothing TaskDistributor.subscribeNode = doNothing
TaskDistributor.getTestType = patch_getTestType
original_createTestResult = TaskDistributionTool.createTestResult original_createTestResult = TaskDistributionTool.createTestResult
TaskDistributionTool.createTestResult = patch_createTestResult TaskDistributionTool.createTestResult = patch_createTestResult
test_node = self.getTestNode() test_node = self.getTestNode()
...@@ -635,7 +644,7 @@ branch = foo ...@@ -635,7 +644,7 @@ branch = foo
original_runTestSuite = RunnerClass.runTestSuite original_runTestSuite = RunnerClass.runTestSuite
RunnerClass.runTestSuite = doNothing RunnerClass.runTestSuite = doNothing
SlapOSControler.initializeSlapOSControler = doNothing SlapOSControler.initializeSlapOSControler = doNothing
test_node.run(my_type_test) test_node.run()
self.assertEquals(counter, 3) self.assertEquals(counter, 3)
checkTestSuite(test_node) checkTestSuite(test_node)
time.sleep = original_sleep time.sleep = original_sleep
...@@ -643,6 +652,7 @@ branch = foo ...@@ -643,6 +652,7 @@ branch = foo
TaskDistributor.startTestSuite = original_startTestSuite TaskDistributor.startTestSuite = original_startTestSuite
TaskDistributionTool.createTestResult = original_createTestResult TaskDistributionTool.createTestResult = original_createTestResult
TaskDistributionTool.subscribeNode = original_subscribeNode TaskDistributionTool.subscribeNode = original_subscribeNode
TaskDistributionTool.getTestType = original_getTestType
RunnerClass._prepareSlapOS = original_prepareSlapOS RunnerClass._prepareSlapOS = original_prepareSlapOS
RunnerClass.runTestSuite = original_runTestSuite RunnerClass.runTestSuite = original_runTestSuite
......
...@@ -304,7 +304,7 @@ branch = %(branch)s ...@@ -304,7 +304,7 @@ branch = %(branch)s
self._cleanupLog() self._cleanupLog()
self._cleanupTemporaryFiles() self._cleanupTemporaryFiles()
def run(self, my_type_test=None): def run(self):
## BLOCK OK ## BLOCK OK
log = self.log log = self.log
...@@ -338,7 +338,6 @@ branch = %(branch)s ...@@ -338,7 +338,6 @@ branch = %(branch)s
(test_suite_data,)) (test_suite_data,))
##/BLOCK OK ##/BLOCK OK
if my_type_test == None:
# TODO : implement this method for each distributor # TODO : implement this method for each distributor
# into nexedi/master-erp5.. # into nexedi/master-erp5..
# (just UnitTestDistributor should be sufficient) # (just UnitTestDistributor should be sufficient)
......
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