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


Python template.clear_test_template_context函数代码示例

本文整理汇总了Python中mediagoblin.tools.template.clear_test_template_context函数的典型用法代码示例。如果您正苦于以下问题:Python clear_test_template_context函数的具体用法?Python clear_test_template_context怎么用?Python clear_test_template_context使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: _test_add_existing

        def _test_add_existing():
            template.clear_test_template_context()
            res = persona_plugin_app.post(
                '/edit/persona/add/')
            res.follow()

            assert urlparse.urlsplit(res.location)[2] == '/edit/persona/'
开发者ID:ausbin,项目名称:mediagoblin,代码行数:7,代码来源:test_persona.py

示例2: _test_delete

        def _test_delete(self, test_user):
            # Delete openid from user
            # Create another user to test deleting OpenID that doesn't belong to them
            new_user = fixture_add_user(username="newman")
            openid = OpenIDUserURL()
            openid.openid_url = "http://realfake.myopenid.com/"
            openid.user_id = new_user.id
            openid.save()

            # Try and delete OpenID url that isn't the users
            template.clear_test_template_context()
            res = openid_plugin_app.post("/edit/openid/delete/", {"openid": "http://realfake.myopenid.com/"})
            context = template.TEMPLATE_TEST_CONTEXT["mediagoblin/plugins/openid/delete.html"]
            form = context["form"]
            assert form.openid.errors == [u"That OpenID is not registered to this account."]

            # Delete OpenID
            # Kind of weird to POST to delete/finish
            template.clear_test_template_context()
            res = openid_plugin_app.post("/edit/openid/delete/finish/", {"openid": u"http://add.myopenid.com"})
            res.follow()

            # Correct place?
            assert urlparse.urlsplit(res.location)[2] == "/edit/account/"
            assert "mediagoblin/edit/edit_account.html" in template.TEMPLATE_TEST_CONTEXT

            # OpenID deleted?
            new_openid = mg_globals.database.OpenIDUserURL.query.filter_by(
                openid_url=u"http://add.myopenid.com"
            ).first()
            assert not new_openid
开发者ID:aurelienmaury,项目名称:JoshuaGoblin,代码行数:31,代码来源:test_openid.py

示例3: _do_request

 def _do_request(self, url, *context_keys, **kwargs):
     template.clear_test_template_context()
     response = self.test_app.request(url, **kwargs)
     context_data = template.TEMPLATE_TEST_CONTEXT
     for key in context_keys:
         context_data = context_data[key]
     return response, context_data
开发者ID:ausbin,项目名称:mediagoblin,代码行数:7,代码来源:__init__.py

示例4: test_change_password

    def test_change_password(self, test_app):
        """Test changing password correctly and incorrectly"""
        self.login(test_app)

        # test that the password can be changed
        template.clear_test_template_context()
        res = test_app.post(
            '/edit/password/', {
                'old_password': 'toast',
                'new_password': '123456',
                })
        res.follow()

        # Did we redirect to the correct page?
        assert urlparse.urlsplit(res.location)[2] == '/edit/account/'

        # test_user has to be fetched again in order to have the current values
        test_user = User.query.filter_by(username=u'chris').first()
        assert auth.check_password('123456', test_user.pw_hash)
        # Update current user passwd
        self.user_password = '123456'

        # test that the password cannot be changed if the given
        # old_password is wrong
        template.clear_test_template_context()
        test_app.post(
            '/edit/password/', {
                'old_password': 'toast',
                'new_password': '098765',
                })

        test_user = User.query.filter_by(username=u'chris').first()
        assert not auth.check_password('098765', test_user.pw_hash)
开发者ID:RichoHan,项目名称:MediaGoblin,代码行数:33,代码来源:test_edit.py

示例5: _test_non_response

        def _test_non_response():
            template.clear_test_template_context()
            res = openid_plugin_app.post("/auth/openid/login/", {"openid": "http://phoney.myopenid.com/"})
            res.follow()

            # Correct Place?
            assert urlparse.urlsplit(res.location)[2] == "/auth/openid/login/"
            assert "mediagoblin/plugins/openid/login.html" in template.TEMPLATE_TEST_CONTEXT
开发者ID:aurelienmaury,项目名称:JoshuaGoblin,代码行数:8,代码来源:test_openid.py

示例6: _test_non_response

        def _test_non_response():
            template.clear_test_template_context()
            res = openid_plugin_app.post(
                '/auth/openid/login/', {
                    'openid': 'http://phoney.myopenid.com/'})
            res.follow()

            # Correct Place?
            assert urlparse.urlsplit(res.location)[2] == '/auth/openid/login/'
            assert 'mediagoblin/plugins/openid/login.html' in template.TEMPLATE_TEST_CONTEXT
开发者ID:commonsmachinery,项目名称:mediagoblin,代码行数:10,代码来源:test_openid.py

示例7: do_post

 def do_post(self, data, *context_keys, **kwargs):
     url = kwargs.pop('url', '/submit/')
     do_follow = kwargs.pop('do_follow', False)
     template.clear_test_template_context()
     response = self.test_app.post(url, data, **kwargs)
     if do_follow:
         response.follow()
     context_data = template.TEMPLATE_TEST_CONTEXT
     for key in context_keys:
         context_data = context_data[key]
     return response, context_data
开发者ID:piratas,项目名称:biblioteca,代码行数:11,代码来源:test_submission.py

示例8: _test_new_user

        def _test_new_user():
            openid_plugin_app.post(
                '/auth/openid/login/', {
                    'openid': u'http://real.myopenid.com'})

            # Right place?
            assert 'mediagoblin/auth/register.html' in template.TEMPLATE_TEST_CONTEXT
            context = template.TEMPLATE_TEST_CONTEXT['mediagoblin/auth/register.html']
            register_form = context['register_form']

            # Register User
            res = openid_plugin_app.post(
                '/auth/openid/register/', {
                    'openid': register_form.openid.data,
                    'username': u'chris',
                    'email': u'[email protected]'})
            res.follow()

            # Correct place?
            assert urlparse.urlsplit(res.location)[2] == '/u/chris/'
            assert 'mediagoblin/user_pages/user_nonactive.html' in template.TEMPLATE_TEST_CONTEXT

            # No need to test if user is in logged in and verification email
            # awaits, since openid uses the register_user function which is
            # tested in test_auth

            # Logout User
            openid_plugin_app.get('/auth/logout')

            # Get user and detach from session
            test_user = mg_globals.database.LocalUser.query.filter(
                LocalUser.username==u'chris'
            ).first()
            Session.expunge(test_user)

            # Log back in
            # Could not get it to work by 'POST'ing to /auth/openid/login/
            template.clear_test_template_context()
            res = openid_plugin_app.post(
                '/auth/openid/login/finish/', {
                    'openid': u'http://real.myopenid.com'})
            res.follow()

            assert urlparse.urlsplit(res.location)[2] == '/'
            assert 'mediagoblin/root.html' in template.TEMPLATE_TEST_CONTEXT

            # Make sure user is in the session
            context = template.TEMPLATE_TEST_CONTEXT['mediagoblin/root.html']
            session = context['request'].session
            assert session['user_id'] == six.text_type(test_user.id)
开发者ID:ausbin,项目名称:mediagoblin,代码行数:50,代码来源:test_openid.py

示例9: _test_authentication

    def _test_authentication():
        template.clear_test_template_context()
        res = ldap_plugin_app.post(
            '/auth/ldap/login/',
            {'username': u'chris',
             'password': u'toast'})

        context = template.TEMPLATE_TEST_CONTEXT['mediagoblin/auth/register.html']
        register_form = context['register_form']

        assert register_form.username.data == u'chris'
        assert register_form.email.data == u'[email protected]'

        template.clear_test_template_context()
        res = ldap_plugin_app.post(
            '/auth/ldap/register/',
            {'username': u'chris',
             'email': u'[email protected]'})
        res.follow()

        assert urlparse.urlsplit(res.location)[2] == '/u/chris/'
        assert 'mediagoblin/user_pages/user.html' in template.TEMPLATE_TEST_CONTEXT

        # Try to register with same email and username
        template.clear_test_template_context()
        res = ldap_plugin_app.post(
            '/auth/ldap/register/',
            {'username': u'chris',
             'email': u'[email protected]'})

        context = template.TEMPLATE_TEST_CONTEXT['mediagoblin/auth/register.html']
        register_form = context['register_form']

        assert register_form.email.errors == [u'Sorry, a user with that email address already exists.']
        assert register_form.username.errors == [u'Sorry, a user with that name already exists.']

        # Log out
        ldap_plugin_app.get('/auth/logout/')

        # Get user and detach from session
        test_user = mg_globals.database.User.query.filter_by(
            username=u'chris').first()
        Session.expunge(test_user)

        # Log back in
        template.clear_test_template_context()
        res = ldap_plugin_app.post(
            '/auth/ldap/login/',
            {'username': u'chris',
             'password': u'toast'})
        res.follow()

        assert urlparse.urlsplit(res.location)[2] == '/'
        assert 'mediagoblin/root.html' in template.TEMPLATE_TEST_CONTEXT

        # Make sure user is in the session
        context = template.TEMPLATE_TEST_CONTEXT['mediagoblin/root.html']
        session = context['request'].session
        assert session['user_id'] == unicode(test_user.id)
开发者ID:commonsmachinery,项目名称:mediagoblin,代码行数:59,代码来源:test_ldap.py

示例10: _test_add

        def _test_add():
            # Successful add
            template.clear_test_template_context()
            res = openid_plugin_app.post("/edit/openid/", {"openid": u"http://add.myopenid.com"})
            res.follow()

            # Correct place?
            assert urlparse.urlsplit(res.location)[2] == "/edit/account/"
            assert "mediagoblin/edit/edit_account.html" in template.TEMPLATE_TEST_CONTEXT

            # OpenID Added?
            new_openid = mg_globals.database.OpenIDUserURL.query.filter_by(
                openid_url=u"http://add.myopenid.com"
            ).first()
            assert new_openid
开发者ID:aurelienmaury,项目名称:JoshuaGoblin,代码行数:15,代码来源:test_openid.py

示例11: clear_test_buckets

def clear_test_buckets():
    """
    We store some things for testing purposes that should be cleared
    when we want a "clean slate" of information for our next round of
    tests.  Call this function to wipe all that stuff clean.

    Also wipes out some other things we might redefine during testing,
    like the jinja envs.
    """
    global SETUP_JINJA_ENVS
    SETUP_JINJA_ENVS = {}

    global EMAIL_TEST_INBOX
    global EMAIL_TEST_MBOX_INBOX
    EMAIL_TEST_INBOX = []
    EMAIL_TEST_MBOX_INBOX = []

    clear_test_template_context()
开发者ID:3rdwiki,项目名称:mediagoblin,代码行数:18,代码来源:testing.py

示例12: _test_edit_persona

        def _test_edit_persona():
            # Try and delete only Persona email address
            template.clear_test_template_context()
            res = persona_plugin_app.post(
                '/edit/persona/',
                {'email': '[email protected]'})

            assert 'mediagoblin/plugins/persona/edit.html' in template.TEMPLATE_TEST_CONTEXT
            context = template.TEMPLATE_TEST_CONTEXT['mediagoblin/plugins/persona/edit.html']
            form = context['form']

            assert form.email.errors == [u"You can't delete your only Persona email address unless you have a password set."]

            template.clear_test_template_context()
            res = persona_plugin_app.post(
                '/edit/persona/', {})

            assert 'mediagoblin/plugins/persona/edit.html' in template.TEMPLATE_TEST_CONTEXT
            context = template.TEMPLATE_TEST_CONTEXT['mediagoblin/plugins/persona/edit.html']
            form = context['form']

            assert form.email.errors == [u'This field is required.']

            # Try and delete Persona not owned by the user
            template.clear_test_template_context()
            res = persona_plugin_app.post(
                '/edit/persona/',
                {'email': '[email protected]'})

            assert 'mediagoblin/plugins/persona/edit.html' in template.TEMPLATE_TEST_CONTEXT
            context = template.TEMPLATE_TEST_CONTEXT['mediagoblin/plugins/persona/edit.html']
            form = context['form']

            assert form.email.errors == [u'That Persona email address is not registered to this account.']

            res = persona_plugin_app.get('/edit/persona/add/')

            assert urlparse.urlsplit(res.location)[2] == '/edit/persona/'

            # Add Persona email address
            template.clear_test_template_context()
            res = persona_plugin_app.post(
                '/edit/persona/add/')
            res.follow()

            assert urlparse.urlsplit(res.location)[2] == '/edit/account/'

            # Delete a Persona
            res = persona_plugin_app.post(
                '/edit/persona/',
                {'email': '[email protected]'})
            res.follow()

            assert urlparse.urlsplit(res.location)[2] == '/edit/account/'
开发者ID:ausbin,项目名称:mediagoblin,代码行数:54,代码来源:test_persona.py

示例13: _test_new_user

        def _test_new_user():
            openid_plugin_app.post("/auth/openid/login/", {"openid": u"http://real.myopenid.com"})

            # Right place?
            assert "mediagoblin/auth/register.html" in template.TEMPLATE_TEST_CONTEXT
            context = template.TEMPLATE_TEST_CONTEXT["mediagoblin/auth/register.html"]
            register_form = context["register_form"]

            # Register User
            res = openid_plugin_app.post(
                "/auth/openid/register/",
                {"openid": register_form.openid.data, "username": u"chris", "email": u"[email protected]"},
            )
            res.follow()

            # Correct place?
            assert urlparse.urlsplit(res.location)[2] == "/u/chris/"
            assert "mediagoblin/user_pages/user.html" in template.TEMPLATE_TEST_CONTEXT

            # No need to test if user is in logged in and verification email
            # awaits, since openid uses the register_user function which is
            # tested in test_auth

            # Logout User
            openid_plugin_app.get("/auth/logout")

            # Get user and detach from session
            test_user = mg_globals.database.User.query.filter_by(username=u"chris").first()
            Session.expunge(test_user)

            # Log back in
            # Could not get it to work by 'POST'ing to /auth/openid/login/
            template.clear_test_template_context()
            res = openid_plugin_app.post("/auth/openid/login/finish/", {"openid": u"http://real.myopenid.com"})
            res.follow()

            assert urlparse.urlsplit(res.location)[2] == "/"
            assert "mediagoblin/root.html" in template.TEMPLATE_TEST_CONTEXT

            # Make sure user is in the session
            context = template.TEMPLATE_TEST_CONTEXT["mediagoblin/root.html"]
            session = context["request"].session
            assert session["user_id"] == unicode(test_user.id)
开发者ID:aurelienmaury,项目名称:JoshuaGoblin,代码行数:43,代码来源:test_openid.py

示例14: test_sniffing

    def test_sniffing(self):
        '''
        Test sniffing mechanism to assert that regular uploads work as intended
        '''
        template.clear_test_template_context()
        response = self.test_app.post(
            '/submit/', {
                'title': u'UNIQUE_TITLE_PLS_DONT_CREATE_OTHER_MEDIA_WITH_THIS_TITLE'
                }, upload_files=[(
                    'file', GOOD_JPG)])

        response.follow()

        context = template.TEMPLATE_TEST_CONTEXT['mediagoblin/user_pages/user.html']

        request = context['request']

        media = request.db.MediaEntry.query.filter_by(
            title=u'UNIQUE_TITLE_PLS_DONT_CREATE_OTHER_MEDIA_WITH_THIS_TITLE').first()

        assert media.media_type == 'mediagoblin.media_types.image'
开发者ID:piratas,项目名称:biblioteca,代码行数:21,代码来源:test_submission.py

示例15: test_authentication_disabled_app

def test_authentication_disabled_app(authentication_disabled_app):
    # app.auth should = false
    assert mg_globals
    assert mg_globals.app.auth is False

    # Try to visit register page
    template.clear_test_template_context()
    response = authentication_disabled_app.get('/auth/register/')
    response.follow()

    # Correct redirect?
    assert urlparse.urlsplit(response.location)[2] == '/'
    assert 'mediagoblin/root.html' in template.TEMPLATE_TEST_CONTEXT

    # Try to vist login page
    template.clear_test_template_context()
    response = authentication_disabled_app.get('/auth/login/')
    response.follow()

    # Correct redirect?
    assert urlparse.urlsplit(response.location)[2] == '/'
    assert 'mediagoblin/root.html' in template.TEMPLATE_TEST_CONTEXT

    ## Test check_login_simple should return None
    assert auth_tools.check_login_simple('test', 'simple') is None

    # Try to visit the forgot password page
    template.clear_test_template_context()
    response = authentication_disabled_app.get('/auth/register/')
    response.follow()

    # Correct redirect?
    assert urlparse.urlsplit(response.location)[2] == '/'
    assert 'mediagoblin/root.html' in template.TEMPLATE_TEST_CONTEXT
开发者ID:goblinrefuge,项目名称:goblinrefuge-mediagoblin,代码行数:34,代码来源:test_auth.py


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