• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python utils.get_user_mock函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: test_different_viewer_returns_public_apps

 def test_different_viewer_returns_public_apps(self, filter_mock):
     owner = utils.get_user_mock()
     viewer = utils.get_user_mock()
     result = views.get_application_list(owner, viewer=viewer)
     filter_mock.assert_called_once_with(
         owner=owner, status=Application.PUBLISHED)
     eq_(list(result), [])
开发者ID:us-ignite,项目名称:us_ignite,代码行数:7,代码来源:views_tests.py


示例2: 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


示例3: 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


示例4: 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


示例5: 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


示例6: test_owner_returns_all_available_objects

 def test_owner_returns_all_available_objects(
         self, owned_mock, membership_mock):
     contact = utils.get_user_mock()
     result = views.get_hub_list(contact, viewer=contact)
     owned_mock.assert_called_once_with(contact, viewer=contact)
     membership_mock.assert_called_once_with(contact, viewer=contact)
     eq_(result, [])
开发者ID:us-ignite,项目名称:us_ignite,代码行数:7,代码来源:views_tests.py


示例7: test_anon_user_returns_public_objects

 def test_anon_user_returns_public_objects(self, filter_mock):
     contact = utils.get_user_mock()
     viewer = utils.get_anon_mock()
     result = views.get_resource_list(contact, viewer=viewer)
     filter_mock.assert_called_once_with(
         contact=contact, status=Resource.PUBLISHED)
     eq_(list(result), [])
开发者ID:us-ignite,项目名称:us_ignite,代码行数:7,代码来源:views_tests.py


示例8: test_non_existing_app_raises_404

 def test_non_existing_app_raises_404(self, get_mock):
     get_mock.side_effect = Http404
     request = self.factory.get('/app/b/membership/')
     request.user = utils.get_user_mock()
     assert_raises(Http404, views.app_membership, request, 'b')
     get_mock.assert_called_once_with(
         Application.active, slug__exact='b')
开发者ID:jendc123,项目名称:us_ignite,代码行数:7,代码来源:views_tests.py


示例9: test_get_request_is_successful

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


示例10: 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


示例11: test_empty_post_request_fails

 def test_empty_post_request_fails(self, save_mock):
     request = self.factory.post('/app/add/', {})
     request.user = utils.get_user_mock()
     response = views.app_add(request)
     eq_(response.status_code, 200)
     ok_(response.context_data['form'].errors)
     eq_(save_mock.call_count, 0)
开发者ID:jendc123,项目名称:us_ignite,代码行数:7,代码来源:views_tests.py


示例12: test_awards_are_returned

 def test_awards_are_returned(self, mock_related):
     mock_related.return_value.filter.return_value = []
     user = utils.get_user_mock()
     result = views.get_award_list(user)
     eq_(result, [])
     mock_related.assert_called_once_with('award')
     mock_related.return_value.filter.assert_called_once_with(user=user)
开发者ID:us-ignite,项目名称:us_ignite,代码行数:7,代码来源:views_tests.py


示例13: 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


示例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, app_mock):
     request = self.factory.get('/profile/delete/')
     request.user = utils.get_user_mock()
     response = views.user_profile_delete(request)
     app_mock.assert_called_once_with(owner=request.user)
     eq_(response.template_name, 'profile/user_profile_delete.html')
     eq_(sorted(response.context_data.keys()),
         sorted(['application_list', 'event_list', 'resource_list']))
开发者ID:jendc123,项目名称:us_ignite,代码行数:8,代码来源:views_tests.py


示例16: test_application_does_not_exist

 def test_application_does_not_exist(self, mock_get):
     mock_get.side_effect = Http404
     request = utils.get_request(
         'get', '/challenge/foo/enter/abc/', user=utils.get_user_mock())
     assert_raises(Http404, views.challenge_entry, request, 'foo', 'abc')
     mock_get.assert_called_once_with(
         Application, slug__exact='abc', owner=request.user,
         status=Application.PUBLISHED)
开发者ID:jendc123,项目名称:us_ignite,代码行数:8,代码来源:views_tests.py


示例17: test_not_published_entry_raises_404

 def test_not_published_entry_raises_404(self, mock_related):
     mock_related = mock_related.return_value
     mock_entry = Mock(spec=Entry)()
     mock_entry.is_visible_by.return_value = False
     mock_related.get.return_value = mock_entry
     request = utils.get_request(
         'get', '/challenges/gigabit/app/', user=utils.get_user_mock())
     assert_raises(Http404, views.entry_detail, request, 'gigabit', 'app')
     mock_entry.is_visible_by.assert_called_once_with(request.user)
开发者ID:jendc123,项目名称:us_ignite,代码行数:9,代码来源:views_tests.py


示例18: test_get_request_is_valid

 def test_get_request_is_valid(self, mock_get):
     mock_profile = Mock(spec=Profile)()
     mock_get.return_value = mock_profile
     request = utils.get_request(
         'get', '/contact/foo/', user=utils.get_user_mock())
     response = views.contact_user(request, 'foo')
     eq_(response.status_code, 200)
     eq_(response.template_name, 'relay/contact_user.html')
     eq_(sorted(response.context_data), ['form', 'object'])
开发者ID:jendc123,项目名称:us_ignite,代码行数:9,代码来源:views_tests.py


示例19: test_resource_requires_ownership

 def test_resource_requires_ownership(self, mock_get):
     mock_instance = Mock(spec=Resource)
     mock_instance.is_editable_by.return_value = False
     mock_get.return_value = mock_instance
     request = utils.get_request(
         'get', '/resource/foo/edit/', user=utils.get_user_mock())
     assert_raises(Http404, views.resource_edit, request, 'foo')
     mock_get.assert_called_once_with(Resource, slug__exact='foo')
     mock_instance.is_editable_by.assert_called_once_with(request.user)
开发者ID:jendc123,项目名称:us_ignite,代码行数:9,代码来源:views_tests.py


示例20: test_non_member_raises_404

 def test_non_member_raises_404(self, mock_get):
     app_mock = Mock(spec=Application)
     app_mock.name = 'Gigabit'
     app_mock.has_member.return_value = False
     mock_get.return_value = app_mock
     request = self.factory.get('/app/blue/export')
     request.user = utils.get_user_mock()
     assert_raises(Http404, views.app_export, request, 'blue')
     mock_get.assert_called_once_with(Application.active, slug__exact='blue')
     app_mock.has_member.assert_called_once_with(request.user)
开发者ID:jendc123,项目名称:us_ignite,代码行数:10,代码来源:views_tests.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python fixtures.get_user函数代码示例发布时间:2022-05-27
下一篇:
Python utils.get_request函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap