keystone.tests.unit.ksfixtures package

keystone.tests.unit.ksfixtures package

Submodules

keystone.tests.unit.ksfixtures.auth_plugins module

class keystone.tests.unit.ksfixtures.auth_plugins.ConfigAuthPlugins(config_fixture, methods, **method_classes)[source]

Bases: fixtures.fixture.Fixture

A fixture for setting up and tearing down a auth plugins.

setUp()[source]
class keystone.tests.unit.ksfixtures.auth_plugins.LoadAuthPlugins(*method_names)[source]

Bases: fixtures.fixture.Fixture

cleanUp()[source]
setUp()[source]

keystone.tests.unit.ksfixtures.backendloader module

class keystone.tests.unit.ksfixtures.backendloader.BackendLoader(testcase)[source]

Bases: fixtures.fixture.Fixture

Initialize each manager and assigns them to an attribute.

clear_auth_plugin_registry()[source]
setUp()[source]

keystone.tests.unit.ksfixtures.cache module

class keystone.tests.unit.ksfixtures.cache.Cache[source]

Bases: fixtures.fixture.Fixture

A fixture for setting up the cache between test cases.

This will also tear down an existing cache if one is already configured.

setUp()[source]

keystone.tests.unit.ksfixtures.database module

class keystone.tests.unit.ksfixtures.database.Database[source]

Bases: fixtures.fixture.Fixture

A fixture for setting up and tearing down a database.

recreate()[source]
setUp()[source]
keystone.tests.unit.ksfixtures.database.initialize_sql_session(connection_str=’sqlite://’)[source]
keystone.tests.unit.ksfixtures.database.run_once(f)[source]

A decorator to ensure the decorated function is only executed once.

The decorated function is assumed to have a one parameter.

keystone.tests.unit.ksfixtures.hacking module

class keystone.tests.unit.ksfixtures.hacking.HackingCode[source]

Bases: fixtures.fixture.Fixture

A fixture to house the various code examples for the keystone hacking style checks.

asserting_none_equality = {‘expected_errors’: [(5, 8, ‘K003’), (6, 8, ‘K003’), (7, 8, ‘K004’), (8, 8, ‘K004’)], ‘code’: “\n class Test(object):\n\n def test(self):\n self.assertEqual(”, ”)\n self.assertEqual(”, None)\n self.assertEqual(None, ”)\n self.assertNotEqual(”, None)\n self.assertNotEqual(None, ”)\n self.assertNotEqual(”, None) # noqa\n self.assertNotEqual(None, ”) # noqa\n “}
comments_begin_with_space = {‘expected_errors’: [(3, 0, ‘K002’)], ‘code’: “\n # This is a good comment\n\n #This is a bad one\n\n # This is alright and can\n # be continued with extra indentation\n # if that’s what the developer wants.\n “}
dict_constructor = {‘expected_errors’: [(3, 0, ‘K008’), (4, 0, ‘K008’), (5, 0, ‘K008’)], ‘code’: “\n lower_res = {k.lower(): v for k, v in res[1].items()}\n fool = dict(a=’a’, b=’b’)\n lower_res = dict((k.lower(), v) for k, v in res[1].items())\n attrs = dict([(k, _from_json(v))])\n dict([[i,i] for i in range(3)])\n dict(({1:2}))\n “}
mutable_default_args = {‘expected_errors’: [(7, 10, ‘K001’), (10, 15, ‘K001’), (10, 29, ‘K001’), (13, 15, ‘K001’), (16, 15, ‘K001’), (16, 31, ‘K001’), (22, 14, ‘K001’), (22, 31, ‘K001’), (22, 53, ‘K001’), (25, 14, ‘K001’), (25, 36, ‘K001’), (28, 10, ‘K001’), (28, 27, ‘K001’), (29, 21, ‘K001’), (32, 11, ‘K001’)], ‘code’: ‘\n def f():\n pass\n\n def f(a, b='', c=None):\n pass\n\n def f(bad=[]):\n pass\n\n def f(foo, bad=[], more_bad=[x for x in range(3)]):\n pass\n\n def f(foo, bad={}):\n pass\n\n def f(foo, bad={}, another_bad=[], fine=None):\n pass\n\n def f(bad=[]): # noqa\n pass\n\n def funcs(bad=dict(), more_bad=list(), even_more_bad=set()):\n “creating mutables through builtins”\n\n def funcs(bad=something(), more_bad=some_object.something()):\n “defaults from any functions”\n\n def f(bad=set(), more_bad={x for x in range(3)},\n even_more_bad={1, 2, 3}):\n “set and set comprehession”\n\n def f(bad={x: x for x in range(3)}):\n “dict comprehension”\n ‘}
class keystone.tests.unit.ksfixtures.hacking.HackingTranslations[source]

Bases: fixtures.fixture.Fixture

Fixtures for checking translation rules.

  1. Exception messages should be translated
  2. Logging messages should not be translated
  3. If a message is used for both an exception and logging it should be translated
examples = [{‘expected_errors’: [(3, 9, ‘K005’), (6, 20, ‘K005’)], ‘code’: “\n # stdlib logging\n LOG = logging.getLogger()\n LOG.info(_(‘text’))\n class C:\n def __init__(self):\n LOG.warning(oslo_i18n(‘text’, {}))\n “}, {‘expected_errors’: [(7, 12, ‘K005’)], ‘code’: “\n # stdlib logging w/ alias and specifying a logger\n class C:\n def __init__(self):\n self.L = logging.getLogger(__name__)\n def m(self):\n self.L.warning(\n _(‘text’), {}\n )\n “}, {‘expected_errors’: [(3, 8, ‘K005’)], ‘code’: “\n # oslo logging and specifying a logger\n L = log.getLogger(__name__)\n L.error(oslo_i18n(‘text’))\n “}, {‘expected_errors’: [(5, 26, ‘K005’)], ‘code’: “\n # oslo logging w/ alias\n class C:\n def __init__(self):\n self.LOG = oslo_logging.getLogger()\n self.LOG.critical(_(‘text’))\n “}, {‘expected_errors’: [(4, 14, ‘K005’)], ‘code’: “\n LOG = log.getLogger(__name__)\n # translation on a separate line\n msg = _(‘text’)\n LOG.exception(msg)\n “}, {‘expected_errors’: [], ‘code’: “\n # this should not be an error\n L = log.getLogger(__name__)\n msg = _(‘text’)\n L.warning(msg)\n raise Exception(msg)\n “}, {‘expected_errors’: [], ‘code’: “\n L = log.getLogger(__name__)\n def f():\n msg = _(‘text’)\n L2.warning(msg)\n something = True # add an extra statement here\n raise Exception(msg)\n “}, {‘expected_errors’: [(4, 16, ‘K005’)], ‘code’: “\n LOG = log.getLogger(__name__)\n def func():\n msg = _(‘text’)\n LOG.warning(msg)\n raise Exception(‘some other message’)\n “}, {‘expected_errors’: [], ‘code’: “\n LOG = log.getLogger(__name__)\n if True:\n msg = _(‘text’)\n else:\n msg = _(‘text’)\n LOG.warning(msg)\n raise Exception(msg)\n “}, {‘expected_errors’: [(6, 12, ‘K005’)], ‘code’: “\n LOG = log.getLogger(__name__)\n if True:\n msg = _(‘text’)\n else:\n msg = _(‘text’)\n LOG.warning(msg)\n “}, {‘expected_errors’: [], ‘code’: “\n LOG = log.getLogger(__name__)\n msg = _LW(‘text’)\n LOG.warning(msg)\n msg = _(‘something else’)\n raise Exception(msg)\n “}, {‘expected_errors’: [(3, 12, ‘K005’)], ‘code’: “\n LOG = log.getLogger(__name__)\n msg = _(‘hello %s’) % ‘world’\n LOG.warning(msg)\n “}, {‘expected_errors’: [], ‘code’: ‘\n # this should not be an error\n LOG = log.getLogger(__name__)\n try:\n something = True\n except AssertionError as e:\n LOG.warning(six.text_type(e))\n raise exception.Unauthorized(e)\n ‘}, {‘expected_errors’: [], ‘code’: “\n # this should not be an error\n LOG = log.getLogger(__name__)\n try:\n pass\n except AssertionError as e:\n msg = _(‘some message’)\n LOG.warning(msg)\n raise exception.Unauthorized(message=msg)\n “}]
shared_imports = ‘\n import logging\n import logging as stlib_logging\n from keystone.i18n import _\n from keystone.i18n import _ as oslo_i18n\n from oslo_log import log\n from oslo_log import log as oslo_logging\n ‘

keystone.tests.unit.ksfixtures.key_repository module

class keystone.tests.unit.ksfixtures.key_repository.KeyRepository(config_fixture, key_group, max_active_keys)[source]

Bases: fixtures.fixture.Fixture

setUp()[source]

keystone.tests.unit.ksfixtures.ldapdb module

class keystone.tests.unit.ksfixtures.ldapdb.LDAPDatabase(dbclass=<class ‘keystone.tests.unit.fakeldap.FakeLdap’>)[source]

Bases: fixtures.fixture.Fixture

A fixture for setting up and tearing down an LDAP database.

clear()[source]
disable_write()[source]
setUp()[source]

keystone.tests.unit.ksfixtures.policy module

class keystone.tests.unit.ksfixtures.policy.Policy(policy_file, config_fixture)[source]

Bases: fixtures.fixture.Fixture

A fixture for working with policy configuration.

setUp()[source]

keystone.tests.unit.ksfixtures.temporaryfile module

class keystone.tests.unit.ksfixtures.temporaryfile.SecureTempFile[source]

Bases: fixtures.fixture.Fixture

A fixture for creating a secure temp file.

setUp()[source]

Module contents

Creative Commons Attribution 3.0 License

Except where otherwise noted, this document is licensed under Creative Commons Attribution 3.0 License. See all OpenStack Legal Documents.