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


Python DummyRequest.matchdict['number']方法代码示例

本文整理汇总了Python中pyramid.testing.DummyRequest.matchdict['number']方法的典型用法代码示例。如果您正苦于以下问题:Python DummyRequest.matchdict['number']方法的具体用法?Python DummyRequest.matchdict['number']怎么用?Python DummyRequest.matchdict['number']使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pyramid.testing.DummyRequest的用法示例。


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

示例1: test_vote__returned_options

# 需要导入模块: from pyramid.testing import DummyRequest [as 别名]
# 或者: from pyramid.testing.DummyRequest import matchdict['number'] [as 别名]
    def test_vote__returned_options(self):
        from nuorisovaalit.models import Voter
        from nuorisovaalit.views.voting import vote
        from pyramid.session import UnencryptedCookieSessionFactoryConfig
        from pyramid.url import route_url

        session = DBSession()
        populate_testing_db()
        voter = session.query(Voter).first()

        self.config.add_route('select', '/valitse')
        self.config.testing_securitypolicy(userid=voter.openid)
        self.config.set_session_factory(UnencryptedCookieSessionFactoryConfig)

        request = DummyRequest()
        csrf_token = request.session.new_csrf_token()
        request.matchdict['number'] = '1'

        options = vote(request)

        self.assertEquals({
            'action_url': request.path_url,
            'select_url': route_url('select', request),
            'candidate': {
                'number': 1,
                'name': u'Turhapuro, Uuno',
            },
            'profile': {
                'fullname': u'Matti Meikäläinen',
                'district': u'Ahvenanmaan maakunnan vaalipiiri',
            },
            'error': False,
            'csrf_token': csrf_token
        }, options)
开发者ID:verkkodemokratiaseura,项目名称:verkkovaali,代码行数:36,代码来源:test_voting.py

示例2: test_vote__invalid_candidate_number

# 需要导入模块: from pyramid.testing import DummyRequest [as 别名]
# 或者: from pyramid.testing.DummyRequest import matchdict['number'] [as 别名]
    def test_vote__invalid_candidate_number(self):
        from nuorisovaalit.models import Voter
        from nuorisovaalit.views.voting import vote
        from pyramid.exceptions import NotFound

        session = DBSession()
        populate_testing_db()
        voter = session.query(Voter).first()
        self.config.testing_securitypolicy(userid=voter.openid)

        request = DummyRequest()
        request.matchdict['number'] = 666

        self.assertRaises(NotFound, lambda: vote(request))
开发者ID:verkkodemokratiaseura,项目名称:verkkovaali,代码行数:16,代码来源:test_voting.py

示例3: test_vote__candidate_number_mismatch

# 需要导入模块: from pyramid.testing import DummyRequest [as 别名]
# 或者: from pyramid.testing.DummyRequest import matchdict['number'] [as 别名]
    def test_vote__candidate_number_mismatch(self):
        from nuorisovaalit.models import Voter
        from nuorisovaalit.views.voting import vote
        from pyramid.session import UnencryptedCookieSessionFactoryConfig

        session = DBSession()
        populate_testing_db()
        voter = session.query(Voter).first()

        self.config.add_route('select', '/valitse')
        self.config.testing_securitypolicy(userid=voter.openid)
        self.config.set_session_factory(UnencryptedCookieSessionFactoryConfig)

        request = DummyRequest(post=dict(vote='1'))
        csrf_token = request.session.new_csrf_token()
        request.POST['csrf_token'] = csrf_token
        request.matchdict['number'] = '2'

        options = vote(request)
        self.assertTrue(options['error'])
        self.assertEquals(csrf_token, options['csrf_token'])
开发者ID:verkkodemokratiaseura,项目名称:verkkovaali,代码行数:23,代码来源:test_voting.py

示例4: test_vote__successful_voting_response

# 需要导入模块: from pyramid.testing import DummyRequest [as 别名]
# 或者: from pyramid.testing.DummyRequest import matchdict['number'] [as 别名]
    def test_vote__successful_voting_response(self):
        from nuorisovaalit.models import Voter
        from nuorisovaalit.views.voting import vote
        from pyramid.session import UnencryptedCookieSessionFactoryConfig
        from pyramid.url import route_url
        from webob.exc import HTTPFound

        session = DBSession()
        populate_testing_db()
        voter = session.query(Voter).first()

        self.config.add_route('select', '/valitse')
        self.config.add_route('vote-finish', '/valmis')
        self.config.testing_securitypolicy(userid=voter.openid)
        self.config.set_session_factory(UnencryptedCookieSessionFactoryConfig)

        request = DummyRequest(post=dict(vote='1'))
        request.POST['csrf_token'] = request.session.new_csrf_token()
        request.matchdict['number'] = '1'

        response = vote(request)
        self.assertTrue(isinstance(response, HTTPFound))
        self.assertEquals(route_url('vote-finish', request), response.location)
开发者ID:verkkodemokratiaseura,项目名称:verkkovaali,代码行数:25,代码来源:test_voting.py

示例5: test_vote__successful_vote_log

# 需要导入模块: from pyramid.testing import DummyRequest [as 别名]
# 或者: from pyramid.testing.DummyRequest import matchdict['number'] [as 别名]
    def test_vote__successful_vote_log(self):
        from nuorisovaalit.models import Vote
        from nuorisovaalit.models import Voter
        from nuorisovaalit.models import VotingLog
        from nuorisovaalit.views.voting import vote
        from pyramid.session import UnencryptedCookieSessionFactoryConfig

        session = DBSession()
        populate_testing_db()
        voter = session.query(Voter).first()

        self.config.add_route('select', '/valitse')
        self.config.add_route('vote-finish', '/valmis')
        self.config.testing_securitypolicy(userid=voter.openid)
        self.config.set_session_factory(UnencryptedCookieSessionFactoryConfig)

        session = DBSession()

        request = DummyRequest(post=dict(vote='1'))
        request.POST['csrf_token'] = request.session.new_csrf_token()
        request.matchdict['number'] = '1'

        # Check the initial conditions.
        self.assertEquals(0, session.query(VotingLog).count())
        self.assertEquals(0, session.query(Vote).count())

        vote(request)

        # Check that the vote was recorded.
        self.assertEquals(1, session.query(VotingLog).count())
        self.assertEquals(1, session.query(Vote).count())

        # Check that the vote record info is correct.
        vote_record = session.query(Vote).first()
        self.assertEquals(u'Uuno', vote_record.candidate.firstname)
        self.assertEquals(u'Turhapuro', vote_record.candidate.lastname)
        self.assertEquals(u'xxxx xxxx', vote_record.school.name)
开发者ID:verkkodemokratiaseura,项目名称:verkkovaali,代码行数:39,代码来源:test_voting.py


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