def setUp(self): super(TestCase, self).setUp() self._paths = [] def _cleanup_paths(): for path in self._paths: if path in sys.path: sys.path.remove(path) self.addCleanup(_cleanup_paths) self._memo = {} self._overrides = [] self._group_overrides = {} # show complete diffs on failure self.maxDiff = None self.addCleanup(CONF.reset) self.exit_patch = self.useFixture(mockpatch.PatchObject(sys, 'exit')) self.exit_patch.mock.side_effect = UnexpectedExit self.config([dirs.etc('keystone.conf.sample'), dirs.tests('test_overrides.conf')]) self.opt(policy_file=dirs.etc('policy.json')) # NOTE(morganfainberg): The only way to reconfigure the # CacheRegion object on each setUp() call is to remove the # .backend property. self.addCleanup(delattr, cache.REGION, 'backend') # ensure the cache region instance is setup cache.configure_cache_region(cache.REGION) self.logger = self.useFixture(fixtures.FakeLogger(level=logging.DEBUG)) warnings.filterwarnings('ignore', category=DeprecationWarning) # Clear the registry of providers so that providers from previous # tests aren't used. self.addCleanup(dependency.reset) self.addCleanup(kvs.INMEMDB.clear) self.addCleanup(timeutils.clear_time_override) # Ensure Notification subscriotions and resource types are empty self.addCleanup(notifications.SUBSCRIBERS.clear) # Reset the auth-plugin registry self.addCleanup(self.clear_auth_plugin_registry)
def _set_expected_languages(self, all_locales, avail_locales=None): # Override localedata.locale_identifiers to return some locales. def returns_some_locales(*args, **kwargs): return all_locales self.useFixture( mockpatch.PatchObject(localedata, 'locale_identifiers', returns_some_locales)) # Override gettext.find to return other than None for some languages. def fake_gettext_find(lang_id, *args, **kwargs): found_ret = '/keystone/%s/LC_MESSAGES/keystone.mo' % lang_id if avail_locales is None: # All locales are available. return found_ret languages = kwargs['languages'] if languages[0] in avail_locales: return found_ret return None self.useFixture( mockpatch.PatchObject(gettext, 'find', fake_gettext_find))
def setUp(self): super(TestCase, self).setUp() self._paths = [] def _cleanup_paths(): for path in self._paths: if path in sys.path: sys.path.remove(path) self.addCleanup(_cleanup_paths) self._memo = {} self._overrides = [] self._group_overrides = {} # show complete diffs on failure self.maxDiff = None self.addCleanup(CONF.reset) self.exit_patch = self.useFixture(mockpatch.PatchObject(sys, 'exit')) self.exit_patch.mock.side_effect = UnexpectedExit self.config_fixture = self.useFixture(config_fixture.Config(CONF)) self.config([ dirs.etc('keystone.conf.sample'), dirs.tests('test_overrides.conf') ]) self.opt(policy_file=dirs.etc('policy.json')) self.logger = self.useFixture(fixtures.FakeLogger(level=logging.DEBUG)) warnings.filterwarnings('ignore', category=DeprecationWarning) self.useFixture(ksfixtures.Cache()) # Clear the registry of providers so that providers from previous # tests aren't used. self.addCleanup(dependency.reset) self.addCleanup(kvs.INMEMDB.clear) self.addCleanup(timeutils.clear_time_override) # Ensure Notification subscriotions and resource types are empty self.addCleanup(notifications.SUBSCRIBERS.clear) self.addCleanup(notifications._reset_notifier) # Reset the auth-plugin registry self.addCleanup(self.clear_auth_plugin_registry)
def setUp(self): super(NotificationsWrapperTestCase, self).setUp() self.exp_resource_id = None self.exp_operation = None self.send_notification_called = False def fake_notify(operation, resource_type, resource_id, public=True): self.assertEqual(self.exp_operation, operation) self.assertEqual(EXP_RESOURCE_TYPE, resource_type) self.assertEqual(self.exp_resource_id, resource_id) self.send_notification_called = True self.useFixture( mockpatch.PatchObject(notifications, '_send_notification', fake_notify))
def setUp(self): super(NotificationsForEntities, self).setUp() self._notifications = [] def fake_notify(operation, resource_type, resource_id, public=True): note = { 'resource_id': resource_id, 'operation': operation, 'resource_type': resource_type, 'send_notification_called': True, 'public': public } self._notifications.append(note) self.useFixture( mockpatch.PatchObject(notifications, '_send_notification', fake_notify))
def setUp(self): super(CadfNotificationsWrapperTestCase, self).setUp() self._notifications = [] def fake_notify(action, initiator, outcome): note = { 'action': action, 'initiator': initiator, # NOTE(stevemar): outcome has 2 stages, pending and success # so we are ignoring it for now. # 'outcome': outcome, 'send_notification_called': True } self._notifications.append(note) self.useFixture( mockpatch.PatchObject(notifications, '_send_audit_notification', fake_notify))