本文整理汇总了Python中us_ignite.common.tests.utils.get_anon_mock函数的典型用法代码示例。如果您正苦于以下问题:Python get_anon_mock函数的具体用法?Python get_anon_mock怎么用?Python get_anon_mock使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_anon_mock函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: test_resource_request_is_successful
def test_resource_request_is_successful(self, mock_get):
instance_mock = Mock(spec=Resource)
instance_mock.is_visible_by.return_value = True
mock_get.return_value = instance_mock
request = utils.get_request(
'get', '/resource/foo/', user=utils.get_anon_mock())
response = views.resource_detail(request, 'foo')
eq_(response.status_code, 200)
eq_(response.template_name, 'resources/object_detail.html')
eq_(response.context_data.keys(), ['object', 'is_owner'])
开发者ID:jendc123,项目名称:us_ignite,代码行数:10,代码来源:views_tests.py
示例17: test_published_hub_request_is_successful
def test_published_hub_request_is_successful(self):
fixtures.get_hub(name='community', status=models.Hub.PUBLISHED)
request = utils.get_request(
'get', '/hub/community/', user=utils.get_anon_mock())
response = views.hub_detail(request, 'community')
eq_(response.status_code, 200)
eq_(sorted(response.context_data.keys()),
sorted(['object', 'feature_list', 'member_list', 'is_member',
'is_contact', 'activity_list', 'event_list', 'award_list'])
)
开发者ID:jendc123,项目名称:us_ignite,代码行数:10,代码来源:views_tests.py
示例18: test_not_visible_post_raises_404
def test_not_visible_post_raises_404(self, mock_get):
mock_post = Mock(spec=Post)()
mock_post.is_visible_by.return_value = False
mock_get.return_value = mock_post
user = utils.get_anon_mock()
request = utils.get_request('get', '/blog/', user=user)
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)
mock_post.is_visible_by.assert_called_once_with(user)
开发者ID:jendc123,项目名称:us_ignite,代码行数:11,代码来源:views_tests.py
示例19: test_get_request_is_valid
def test_get_request_is_valid(self, mock_get):
mock_instance = Mock(spec=Event)()
mock_instance.audiences.all.return_value = []
mock_instance.is_visible_by.return_value = True
mock_instance.hubs.all.return_value = []
mock_get.return_value = mock_instance
request = utils.get_request("get", "/event/abc/", user=utils.get_anon_mock())
response = views.event_detail(request, "abc")
mock_get.assert_called_once_with(Event, slug__exact="abc")
mock_instance.is_visible_by.assert_called_once_with(request.user)
eq_(response.status_code, 200)
eq_(sorted(response.context_data.keys()), sorted(["hub_list", "is_owner", "object", "audience_list"]))
eq_(response.template_name, "events/object_detail.html")
开发者ID:jendc123,项目名称:us_ignite,代码行数:13,代码来源:views_tests.py
示例20: test_organization_request_is_successful
def test_organization_request_is_successful(self, mock_get, mock_awards):
mock_instance = Mock(spec=Organization)()
mock_instance.interests.all.return_value = []
mock_get.return_value = mock_instance
mock_instance.is_visible_by.return_value = True
mock_awards.return_value = []
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()),
sorted(['interest_list', 'is_member', 'member_list', 'object',
'award_list']))
开发者ID:us-ignite,项目名称:us_ignite,代码行数:14,代码来源:views_tests.py
注:本文中的us_ignite.common.tests.utils.get_anon_mock函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论