本文整理汇总了Python中unittest.mock.MagicMock.cognito_email_based方法的典型用法代码示例。如果您正苦于以下问题:Python MagicMock.cognito_email_based方法的具体用法?Python MagicMock.cognito_email_based怎么用?Python MagicMock.cognito_email_based使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类unittest.mock.MagicMock
的用法示例。
在下文中一共展示了MagicMock.cognito_email_based方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_register
# 需要导入模块: from unittest.mock import MagicMock [as 别名]
# 或者: from unittest.mock.MagicMock import cognito_email_based [as 别名]
def test_register(mock_cognito):
"""Test registering an account."""
cloud = MagicMock()
cloud.cognito_email_based = False
cloud = MagicMock()
cloud.cognito_email_based = False
auth_api.register(cloud, '[email protected]', 'password')
assert len(mock_cognito.register.mock_calls) == 1
result_user, result_password = mock_cognito.register.mock_calls[0][1]
assert result_user == \
auth_api._generate_username('[email protected]')
assert result_password == 'password'
示例2: test_register_fails
# 需要导入模块: from unittest.mock import MagicMock [as 别名]
# 或者: from unittest.mock.MagicMock import cognito_email_based [as 别名]
def test_register_fails(mock_cognito):
"""Test registering an account."""
cloud = MagicMock()
cloud.cognito_email_based = False
mock_cognito.register.side_effect = aws_error('SomeError')
with pytest.raises(auth_api.CloudError):
auth_api.register(cloud, '[email protected]', 'password')
示例3: test_forgot_password_fails
# 需要导入模块: from unittest.mock import MagicMock [as 别名]
# 或者: from unittest.mock.MagicMock import cognito_email_based [as 别名]
def test_forgot_password_fails(mock_cognito):
"""Test failure when starting forgot password flow."""
cloud = MagicMock()
cloud.cognito_email_based = False
mock_cognito.initiate_forgot_password.side_effect = aws_error('SomeError')
with pytest.raises(auth_api.CloudError):
auth_api.forgot_password(cloud, '[email protected]')
示例4: test_confirm_register_fails
# 需要导入模块: from unittest.mock import MagicMock [as 别名]
# 或者: from unittest.mock.MagicMock import cognito_email_based [as 别名]
def test_confirm_register_fails(mock_cognito):
"""Test an error during confirmation of an account."""
cloud = MagicMock()
cloud.cognito_email_based = False
mock_cognito.confirm_sign_up.side_effect = aws_error('SomeError')
with pytest.raises(auth_api.CloudError):
auth_api.confirm_register(cloud, '123456', '[email protected]')
示例5: test_confirm_forgot_password_fails
# 需要导入模块: from unittest.mock import MagicMock [as 别名]
# 或者: from unittest.mock.MagicMock import cognito_email_based [as 别名]
def test_confirm_forgot_password_fails(mock_cognito):
"""Test failure when confirming forgot password."""
cloud = MagicMock()
cloud.cognito_email_based = False
mock_cognito.confirm_forgot_password.side_effect = aws_error('SomeError')
with pytest.raises(auth_api.CloudError):
auth_api.confirm_forgot_password(
cloud, '123456', '[email protected]', 'new password')
示例6: test_confirm_register
# 需要导入模块: from unittest.mock import MagicMock [as 别名]
# 或者: from unittest.mock.MagicMock import cognito_email_based [as 别名]
def test_confirm_register(mock_cognito):
"""Test confirming a registration of an account."""
cloud = MagicMock()
cloud.cognito_email_based = False
auth_api.confirm_register(cloud, '123456', '[email protected]')
assert len(mock_cognito.confirm_sign_up.mock_calls) == 1
result_code, result_user = mock_cognito.confirm_sign_up.mock_calls[0][1]
assert result_user == \
auth_api._generate_username('[email protected]')
assert result_code == '123456'
示例7: test_confirm_forgot_password
# 需要导入模块: from unittest.mock import MagicMock [as 别名]
# 或者: from unittest.mock.MagicMock import cognito_email_based [as 别名]
def test_confirm_forgot_password(mock_cognito):
"""Test confirming forgot password."""
cloud = MagicMock()
cloud.cognito_email_based = False
auth_api.confirm_forgot_password(
cloud, '123456', '[email protected]', 'new password')
assert len(mock_cognito.confirm_forgot_password.mock_calls) == 1
result_code, result_password = \
mock_cognito.confirm_forgot_password.mock_calls[0][1]
assert result_code == '123456'
assert result_password == 'new password'
示例8: test_forgot_password
# 需要导入模块: from unittest.mock import MagicMock [as 别名]
# 或者: from unittest.mock.MagicMock import cognito_email_based [as 别名]
def test_forgot_password(mock_cognito):
"""Test starting forgot password flow."""
cloud = MagicMock()
cloud.cognito_email_based = False
auth_api.forgot_password(cloud, '[email protected]')
assert len(mock_cognito.initiate_forgot_password.mock_calls) == 1