Commit 7ea34e36 authored by Romain Courteaud's avatar Romain Courteaud

Workaround the asynchronous cache in getFullComputerInformation

parent dcf09c09
...@@ -117,13 +117,42 @@ class TestVifibSlapWebServiceMixin(testVifibMixin): ...@@ -117,13 +117,42 @@ class TestVifibSlapWebServiceMixin(testVifibMixin):
def unfakeSlapAuth(self): def unfakeSlapAuth(self):
unfakeSlapAuth() unfakeSlapAuth()
def fakeGetComputerInformation(self):
from slapos.slap.slap import ConnectionHelper, ServerError
if getattr(ConnectionHelper, '_oldGetFullComputerInformation', None) is None:
ConnectionHelper._oldGetFullComputerInformation = \
ConnectionHelper.getFullComputerInformation
running_test = self
def monkeyPatchedGetFullComputerInformation(self, computer_id):
try:
return self._oldGetFullComputerInformation(computer_id)
except ServerError:
transaction.commit()
running_test.stepCleanTic()
transaction.commit()
return self._oldGetFullComputerInformation(computer_id)
ConnectionHelper.getFullComputerInformation = \
monkeyPatchedGetFullComputerInformation
def unfakeGetComputerInformation(self):
from slapos.slap.slap import ConnectionHelper
if getattr(ConnectionHelper, '_oldGetFullComputerInformation', None) \
is not None:
ConnectionHelper.getFullComputerInformation = \
ConnectionHelper._oldGetFullComputerInformation
delattr(ConnectionHelper, '_oldGetFullComputerInformation',)
def afterSetUp(self): def afterSetUp(self):
self.fakeSlapAuth() self.fakeSlapAuth()
self.fakeGetComputerInformation()
testVifibMixin.afterSetUp(self) testVifibMixin.afterSetUp(self)
self.server_url = self.portal.portal_slap.absolute_url() self.server_url = self.portal.portal_slap.absolute_url()
def beforeTearDown(self): def beforeTearDown(self):
self.unfakeSlapAuth() self.unfakeSlapAuth()
self.unfakeGetComputerInformation()
super(testVifibMixin, self).beforeTearDown() super(testVifibMixin, self).beforeTearDown()
def _loginAsUser(self, username): def _loginAsUser(self, username):
......
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