本文整理汇总了Python中avocado.models.DataQuery.share_with_user方法的典型用法代码示例。如果您正苦于以下问题:Python DataQuery.share_with_user方法的具体用法?Python DataQuery.share_with_user怎么用?Python DataQuery.share_with_user使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类avocado.models.DataQuery
的用法示例。
在下文中一共展示了DataQuery.share_with_user方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_no_create_on_share
# 需要导入模块: from avocado.models import DataQuery [as 别名]
# 或者: from avocado.models.DataQuery import share_with_user [as 别名]
def test_no_create_on_share(self):
# Make sure we are starting with the anticipated number of users.
self.assertEqual(User.objects.count(), 1)
# Assign an email to the existing user
User.objects.all().update(email=self.existing_email)
query = DataQuery(template=True, default=True)
query.save()
self.assertEqual(query.shared_users.count(), 0)
# Test when both settings are False
response = query.share_with_user(self.existing_email)
self.assertEqual(response, False)
with self.settings(AVOCADO_SHARE_BY_EMAIL=True):
# Share with all the emails but, with create_user set to False, the
# query should only be shared with the 1 existing user.
[query.share_with_user(e, create_user=False)
for e in self.emails]
# Check that the user count increased for the email-based users
self.assertEqual(User.objects.count(), 1)
# Check that the users are in the query's shared_users
self.assertEqual(query.shared_users.count(), 1)
示例2: test_add_shared_user
# 需要导入模块: from avocado.models import DataQuery [as 别名]
# 或者: from avocado.models.DataQuery import share_with_user [as 别名]
def test_add_shared_user(self):
# Make sure we are starting with the anticipated number of users.
self.assertEqual(User.objects.count(), 1)
# Assign an email to the existing user
User.objects.update(email=self.existing_email,
username=self.existing_username)
query = DataQuery(template=True, default=True)
query.save()
self.assertEqual(query.shared_users.count(), 0)
# Try add an existing user to shared users by username
query.share_with_user(self.existing_username)
self.assertEqual(query.shared_users.count(), 1)
[query.share_with_user(e) for e in self.emails]
# Looking up non existant users with usernames should not
# create new users
[query.share_with_user(u) for u in self.usernames]
# Check that the user count increased for the email-based users
# and no extra users were created when queried w/ username
self.assertEqual(User.objects.count(), 4)
# Check that the users are in the query's shared_users
self.assertEqual(query.shared_users.count(), 4)
示例3: test_duplicate_share
# 需要导入模块: from avocado.models import DataQuery [as 别名]
# 或者: from avocado.models.DataQuery import share_with_user [as 别名]
def test_duplicate_share(self):
query = DataQuery(template=True, default=True)
query.save()
[query.share_with_user(e) for e in self.emails]
share_count = query.shared_users.count()
user_count = User.objects.count()
# Make sure that requests to share with users that are already shared
# with don't cause new user or shared_user entries.
[query.share_with_user(e) for e in self.emails]
self.assertEqual(share_count, query.shared_users.count())
self.assertEqual(user_count, User.objects.count())
示例4: test_add_shared_user
# 需要导入模块: from avocado.models import DataQuery [as 别名]
# 或者: from avocado.models.DataQuery import share_with_user [as 别名]
def test_add_shared_user(self):
# Make sure we are starting with the anticipated number of users.
self.assertEqual(User.objects.count(), 1)
# Assign an email to the existing user
User.objects.all().update(email=self.existing_email)
query = DataQuery(template=True, default=True)
query.save()
self.assertEqual(query.shared_users.count(), 0)
[query.share_with_user(e) for e in self.emails]
# Check that the user count increased for the email-based users
self.assertEqual(User.objects.count(), 4)
# Check that the users are in the query's shared_users
self.assertEqual(query.shared_users.count(), 4)