def setUp(self): super(GettextTest, self).setUp() moxfixture = self.useFixture(moxstubout.MoxStubout()) self.stubs = moxfixture.stubs self.mox = moxfixture.mox # remember so we can reset to it later self._USE_LAZY = gettextutils.USE_LAZY
def setUp(self): super(MultiNotifierTestCase, self).setUp() self.config = self.useFixture(config.Config()).config self.stubs = self.useFixture(moxstubout.MoxStubout()).stubs # Mock log to add one to exception_count when log.exception is called def mock_exception(cls, *args): self.exception_count += 1 self.exception_count = 0 notifier_log = log.getLogger( 'essential.notifier.api') self.stubs.Set(notifier_log, "exception", mock_exception) # Mock no_op notifier to add one to notify_count when called. def mock_notify(cls, *args): self.notify_count += 1 self.notify_count = 0 self.stubs.Set(no_op_notifier, 'notify', mock_notify) # Mock log_notifier to raise RuntimeError when called. def mock_notify2(cls, *args): raise RuntimeError("Bad notifier.") self.stubs.Set(log_notifier, 'notify', mock_notify2) self.addCleanup(notifier_api._reset_drivers)
def setUp(self): self.stubs = self.useFixture(moxstubout.MoxStubout()).stubs self.CONF = self.useFixture(config.Config()).conf self.sample_resources = { 'r1': quota.BaseResource('r1'), 'r2': quota.BaseResource('r2') } dbapi = mock.Mock() dbapi.quota_usage_get_all_by_project_and_user = mock.Mock( return_value={ 'project_id': 'p1', 'user_id': 'u1', 'r1': { 'reserved': 1, 'in_use': 2 }, 'r2': { 'reserved': 2, 'in_use': 3 } }) dbapi.quota_get_all_by_project_and_user = mock.Mock(return_value={ 'project_id': 'p1', 'user_id': 'u1', 'r1': 5, 'r2': 6 }) dbapi.quota_get = mock.Mock(return_value='quota_get') dbapi.quota_reserve = mock.Mock(return_value='quota_reserve') dbapi.quota_class_get = mock.Mock(return_value='quota_class_get') dbapi.quota_class_reserve = mock.Mock( return_value='quota_class_reserve') dbapi.quota_class_get_default = mock.Mock(return_value={ 'r1': 1, 'r2': 2 }) dbapi.quota_class_get_all_by_name = mock.Mock(return_value={'r1': 9}) dbapi.quota_get_all_by_project = mock.Mock( return_value=dict([('r%d' % i, i) for i in range(3)])) dbapi.quota_get_all = mock.Mock(return_value=[{ 'resource': 'r1', 'hard_limit': 3 }, { 'resource': 'r2', 'hard_limit': 4 }]) dbapi.quota_usage_get_all_by_project = mock.Mock( return_value=dict([('r%d' % i, { 'in_use': i, 'reserved': i + 1 }) for i in range(3)])) self.dbapi = dbapi self.driver = quota.DbQuotaDriver(dbapi) self.ctxt = FakeContext() return super(DbQuotaDriverTestCase, self).setUp()
def setUp(self): super(NotifierTestCase, self).setUp() notification_driver = [ 'essential.notifier.no_op_notifier' ] self.stubs = self.useFixture(moxstubout.MoxStubout()).stubs self.config = self.useFixture(config.Config()).config self.CONF = self.useFixture(config.Config()).conf self.config(notification_driver=notification_driver) self.config(default_publisher_id='publisher') self.addCleanup(notifier_api._reset_drivers)
def setUp(self): super(LogLevelTranslationsTest, self).setUp() moxfixture = self.useFixture(moxstubout.MoxStubout()) self.stubs = moxfixture.stubs self.mox = moxfixture.mox # remember so we can reset to it later self._USE_LAZY = gettextutils.USE_LAZY # Stub out the appropriate translation logger if six.PY3: self.mox.StubOutWithMock(gettextutils._t_log_levels[self.level], 'gettext') self.trans_func = gettextutils._t_log_levels[self.level].gettext else: self.mox.StubOutWithMock(gettextutils._t_log_levels[self.level], 'ugettext') self.trans_func = gettextutils._t_log_levels[self.level].ugettext # Look up the translator function for the log level we are testing translator_name = '_L' + self.level[0].upper() self.translator = getattr(gettextutils, translator_name)
def setUp(self): super(ForeverRetryUncaughtExceptionsTest, self).setUp() moxfixture = self.useFixture(moxstubout.MoxStubout()) self.mox = moxfixture.mox self.stubs = moxfixture.stubs
def setUp(self): super(SystemdTestCase, self).setUp() self.mox = self.useFixture(moxstubout.MoxStubout()).mox self.stubs = self.useFixture(moxstubout.MoxStubout()).stubs
def setUp(self): super(BackdoorPortTest, self).setUp() self.mox = self.useFixture(moxstubout.MoxStubout()).mox self.config = self.useFixture(config.Config()).config