當前位置: 首頁>>代碼示例>>Python>>正文


Python ProfileController.edit_profile方法代碼示例

本文整理匯總了Python中h.accounts.views.ProfileController.edit_profile方法的典型用法代碼示例。如果您正苦於以下問題:Python ProfileController.edit_profile方法的具體用法?Python ProfileController.edit_profile怎麽用?Python ProfileController.edit_profile使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在h.accounts.views.ProfileController的用法示例。


在下文中一共展示了ProfileController.edit_profile方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_subscription_update

# 需要導入模塊: from h.accounts.views import ProfileController [as 別名]
# 或者: from h.accounts.views.ProfileController import edit_profile [as 別名]
    def test_subscription_update(self, config, dummy_db_session):
        """Make sure that the new status is written into the DB."""
        request = _get_fake_request('acct:[email protected]', 'smith', True, True)
        configure(config)

        with patch('h.accounts.views.Subscriptions') as mock_subs:
            mock_subs.get_by_id = MagicMock()
            mock_subs.get_by_id.return_value = Mock(active=True)
            profile = ProfileController(request)
            profile.edit_profile()
            assert dummy_db_session.added
開發者ID:klrkdekira,項目名稱:h,代碼行數:13,代碼來源:views_test.py

示例2: test_profile_invalid_password

# 需要導入模塊: from h.accounts.views import ProfileController [as 別名]
# 或者: from h.accounts.views.ProfileController import edit_profile [as 別名]
def test_profile_invalid_password():
    """ Make sure our edit_profile call validates the user password
    """
    request = _get_fake_request('john', 'doe')

    with testConfig() as config:
        configure(config)
        with patch('horus.models.UserMixin') as mock_user:
            with patch('horus.lib.FlashMessage') as mock_flash:
                mock_user.get_user = MagicMock(side_effect=_bad_password)
                profile = ProfileController(request)
                profile.User = mock_user
                profile.edit_profile()
                assert mock_flash.called_with(request, _('Invalid password.'), kind='error')
開發者ID:Treora,項目名稱:h,代碼行數:16,代碼來源:views_test.py

示例3: test_profile_calls_super

# 需要導入模塊: from h.accounts.views import ProfileController [as 別名]
# 或者: from h.accounts.views.ProfileController import edit_profile [as 別名]
def test_profile_calls_super():
    """Make sure our method calls the superclasses edit_profile
       if the validations are successful
    """
    request = _get_fake_request('john', 'smith')
    with testConfig() as config:
        configure(config)
        with patch('horus.models.UserMixin') as mock_user:
            with patch('horus.views.ProfileController.edit_profile') as mock_super_profile:
                mock_user.get_user = MagicMock(side_effect=_good_password_simple)
                profile = ProfileController(request)
                profile.User = mock_user
                profile.edit_profile()
                assert profile.request.context is True
                assert mock_super_profile.called
開發者ID:Treora,項目名稱:h,代碼行數:17,代碼來源:views_test.py

示例4: test_subscription_update

# 需要導入模塊: from h.accounts.views import ProfileController [as 別名]
# 或者: from h.accounts.views.ProfileController import edit_profile [as 別名]
def test_subscription_update():
    """Make sure that the new status is written into the DB
    """
    request = _get_fake_request('acct:[email protected]', 'smith', True, True)
    print "request", request.POST
    with testConfig() as config:
        configure(config)
        with patch('h.accounts.views.Subscriptions') as mock_subs:
            mock_subs.get_by_id = MagicMock()
            mock_subs.get_by_id.return_value = Mock(active=True)
            profile = ProfileController(request)
            profile.db = Mock()
            profile.db.add = MagicMock(name='add')
            profile.edit_profile()
            assert profile.db.add.called
開發者ID:Treora,項目名稱:h,代碼行數:17,代碼來源:views_test.py

示例5: test_edit_profile_with_validation_failure

# 需要導入模塊: from h.accounts.views import ProfileController [as 別名]
# 或者: from h.accounts.views.ProfileController import edit_profile [as 別名]
def test_edit_profile_with_validation_failure(authn_policy, form_validator):
    """If form validation fails, return the error object."""
    authn_policy.authenticated_userid.return_value = "johndoe"
    form_validator.return_value = ({"errors": "BOOM!"}, None)

    request = DummyRequest(method='POST')
    profile = ProfileController(request)
    result = profile.edit_profile()

    assert result == {"errors": "BOOM!"}
開發者ID:apurvajalit,項目名稱:h,代碼行數:12,代碼來源:views_test.py

示例6: test_edit_profile_successfully

# 需要導入模塊: from h.accounts.views import ProfileController [as 別名]
# 或者: from h.accounts.views.ProfileController import edit_profile [as 別名]
def test_edit_profile_successfully(authn_policy, form_validator, user_model):
    """edit_profile() returns a dict with key "form" when successful."""
    authn_policy.authenticated_userid.return_value = "johndoe"
    form_validator.return_value = (None, {"username": "johndoe", "pwd": "password", "subscriptions": ""})
    user_model.validate_user.return_value = True
    user_model.get_by_id.return_value = FakeUser(email="[email protected]")

    request = DummyRequest(method="POST")
    profile = ProfileController(request)
    result = profile.edit_profile()

    assert result == {"model": {"email": "[email protected]"}}
開發者ID:stuk88,項目名稱:h,代碼行數:14,代碼來源:views_test.py

示例7: test_profile_invalid_password

# 需要導入模塊: from h.accounts.views import ProfileController [as 別名]
# 或者: from h.accounts.views.ProfileController import edit_profile [as 別名]
    def test_profile_invalid_password(self, config, user_model):
        """Make sure our edit_profile call validates the user password."""
        request = _get_fake_request('john', 'doe')
        configure(config)

        # With an invalid password, get_user returns None
        user_model.get_user.return_value = None

        profile = ProfileController(request)
        result = profile.edit_profile()

        assert result['code'] == 401
        assert any('pwd' in err for err in result['errors'])
開發者ID:klrkdekira,項目名稱:h,代碼行數:15,代碼來源:views_test.py

示例8: test_edit_profile_invalid_password

# 需要導入模塊: from h.accounts.views import ProfileController [as 別名]
# 或者: from h.accounts.views.ProfileController import edit_profile [as 別名]
def test_edit_profile_invalid_password(authn_policy, form_validator, user_model):
    """Make sure our edit_profile call validates the user password."""
    authn_policy.authenticated_userid.return_value = "johndoe"
    form_validator.return_value = (None, {"username": "john", "pwd": "blah", "subscriptions": ""})

    # Mock an invalid password
    user_model.validate_user.return_value = False

    request = DummyRequest(method="POST")
    profile = ProfileController(request)
    result = profile.edit_profile()

    assert result["code"] == 401
    assert any("pwd" in err for err in result["errors"])
開發者ID:stuk88,項目名稱:h,代碼行數:16,代碼來源:views_test.py

示例9: test_edit_profile_successfully

# 需要導入模塊: from h.accounts.views import ProfileController [as 別名]
# 或者: from h.accounts.views.ProfileController import edit_profile [as 別名]
    def test_edit_profile_successfully(self, config, user_model):
        """edit_profile() returns a dict with key "form" when successful."""
        configure(config)
        profile = ProfileController(DummyRequest())

        with patch(
                "h.accounts.views._validate_edit_profile_request") as validate:
            validate.return_value = {
                "username": "johndoe",
                "pwd": "password",
                "subscriptions": []
            }
            result = profile.edit_profile()

        assert "form" in result
        assert "errors" not in result
開發者ID:klrkdekira,項目名稱:h,代碼行數:18,代碼來源:views_test.py

示例10: test_subscription_update

# 需要導入模塊: from h.accounts.views import ProfileController [as 別名]
# 或者: from h.accounts.views.ProfileController import edit_profile [as 別名]
def test_subscription_update(authn_policy, form_validator, subscriptions_model, user_model):
    """Make sure that the new status is written into the DB."""
    authn_policy.authenticated_userid.return_value = "acct:[email protected]"
    form_validator.return_value = (
        None,
        {"username": "acct:[email protected]", "pwd": "smith", "subscriptions": '{"active":true,"uri":"acct:[email protected]","id":1}'},
    )
    mock_sub = Mock(active=False, uri="acct:[email protected]")
    subscriptions_model.get_by_id.return_value = mock_sub
    user_model.get_by_id.return_value = FakeUser(email="[email protected]")

    request = DummyRequest(method="POST")
    profile = ProfileController(request)
    result = profile.edit_profile()

    assert mock_sub.active is True
    assert result == {"model": {"email": "[email protected]"}}
開發者ID:stuk88,項目名稱:h,代碼行數:19,代碼來源:views_test.py

示例11: test_edit_profile_with_validation_failure

# 需要導入模塊: from h.accounts.views import ProfileController [as 別名]
# 或者: from h.accounts.views.ProfileController import edit_profile [as 別名]
    def test_edit_profile_with_validation_failure(self, config, user_model):
        """If validation raises edit_profile() should return an error.

        If _validate_edit_profile_request() raises an exception then
        edit_profile() should return a dict with an "errors" list containing a
        list of the error(s) from the exception's .errors property.

        """
        configure(config)
        profile = ProfileController(DummyRequest())
        errors = [
            ("email", ["That email is invalid", "That email is taken"]),
            ("emailAgain", "The emails must match."),
            ("password", ["That password is wrong"])
        ]

        with patch(
                "h.accounts.views._validate_edit_profile_request") as validate:
            validate.side_effect = (
                views._InvalidEditProfileRequestError(errors=errors))
            result = profile.edit_profile()

        assert result["errors"] == errors
開發者ID:klrkdekira,項目名稱:h,代碼行數:25,代碼來源:views_test.py


注:本文中的h.accounts.views.ProfileController.edit_profile方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。