本文整理汇总了Python中myjobs.tests.factories.UserFactory.can方法的典型用法代码示例。如果您正苦于以下问题:Python UserFactory.can方法的具体用法?Python UserFactory.can怎么用?Python UserFactory.can使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类myjobs.tests.factories.UserFactory
的用法示例。
在下文中一共展示了UserFactory.can方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_can_method_with_app_access
# 需要导入模块: from myjobs.tests.factories import UserFactory [as 别名]
# 或者: from myjobs.tests.factories.UserFactory import can [as 别名]
def test_can_method_with_app_access(self):
"""
``User.can`` should return False when a user isn't associated with the
correct activities and True when they are.
"""
user = UserFactory(email="[email protected]", roles=[self.role])
self.role.activities = self.activities
activities = self.role.activities.values_list('name', flat=True)
# check for a single activity
self.assertTrue(user.can(self.company, activities[0]))
self.assertFalse(user.can(self.company, "eat a burrito"))
# check for multiple activities
self.assertTrue(user.can(self.company, *activities))
self.assertFalse(user.can(
self.company, activities[0], "eat a burrito"))