当前位置: 首页>>代码示例>>Python>>正文


Python test.BaseTestCase方法代码示例

本文整理汇总了Python中tempest.test.BaseTestCase方法的典型用法代码示例。如果您正苦于以下问题:Python test.BaseTestCase方法的具体用法?Python test.BaseTestCase怎么用?Python test.BaseTestCase使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在tempest.test的用法示例。


在下文中一共展示了test.BaseTestCase方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: setUp

# 需要导入模块: from tempest import test [as 别名]
# 或者: from tempest.test import BaseTestCase [as 别名]
def setUp(self):
        super(RBACRuleValidationTest, self).setUp()
        self.mock_test_args = mock.Mock(spec=test.BaseTestCase)
        self.mock_test_args.os_primary = mock.Mock(spec=manager.Manager)
        self.mock_test_args.rbac_utils = mock.Mock(
            spec_set=rbac_utils.RbacUtils)

        # Setup credentials for mock client manager.
        mock_creds = mock.Mock(user_id=mock.sentinel.user_id,
                               project_id=mock.sentinel.project_id)
        setattr(self.mock_test_args.os_primary, 'credentials', mock_creds)

        self.useFixture(
            fixtures.ConfPatcher(rbac_test_role='Member', group='patrole'))
        # Disable patrole log for unit tests.
        self.useFixture(
            fixtures.ConfPatcher(enable_reporting=False, group='patrole_log')) 
开发者ID:openstack,项目名称:patrole,代码行数:19,代码来源:test_rbac_rule_validation.py

示例2: setUp

# 需要导入模块: from tempest import test [as 别名]
# 或者: from tempest.test import BaseTestCase [as 别名]
def setUp(self):
        super(RbacUtilsFixture, self).setUp()

        self.useFixture(ConfPatcher(rbac_test_role='member', group='patrole'))
        self.useFixture(ConfPatcher(
            admin_role='admin', auth_version='v3', group='identity'))

        test_obj_kwargs = {
            'os_primary.credentials.user_id': self.USER_ID,
            'os_primary.credentials.tenant_id': self.PROJECT_ID,
            'os_primary.credentials.project_id': self.PROJECT_ID,
            'get_identity_version.return_value': 'v3'
        }
        self.mock_test_obj = mock.Mock(
            __name__='patrole_unit_test', spec=test.BaseTestCase,
            os_primary=mock.Mock(), **test_obj_kwargs)

        # Mock out functionality that can't be used by unit tests. Mocking out
        # time.sleep is a test optimization.
        self.mock_time = mock.patch.object(
            rbac_utils, 'time', __name__='mock_time', spec=time).start()
        mock.patch.object(credentials, 'get_configured_admin_credentials',
                          spec=object).start()
        mock_admin_mgr = mock.patch.object(
            clients, 'Manager', spec=clients.Manager,
            roles_v3_client=mock.Mock(), roles_client=mock.Mock()).start()
        self.roles_v3_client = mock_admin_mgr.return_value.roles_v3_client

        self.set_roles(['admin', 'member'], []) 
开发者ID:openstack,项目名称:patrole,代码行数:31,代码来源:fixtures.py

示例3: _format_extra_target_data

# 需要导入模块: from tempest import test [as 别名]
# 或者: from tempest.test import BaseTestCase [as 别名]
def _format_extra_target_data(test_obj, extra_target_data):
    """Formats the "extra_target_data" dictionary with correct test data.

    Before being formatted, "extra_target_data" is a dictionary that maps a
    policy string like "trust.trustor_user_id" to a nested list of
    ``tempest.test.BaseTestCase`` attributes. For example, the attribute list
    in:

        "trust.trustor_user_id": "os.auth_provider.credentials.user_id"

    is parsed by iteratively calling ``getattr`` until the value of "user_id"
    is resolved. The resulting dictionary returns:

        "trust.trustor_user_id": "the user_id of the `os_primary` credential"

    :param test_obj: An instance or subclass of ``tempest.test.BaseTestCase``.
    :param extra_target_data: Dictionary, keyed with ``oslo.policy`` generic
        check names, whose values are string literals that reference nested
        ``tempest.test.BaseTestCase`` attributes. Used by ``oslo.policy`` for
        performing matching against attributes that are sent along with the API
        calls.
    :returns: Dictionary containing additional object data needed by
        ``oslo.policy`` to validate generic checks.
    """
    attr_value = test_obj
    formatted_target_data = {}

    for user_attribute, attr_string in extra_target_data.items():
        attrs = attr_string.split('.')
        for attr in attrs:
            attr_value = getattr(attr_value, attr)
        formatted_target_data[user_attribute] = attr_value

    return formatted_target_data 
开发者ID:openstack,项目名称:patrole,代码行数:36,代码来源:rbac_rule_validation.py


注:本文中的tempest.test.BaseTestCase方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。