本文整理汇总了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)
示例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)
示例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)
示例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)
示例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
示例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'