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


Python utils.get_anon_mock函数代码示例

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


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

示例1: test_anon_user_returns_public_objects

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

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

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

示例4: test_is_not_visible_when_is_draft

 def test_is_not_visible_when_is_draft(self):
     user = get_user('us-ignite')
     challenge = fixtures.get_challenge(user=user)
     application = get_application(owner=user)
     entry = fixtures.get_entry(
         application, challenge=challenge, status=Entry.DRAFT)
     eq_(entry.is_visible_by(utils.get_anon_mock()), False)
开发者ID:jendc123,项目名称:us_ignite,代码行数:7,代码来源:models_tests.py

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

示例6: test_is_visible_for_published_challenges

 def test_is_visible_for_published_challenges(self):
     user = get_user('us-ignite')
     challenge = fixtures.get_challenge(user=user)
     application = get_application(owner=user)
     entry = fixtures.get_entry(
         application, challenge=challenge, status=Entry.SUBMITTED)
     eq_(entry.is_visible_by(utils.get_anon_mock()), True)
开发者ID:jendc123,项目名称:us_ignite,代码行数:7,代码来源:models_tests.py

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

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

示例9: setUp

 def setUp(self):
     # key is a mk5 key, determined between the remote ip and
     # path from the request
     self.key = '8243f83255259f10db07a5c781f7c3ab'
     self.factory = client.RequestFactory()
     kwargs = {'HTTP_X_FORWARDED_FOR': '127.0.0.1'}
     self.request = self.factory.get('/', **kwargs)
     self.request.user = utils.get_anon_mock()
开发者ID:jendc123,项目名称:us_ignite,代码行数:8,代码来源:decorators_tests.py

示例10: test_get_request_is_successful

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

示例11: challenge_detail_anon_request_is_valid

 def challenge_detail_anon_request_is_valid(self, mock_filter):
     request = utils.get_request(
         'get', '/challenges/gigabit/', user=utils.get_anon_mock())
     response = views.challenge_detail(request, 'gigabit')
     eq_(response.status_code, 200)
     eq_(response.template_name, 'challenges/object_detail.html')
     eq_(sorted(response.context_data.keys()), ['entry_list', 'object'])
     eq_(mock_filter.call_count, 0)
开发者ID:jendc123,项目名称:us_ignite,代码行数:8,代码来源:views_tests.py

示例12: test_resource_list_request_is_successful

 def test_resource_list_request_is_successful(self, mock_filter):
     mock_filter.return_value = []
     request = utils.get_request(
         'get', '/resource/', user=utils.get_anon_mock())
     response = views.resource_list(request)
     eq_(response.status_code, 200)
     eq_(response.template_name, 'resources/object_list.html')
     eq_(sorted(response.context_data.keys()), ['page'])
开发者ID:jendc123,项目名称:us_ignite,代码行数:8,代码来源:views_tests.py

示例13: test_non_visible_resource_raises_404

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

示例14: test_request_is_successful

 def test_request_is_successful(self, related_mock):
     related_mock.return_value.filter.return_value = []
     related_mock.return_value.all.return_value = []
     request = utils.get_request('get', '/blog/', user=utils.get_anon_mock())
     response = views.post_list(request)
     eq_(response.status_code, 200)
     eq_(response.template_name, 'blog/object_list.html')
     eq_(sorted(response.context_data.keys()), ['featured_list', 'page'])
     eq_(related_mock.return_value.filter.call_count, 2)
开发者ID:us-ignite,项目名称:us_ignite,代码行数:9,代码来源:views_tests.py

示例15: test_organization_request_is_successful

 def test_organization_request_is_successful(self, mock_get):
     mock_instance = Mock(spec=Organization)()
     mock_get.return_value = mock_instance
     mock_instance.is_visible_by.return_value = True
     request = utils.get_request("get", "/org/foo/", user=utils.get_anon_mock())
     response = views.organization_detail(request, "foo")
     eq_(response.status_code, 200)
     eq_(response.template_name, "organizations/object_detail.html")
     eq_(sorted(response.context_data.keys()), ["is_member", "member_list", "object"])
开发者ID:jendc123,项目名称:us_ignite,代码行数:9,代码来源:views_tests.py


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