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


Python utils.get_user_mock函数代码示例

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


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


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