本文整理汇总了Python中tests.factories.AuthUserFactory.merge_user方法的典型用法代码示例。如果您正苦于以下问题:Python AuthUserFactory.merge_user方法的具体用法?Python AuthUserFactory.merge_user怎么用?Python AuthUserFactory.merge_user使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tests.factories.AuthUserFactory
的用法示例。
在下文中一共展示了AuthUserFactory.merge_user方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_merged_user
# 需要导入模块: from tests.factories import AuthUserFactory [as 别名]
# 或者: from tests.factories.AuthUserFactory import merge_user [as 别名]
def test_merged_user(self):
user = AuthUserFactory(fullname='Annie Lennox')
merged_user = AuthUserFactory(fullname='Lisa Stansfield')
user.save()
merged_user.save()
user.merge_user(merged_user)
user.save()
merged_user.save()
user.reload()
merged_user.reload()
modify_user_dates_in_mongo(self.yesterday)
data = UserSummary().get_events(self.yesterday.date())[0]
assert_equal(data['status']['merged'], 1)
示例2: TestUsers
# 需要导入模块: from tests.factories import AuthUserFactory [as 别名]
# 或者: from tests.factories.AuthUserFactory import merge_user [as 别名]
class TestUsers(ApiTestCase):
def setUp(self):
super(TestUsers, self).setUp()
self.user_one = AuthUserFactory()
self.user_two = AuthUserFactory()
def tearDown(self):
super(TestUsers, self).tearDown()
def test_returns_200(self):
res = self.app.get('/{}users/'.format(API_BASE))
assert_equal(res.status_code, 200)
assert_equal(res.content_type, 'application/vnd.api+json')
def test_find_user_in_users(self):
url = "/{}users/".format(API_BASE)
res = self.app.get(url)
user_son = res.json['data']
ids = [each['id'] for each in user_son]
assert_in(self.user_two._id, ids)
def test_all_users_in_users(self):
url = "/{}users/".format(API_BASE)
res = self.app.get(url)
user_son = res.json['data']
ids = [each['id'] for each in user_son]
assert_in(self.user_one._id, ids)
assert_in(self.user_two._id, ids)
def test_merged_user_is_not_in_user_list_after_2point3(self):
self.user_two.merge_user(self.user_one)
res = self.app.get('/{}users/?version=2.3'.format(API_BASE))
user_son = res.json['data']
ids = [each['id'] for each in user_son]
assert_equal(res.status_code, 200)
assert_in(self.user_two._id, ids)
assert_not_in(self.user_one._id, ids)
def test_merged_user_is_returned_before_2point3(self):
self.user_two.merge_user(self.user_one)
res = self.app.get('/{}users/'.format(API_BASE))
user_son = res.json['data']
ids = [each['id'] for each in user_son]
assert_equal(res.status_code, 200)
assert_in(self.user_two._id, ids)
assert_in(self.user_one._id, ids)
def test_find_multiple_in_users(self):
url = "/{}users/?filter[full_name]=fred".format(API_BASE)
res = self.app.get(url)
user_json = res.json['data']
ids = [each['id'] for each in user_json]
assert_in(self.user_one._id, ids)
assert_in(self.user_two._id, ids)
def test_find_single_user_in_users(self):
url = "/{}users/?filter[full_name]=my".format(API_BASE)
self.user_one.fullname = 'My Mom'
self.user_one.save()
res = self.app.get(url)
user_json = res.json['data']
ids = [each['id'] for each in user_json]
assert_in(self.user_one._id, ids)
assert_not_in(self.user_two._id, ids)
def test_find_no_user_in_users(self):
url = "/{}users/?filter[full_name]=NotMyMom".format(API_BASE)
res = self.app.get(url)
user_json = res.json['data']
ids = [each['id'] for each in user_json]
assert_not_in(self.user_one._id, ids)
assert_not_in(self.user_two._id, ids)
def test_more_than_one_projects_in_common(self):
project1 = ProjectFactory(creator=self.user_one)
project1.add_contributor(
contributor=self.user_two,
permissions=CREATOR_PERMISSIONS,
auth=Auth(user=self.user_one)
)
project1.save()
project2 = ProjectFactory(creator=self.user_one)
project2.add_contributor(
contributor=self.user_two,
permissions=CREATOR_PERMISSIONS,
auth=Auth(user=self.user_one)
)
project2.save()
url = "/{}users/?show_projects_in_common=true".format(API_BASE)
res = self.app.get(url, auth=self.user_two.auth)
user_json = res.json['data']
for user in user_json:
#.........这里部分代码省略.........