import datetime
+import mock
from oslo.config import cfg
from cinder import context
self.calls = []
- timeutils.set_time_override()
-
- def tearDown(self):
- timeutils.clear_time_override()
- super(DbQuotaDriverTestCase, self).tearDown()
+ patcher = mock.patch.object(timeutils, 'utcnow')
+ self.addCleanup(patcher.stop)
+ self.mock_utcnow = patcher.start()
+ self.mock_utcnow.return_value = datetime.datetime.utcnow()
def test_get_defaults(self):
# Use our pre-defined resources
self.stubs.Set(sqa_api, '_quota_usage_create', fake_quota_usage_create)
self.stubs.Set(sqa_api, '_reservation_create', fake_reservation_create)
- timeutils.set_time_override()
+ patcher = mock.patch.object(timeutils, 'utcnow')
+ self.addCleanup(patcher.stop)
+ self.mock_utcnow = patcher.start()
+ self.mock_utcnow.return_value = datetime.datetime.utcnow()
def _make_quota_usage(self, project_id, resource, in_use, reserved,
until_refresh, created_at, updated_at):
import tempfile
import uuid
+import mock
import mox
from oslo.config import cfg
import paramiko
def setUp(self):
super(AuditPeriodTest, self).setUp()
#a fairly random time to test with
- self.test_time = datetime.datetime(second=23,
- minute=12,
- hour=8,
- day=5,
- month=3,
- year=2012)
- timeutils.set_time_override(override_time=self.test_time)
-
- def tearDown(self):
- timeutils.clear_time_override()
- super(AuditPeriodTest, self).tearDown()
+ test_time = datetime.datetime(second=23,
+ minute=12,
+ hour=8,
+ day=5,
+ month=3,
+ year=2012)
+ patcher = mock.patch.object(timeutils, 'utcnow')
+ self.addCleanup(patcher.stop)
+ self.mock_utcnow = patcher.start()
+ self.mock_utcnow.return_value = test_time
def test_hour(self):
begin, end = utils.last_completed_audit_period(unit='hour')