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


Python utils.get_request函数代码示例

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


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

示例1: test_organization_does_not_exist

 def test_organization_does_not_exist(self, mock_get):
     mock_get.side_effect = Http404
     request = utils.get_request(
         'get', '/org/foo/edit/', user=utils.get_user_mock())
     assert_raises(Http404, views.organization_edit, request, 'foo')
     mock_get.assert_called_once_with(
         Organization, slug__exact='foo', members=request.user)
开发者ID:us-ignite,项目名称:us_ignite,代码行数:7,代码来源:views_tests.py

示例2: test_valid_payload_succeeds

 def test_valid_payload_succeeds(self):
     user = get_user('us-ignite')
     challenge = fixtures.get_challenge(
         user=user, status=Challenge.PUBLISHED)
     app = get_application(owner=user, status=Application.PUBLISHED)
     question = fixtures.get_question(challenge)
     entry = fixtures.get_entry(app)
     EntryAnswer.get_or_create_answer(
         entry, question, 'Uses Gigabit features.')
     question_id = 'question_%s' % question.id
     data = {
         'status': Entry.SUBMITTED,
         question_id: 'Answer for the question!'
     }
     url = '/challenges/%s/enter/%s/' % (challenge.slug, app.slug)
     request = utils.get_request('post', url, data=data, user=user)
     request._messages = utils.TestMessagesBackend(request)
     response = views.challenge_entry(
         request, challenge.slug, app.slug)
     eq_(response.status_code, 302)
     eq_(response['location'], url)
     entry = Entry.objects.get_entry_or_none(challenge, app)
     values = entry.entryanswer_set.values('answer', 'question_id').all()
     expected = [{
         'answer': 'Answer for the question!',
         'question_id': question.id
     }]
     eq_(list(values), expected)
开发者ID:jendc123,项目名称:us_ignite,代码行数:28,代码来源:views_tests.py

示例3: test_request_is_successful

 def test_request_is_successful(self):
     request = utils.get_request(
         'get', '/org/', user=utils.get_user_mock())
     response = views.organization_list(request)
     eq_(response.status_code, 200)
     eq_(response.template_name, 'organizations/object_list.html')
     eq_(sorted(response.context_data.keys()), ['page'])
开发者ID:us-ignite,项目名称:us_ignite,代码行数:7,代码来源:views_tests.py

示例4: test_search_tag_is_successful

 def test_search_tag_is_successful(self, search_mock):
     search_mock.return_value = 'ok'
     request = utils.get_request('get', '/search/orgs/')
     response = views.search_organizations(request)
     eq_(response, 'ok')
     search_mock.assert_called_once_with(
         request, Organization.active, 'search/organization_list.html')
开发者ID:jendc123,项目名称:us_ignite,代码行数:7,代码来源:views_tests.py

示例5: test_entry_request_requires_authentication

 def test_entry_request_requires_authentication(self):
     request = utils.get_request(
         'get', '/challenges/foo/enter/abc/', user=utils.get_anon_mock())
     response = views.challenge_entry(request, 'foo', 'abc')
     eq_(response.status_code, 302)
     eq_(response['Location'],
         utils.get_login_url('/challenges/foo/enter/abc/'))
开发者ID:jendc123,项目名称:us_ignite,代码行数:7,代码来源:views_tests.py

示例6: test_get_request_is_successful

 def test_get_request_is_successful(self):
     request = utils.get_request(
         'get', '/resource/add/', user=utils.get_user_mock())
     response = views.resource_add(request)
     eq_(response.status_code, 200)
     eq_(response.template_name, 'resources/object_add.html')
     eq_(sorted(response.context_data.keys()), ['form'])
开发者ID:jendc123,项目名称:us_ignite,代码行数:7,代码来源:views_tests.py

示例7: test_redirect_does_not_exists

 def test_redirect_does_not_exists(self, mock_get):
     mock_get.side_effect = Http404
     request = utils.get_request('get', '/2014/3/foo/')
     assert_raises(Http404, views.legacy_redirect, request, 2014, 3, u'foo')
     mock_get.assert_called_once_with(
         Post.published, slug='foo', publication_date__year=2014,
         publication_date__month=3)
开发者ID:jendc123,项目名称:us_ignite,代码行数:7,代码来源:views_tests.py

示例8: test_membership_requires_authentication

 def test_membership_requires_authentication(self):
     request = utils.get_request(
         'post', '/hub/community/membership/', user=utils.get_anon_mock())
     response = views.hub_membership(request, 'community')
     eq_(response.status_code, 302)
     eq_(response['Location'],
         utils.get_login_url('/hub/community/membership/'))
开发者ID:jendc123,项目名称:us_ignite,代码行数:7,代码来源:views_tests.py

示例9: test_challenge_does_not_exist

 def test_challenge_does_not_exist(self, mock_get):
     mock_get.side_effect = [Mock(spec=Application), Http404]
     request = utils.get_request(
         'get', '/challenges/foo/enter/abc/', user=utils.get_user_mock())
     assert_raises(Http404, views.challenge_entry, request, 'foo', 'abc')
     mock_get.assert_any_call(
         Challenge, slug__exact='foo', status=Challenge.PUBLISHED)
开发者ID:jendc123,项目名称:us_ignite,代码行数:7,代码来源:views_tests.py

示例10: test_invalid_published_post_returns_404

 def test_invalid_published_post_returns_404(self, mock_get):
     mock_get.side_effect = Http404
     request = utils.get_request('get', '/blog/', user=utils.get_anon_mock())
     assert_raises(Http404, views.post_detail, request, 2013, 12, 'gigabit')
     mock_get.assert_called_once_with(
         Post, slug='gigabit', publication_date__year=2013,
         publication_date__month=12)
开发者ID:jendc123,项目名称:us_ignite,代码行数:7,代码来源:views_tests.py

示例11: test_empty_post_request_fails

 def test_empty_post_request_fails(self, mock_get):
     mock_profile = Mock(spec=Profile)()
     mock_get.return_value = mock_profile
     request = utils.get_request(
         'post', '/contact/foo/', data={}, user=utils.get_user_mock())
     response = views.contact_user(request, 'foo')
     ok_(response.context_data['form'].errors)
开发者ID:jendc123,项目名称:us_ignite,代码行数:7,代码来源:views_tests.py

示例12: test_organization_is_not_visible

 def test_organization_is_not_visible(self, mock_get):
     mock_instance = Mock(spec=Organization)()
     mock_get.return_value = mock_instance
     mock_instance.is_visible_by.return_value = False
     request = utils.get_request("get", "/organization/foo/", user=utils.get_anon_mock())
     assert_raises(Http404, views.organization_detail, request, "foo")
     mock_instance.is_visible_by.assert_called_once_with(request.user)
开发者ID:jendc123,项目名称:us_ignite,代码行数:7,代码来源:views_tests.py

示例13: test_entry_detail_requires_authentication

 def test_entry_detail_requires_authentication(self):
     request = utils.get_request(
         'get', '/challenges/gigabit/app/', user=utils.get_anon_mock())
     response = views.entry_detail(request, 'gigabit', 'app')
     eq_(response.status_code, 302)
     eq_(response['Location'],
         utils.get_login_url('/challenges/gigabit/app/'))
开发者ID:jendc123,项目名称:us_ignite,代码行数:7,代码来源:views_tests.py

示例14: test_empty_submission_fails

 def test_empty_submission_fails(self, *args):
     request = utils.get_request(
         'post', '/hub/apply/', data={}, user=utils.get_user_mock())
     response = views.hub_application(request)
     eq_(response.status_code, 200)
     eq_(sorted(response.context_data.keys()), ['form', 'object_list'])
     eq_(response.template_name, 'hubs/object_application.html')
     ok_(response.context_data['form'].errors)
开发者ID:jendc123,项目名称:us_ignite,代码行数:8,代码来源:views_tests.py

示例15: test_get_request_is_successful

 def test_get_request_is_successful(self, mock_filter):
     request = utils.get_request(
         'get', '/hub/apply/', user=utils.get_user_mock())
     response = views.hub_application(request)
     eq_(response.status_code, 200)
     eq_(sorted(response.context_data.keys()), ['form', 'object_list'])
     eq_(response.template_name, 'hubs/object_application.html')
     mock_filter.assert_called_once()
开发者ID:jendc123,项目名称:us_ignite,代码行数:8,代码来源:views_tests.py


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