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


Python Mock.clients方法代码示例

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


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

示例1: test_valid_claims_request_for_client

# 需要导入模块: from unittest.mock import Mock [as 别名]
# 或者: from unittest.mock.Mock import clients [as 别名]
    def test_valid_claims_request_for_client(self):
        client_id = 'client1'
        provider = Mock()
        provider.clients = {client_id: {'allowed_claims': ['domain']}}

        auth_req = AuthorizationRequest(claims=ClaimsRequest(id_token=Claims(domain=None)), client_id=client_id)
        # should not raise an exception
        claims_request_is_valid_for_client(provider, auth_req)
开发者ID:jkakavas,项目名称:svs,代码行数:10,代码来源:test_inacademia_frontend.py

示例2: test_default_transient_not_allowed

# 需要导入模块: from unittest.mock import Mock [as 别名]
# 或者: from unittest.mock.Mock import clients [as 别名]
    def test_default_transient_not_allowed(self):
        client_id = 'client1'
        provider = Mock()
        provider.clients = {client_id: {'allowed_scope_values': ['student']}}

        auth_req = AuthorizationRequest(scope='openid student', client_id=client_id)
        with pytest.raises(InvalidAuthenticationRequest):
            scope_is_valid_for_client(provider, auth_req)
开发者ID:jkakavas,项目名称:svs,代码行数:10,代码来源:test_inacademia_frontend.py

示例3: test_valid_scope

# 需要导入模块: from unittest.mock import Mock [as 别名]
# 或者: from unittest.mock.Mock import clients [as 别名]
    def test_valid_scope(self, scope, allowed_scope_values):
        client_id = 'client1'
        provider = Mock()
        provider.clients = {client_id: {'allowed_scope_values': allowed_scope_values}}
        auth_req = AuthorizationRequest(scope=scope, client_id=client_id)

        # should not raise an exception
        scope_is_valid_for_client(provider, auth_req)
开发者ID:jkakavas,项目名称:svs,代码行数:10,代码来源:test_inacademia_frontend.py

示例4: test_claims_request_not_allowed_for_client

# 需要导入模块: from unittest.mock import Mock [as 别名]
# 或者: from unittest.mock.Mock import clients [as 别名]
    def test_claims_request_not_allowed_for_client(self):
        client_id = 'client1'
        provider = Mock()
        provider.clients = {client_id: {'allowed_claims': []}}

        auth_req = AuthorizationRequest(claims=ClaimsRequest(id_token=Claims(domain=None)), client_id=client_id)
        with pytest.raises(InvalidAuthenticationRequest):
            claims_request_is_valid_for_client(provider, auth_req)
开发者ID:jkakavas,项目名称:svs,代码行数:10,代码来源:test_inacademia_frontend.py

示例5: test_controller_no_mac

# 需要导入模块: from unittest.mock import Mock [as 别名]
# 或者: from unittest.mock.Mock import clients [as 别名]
async def test_controller_no_mac():
    """Test that it works to not find the controllers mac."""
    hass = Mock()
    entry = Mock()
    entry.data = ENTRY_CONFIG
    client = Mock()
    client.ip = '5.6.7.8'
    api = Mock()
    api.initialize.return_value = mock_coro(True)
    api.clients = {'client1': client}

    unifi_controller = controller.UniFiController(hass, entry)

    with patch.object(controller, 'get_controller',
                      return_value=mock_coro(api)):
        assert await unifi_controller.async_setup() is True

    assert unifi_controller.mac is None
开发者ID:ManHammer,项目名称:home-assistant,代码行数:20,代码来源:test_controller.py

示例6: test_controller_mac

# 需要导入模块: from unittest.mock import Mock [as 别名]
# 或者: from unittest.mock.Mock import clients [as 别名]
async def test_controller_mac():
    """Test that it is possible to identify controller mac."""
    hass = Mock()
    entry = Mock()
    entry.data = ENTRY_CONFIG
    client = Mock()
    client.ip = '1.2.3.4'
    client.mac = '00:11:22:33:44:55'
    api = Mock()
    api.initialize.return_value = mock_coro(True)
    api.clients = {'client1': client}

    unifi_controller = controller.UniFiController(hass, entry)

    with patch.object(controller, 'get_controller',
                      return_value=mock_coro(api)):
        assert await unifi_controller.async_setup() is True

    assert unifi_controller.mac == '00:11:22:33:44:55'
开发者ID:ManHammer,项目名称:home-assistant,代码行数:21,代码来源:test_controller.py


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