Commit 0209142c authored by Benjamin Blanc's avatar Benjamin Blanc

Update patching method in order to work with runners. Tests passed.

parent f8337edd
...@@ -498,29 +498,32 @@ branch = foo ...@@ -498,29 +498,32 @@ branch = foo
original_sleep = time.sleep original_sleep = time.sleep
time.sleep = doNothing time.sleep = doNothing
self.generateTestRepositoryList() self.generateTestRepositoryList()
# Patch
original_startTestSuite = TaskDistributor.startTestSuite original_startTestSuite = TaskDistributor.startTestSuite
TaskDistributor.startTestSuite = patch_startTestSuite TaskDistributor.startTestSuite = patch_startTestSuite
original_createTestResult = TaskDistributionTool.createTestResult original_createTestResult = TaskDistributionTool.createTestResult
TaskDistributionTool.createTestResult = patch_createTestResult TaskDistributionTool.createTestResult = patch_createTestResult
test_node = self.getTestNode()
# TestNode
test_node = self.getTestNode()
runner = UnitTestRunner(test_node) # Modify class UnitTestRunner(or more after) method
original_prepareSlapOS = runner._prepareSlapOS original_prepareSlapOS = UnitTestRunner._prepareSlapOS
runner._prepareSlapOS = doNothing original_runTestSuite = UnitTestRunner.runTestSuite
UnitTestRunner._prepareSlapOS = doNothing
UnitTestRunner.runTestSuite = doNothing
original_runTestSuite = runner.runTestSuite
runner.runTestSuite = doNothing
SlapOSControler.initializeSlapOSControler = doNothing SlapOSControler.initializeSlapOSControler = doNothing
runner.testnode.run() # Inside test_node a runner is created using new UnitTestRunner methods
test_node.run()
self.assertEquals(5, counter) self.assertEquals(5, counter)
time.sleep = original_sleep time.sleep = original_sleep
# Restore old class methods
TaskDistributor.startTestSuite = original_startTestSuite TaskDistributor.startTestSuite = original_startTestSuite
TaskDistributionTool.createTestResult = original_createTestResult TaskDistributionTool.createTestResult = original_createTestResult
runner._prepareSlapOS = original_prepareSlapOS UnitTestRunner._prepareSlapOS = original_prepareSlapOS
runner.runTestSuite = original_runTestSuite UnitTestRunner.runTestSuite = original_runTestSuite
def test_12_spawn(self): def test_12_spawn(self):
def _checkCorrectStatus(expected_status,*args): def _checkCorrectStatus(expected_status,*args):
...@@ -611,20 +614,24 @@ branch = foo ...@@ -611,20 +614,24 @@ branch = foo
original_createTestResult = TaskDistributionTool.createTestResult original_createTestResult = TaskDistributionTool.createTestResult
TaskDistributionTool.createTestResult = patch_createTestResult TaskDistributionTool.createTestResult = patch_createTestResult
test_node = self.getTestNode() test_node = self.getTestNode()
runner = UnitTestRunner(test_node) # Change UnitTestRunner class methods
original_prepareSlapOS = runner._prepareSlapOS original_prepareSlapOS = UnitTestRunner._prepareSlapOS
runner._prepareSlapOS = doNothing UnitTestRunner._prepareSlapOS = doNothing
original_runTestSuite = runner.runTestSuite original_runTestSuite = UnitTestRunner.runTestSuite
runner.runTestSuite = doNothing UnitTestRunner.runTestSuite = doNothing
SlapOSControler.initializeSlapOSControler = doNothing SlapOSControler.initializeSlapOSControler = doNothing
runner.testnode.run()
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
# Restore old class methods
TaskDistributor.startTestSuite = original_startTestSuite TaskDistributor.startTestSuite = original_startTestSuite
TaskDistributionTool.createTestResult = original_createTestResult TaskDistributionTool.createTestResult = original_createTestResult
runner._prepareSlapOS = original_prepareSlapOS UnitTestRunner._prepareSlapOS = original_prepareSlapOS
runner.runTestSuite = original_runTestSuite UnitTestRunner.runTestSuite = original_runTestSuite
def test_16_cleanupLogDirectory(self): def test_16_cleanupLogDirectory(self):
# Make sure that we are able to cleanup old log folders # Make sure that we are able to cleanup old log folders
......
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