Commit 196e4c0f authored by Łukasz Nowak's avatar Łukasz Nowak

Stabilise test code.

Thanks to mocking up getCreationDate it is possible to check exact scenarios.
parent 586fddf6
...@@ -3,6 +3,7 @@ from Products.SlapOS.tests.testSlapOSMixin import \ ...@@ -3,6 +3,7 @@ from Products.SlapOS.tests.testSlapOSMixin import \
testSlapOSMixin testSlapOSMixin
import transaction import transaction
from Products.ERP5Type.tests.utils import createZODBPythonScript from Products.ERP5Type.tests.utils import createZODBPythonScript
from DateTime import DateTime
class TestSlapOSAccountingInteractionWorkflow(testSlapOSMixin): class TestSlapOSAccountingInteractionWorkflow(testSlapOSMixin):
def beforeTearDown(self): def beforeTearDown(self):
...@@ -138,7 +139,8 @@ class TestSlapOSAccountingInteractionWorkflow(testSlapOSMixin): ...@@ -138,7 +139,8 @@ class TestSlapOSAccountingInteractionWorkflow(testSlapOSMixin):
instance.requestStop(**request_kw) instance.requestStop(**request_kw)
self.assertEqual(instance.getCausalityState(), 'diverged') self.assertEqual(instance.getCausalityState(), 'diverged')
def test_HostingSubscription_fixConsistency(self): def test_HostingSubscription_fixConsistency(self,
date=DateTime('2012/01/15'), day=15):
new_id = self.generateNewId() new_id = self.generateNewId()
item = self.portal.hosting_subscription_module.newContent( item = self.portal.hosting_subscription_module.newContent(
portal_type='Hosting Subscription', portal_type='Hosting Subscription',
...@@ -153,18 +155,23 @@ class TestSlapOSAccountingInteractionWorkflow(testSlapOSMixin): ...@@ -153,18 +155,23 @@ class TestSlapOSAccountingInteractionWorkflow(testSlapOSMixin):
self.assertEqual(item.getPeriodicityMinute(), None) self.assertEqual(item.getPeriodicityMinute(), None)
self.assertEqual(item.getPeriodicityMonthDay(), None) self.assertEqual(item.getPeriodicityMonthDay(), None)
try:
from Products.ERP5Type.Base import Base
Base.original_getCreationDate = Base.getCreationDate
def getCreationDate(*args, **kwargs):
return date
Base.getCreationDate = getCreationDate
item.fixConsistency() item.fixConsistency()
finally:
Base.getCreationDate = Base.original_getCreationDate
delattr(Base, 'original_getCreationDate')
import datetime
self.assertEqual(item.getPeriodicityHourList(), [0]) self.assertEqual(item.getPeriodicityHourList(), [0])
self.assertEqual(item.getPeriodicityMinuteList(), [0]) self.assertEqual(item.getPeriodicityMinuteList(), [0])
day = datetime.datetime.today().day
if day > 28:
day = 28
self.assertEqual(item.getPeriodicityMonthDay(), day) self.assertEqual(item.getPeriodicityMonthDay(), day)
def test_HostingSubscription_fixConsistency_today_after_28(self): def test_HostingSubscription_fixConsistency_today_after_28(self):
raise NotImplementedError('Test missing.') self.test_HostingSubscription_fixConsistency(DateTime('2012/01/30'), 28)
def test_HostingSubscription_manageAfter(self): def test_HostingSubscription_manageAfter(self):
class DummyTestException(Exception): class DummyTestException(Exception):
......
188 189
\ No newline at end of file \ No newline at end of file
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