本文整理汇总了Python中test_utils.RequestFactory.amo_user方法的典型用法代码示例。如果您正苦于以下问题:Python RequestFactory.amo_user方法的具体用法?Python RequestFactory.amo_user怎么用?Python RequestFactory.amo_user使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类test_utils.RequestFactory
的用法示例。
在下文中一共展示了RequestFactory.amo_user方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_request
# 需要导入模块: from test_utils import RequestFactory [as 别名]
# 或者: from test_utils.RequestFactory import amo_user [as 别名]
def get_request(self, profile):
request = RequestFactory().post('/')
if not profile:
request.user = AnonymousUser()
else:
request.user = profile.user
request.amo_user = profile
return request
示例2: req_factory_factory
# 需要导入模块: from test_utils import RequestFactory [as 别名]
# 或者: from test_utils.RequestFactory import amo_user [as 别名]
def req_factory_factory(url, user=None):
"""Creates a request factory, logged in with the user."""
req = RequestFactory().get(url)
if user:
req.amo_user = user
req.user = user.user
req.groups = req.user.get_profile().groups.all()
return req
示例3: check_permissions
# 需要导入模块: from test_utils import RequestFactory [as 别名]
# 或者: from test_utils.RequestFactory import amo_user [as 别名]
def check_permissions(self):
req = RequestFactory().get(reverse('comm-thread-detail',
kwargs={'pk': self.thread.pk}))
req.user = self.user
req.amo_user = self.profile
req.groups = req.amo_user.groups.all()
return ThreadPermission().has_object_permission(
req, 'comm-thread-detail', self.thread)
示例4: req_factory_factory
# 需要导入模块: from test_utils import RequestFactory [as 别名]
# 或者: from test_utils.RequestFactory import amo_user [as 别名]
def req_factory_factory(url, user=None, post=False, data=None):
"""Creates a request factory, logged in with the user."""
req = RequestFactory()
if post:
req = req.post(url, data or {})
else:
req = req.get(url, data or {})
if user:
req.amo_user = user
req.user = user.user
req.groups = req.user.get_profile().groups.all()
return req
示例5: req_factory_factory
# 需要导入模块: from test_utils import RequestFactory [as 别名]
# 或者: from test_utils.RequestFactory import amo_user [as 别名]
def req_factory_factory(url, user=None, post=False, data=None):
"""Creates a request factory, logged in with the user."""
req = RequestFactory()
if post:
req = req.post(url, data or {})
else:
req = req.get(url, data or {})
if user:
req.amo_user = UserProfile.objects.get(id=user.id)
req.user = user
req.groups = user.groups.all()
req.check_ownership = partial(check_ownership, req)
return req
示例6: create_request
# 需要导入模块: from test_utils import RequestFactory [as 别名]
# 或者: from test_utils.RequestFactory import amo_user [as 别名]
def create_request(self, user_profile):
request = RequestFactory().get('/')
request.amo_user = user_profile
return request