def setUp(self): self.timer = _DateTimeTimer() self.expiration = datetime.timedelta(seconds=2) self.flush_interval = datetime.timedelta(seconds=1) options = caches.QuotaOptions( flush_interval=self.flush_interval, expiration=self.expiration) self.agg = quota_request.Aggregator( self.SERVICE_NAME, options, timer=self.timer)
def test_should_create_client_ok(self, check_opts, quota_opts, report_opts): # the mocks return fake instances else code using them fails check_opts.return_value = caches.CheckOptions() report_opts.return_value = caches.ReportOptions() quota_opts.return_value = caches.QuotaOptions() # ensure the client is constructed using no args instances of the opts expect(client.Loaders.DEFAULT.load(self.SERVICE_NAME)).not_to(be_none) check_opts.assert_called_once_with() quota_opts.assert_called_once_with() report_opts.assert_called_once_with()
def test_should_create_client_from_environment_ok(self, check_opts, quota_opts, report_opts): check_opts.return_value = caches.CheckOptions() report_opts.return_value = caches.ReportOptions() quota_opts.return_value = caches.QuotaOptions() # ensure the client is constructed using options values from the test JSON expect(client.Loaders.ENVIRONMENT.load(self.SERVICE_NAME)).not_to(be_none) check_opts.assert_called_once_with(expiration=datetime.timedelta(0, 1), flush_interval=datetime.timedelta(0, 2), num_entries=10) report_opts.assert_called_once_with(flush_interval=datetime.timedelta(0, 1), num_entries=10)
def setUp(self): self.timer = _DateTimeTimer() self.agg = quota_request.Aggregator( self.SERVICE_NAME, caches.QuotaOptions())
def setUp(self): # -ve num_entries means no cache is present self.agg = quota_request.Aggregator( self.SERVICE_NAME, caches.QuotaOptions(num_entries=-1))