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


Python MagicMock.cognito_email_based方法代码示例

本文整理汇总了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'
开发者ID:JiShangShiDai,项目名称:home-assistant,代码行数:14,代码来源:test_auth_api.py

示例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')
开发者ID:JiShangShiDai,项目名称:home-assistant,代码行数:9,代码来源:test_auth_api.py

示例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]')
开发者ID:JiShangShiDai,项目名称:home-assistant,代码行数:9,代码来源:test_auth_api.py

示例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]')
开发者ID:JiShangShiDai,项目名称:home-assistant,代码行数:9,代码来源:test_auth_api.py

示例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')
开发者ID:JiShangShiDai,项目名称:home-assistant,代码行数:10,代码来源:test_auth_api.py

示例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'
开发者ID:JiShangShiDai,项目名称:home-assistant,代码行数:12,代码来源:test_auth_api.py

示例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'
开发者ID:JiShangShiDai,项目名称:home-assistant,代码行数:13,代码来源:test_auth_api.py

示例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
开发者ID:JiShangShiDai,项目名称:home-assistant,代码行数:8,代码来源:test_auth_api.py


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