本文整理汇总了Python中mozillians.users.models.UserProfile.extract_document方法的典型用法代码示例。如果您正苦于以下问题:Python UserProfile.extract_document方法的具体用法?Python UserProfile.extract_document怎么用?Python UserProfile.extract_document使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mozillians.users.models.UserProfile
的用法示例。
在下文中一共展示了UserProfile.extract_document方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_extract_document
# 需要导入模块: from mozillians.users.models import UserProfile [as 别名]
# 或者: from mozillians.users.models.UserProfile import extract_document [as 别名]
def test_extract_document(self):
user = UserFactory.create(userprofile={'allows_community_sites': False,
'allows_mozilla_sites': False,
'full_name': 'Nikos Koukos',
'bio': 'This is my bio'})
profile = user.userprofile
group_1 = GroupFactory.create()
group_2 = GroupFactory.create()
skill_1 = SkillFactory.create()
skill_2 = SkillFactory.create()
LanguageFactory.create(code='fr', userprofile=profile)
LanguageFactory.create(code='en', userprofile=profile)
group_1.add_member(profile)
group_2.add_member(profile)
profile.skills.add(skill_1)
profile.skills.add(skill_2)
result = UserProfile.extract_document(profile.id)
ok_(isinstance(result, dict))
eq_(result['id'], profile.id)
eq_(result['is_vouched'], profile.is_vouched)
eq_(result['region'], 'Attika')
eq_(result['city'], 'Athens')
eq_(result['allows_community_sites'], profile.allows_community_sites)
eq_(result['allows_mozilla_sites'], profile.allows_mozilla_sites)
eq_(set(result['country']), set(['gr', 'Greece']))
eq_(result['fullname'], profile.full_name.lower())
eq_(result['name'], profile.full_name.lower())
eq_(result['bio'], profile.bio)
eq_(result['has_photo'], False)
eq_(result['groups'], [group_1.name, group_2.name])
eq_(result['skills'], [skill_1.name, skill_2.name])
eq_(set(result['languages']),
set([u'en', u'fr', u'english', u'french', u'français']))
示例2: test_extract_document
# 需要导入模块: from mozillians.users.models import UserProfile [as 别名]
# 或者: from mozillians.users.models.UserProfile import extract_document [as 别名]
def test_extract_document(self):
country = CountryFactory.create(name="Greece", code="gr")
region = RegionFactory.create(name="attika", country=country)
city = CityFactory.create(name="athens", region=region, country=country)
user = UserFactory.create(
userprofile={
"geo_city": city,
"geo_region": region,
"allows_community_sites": False,
"allows_mozilla_sites": False,
"geo_country": country,
"full_name": "Nikos Koukos",
"bio": "This is my bio",
}
)
profile = user.userprofile
group_1 = GroupFactory.create()
group_2 = GroupFactory.create()
skill_1 = SkillFactory.create()
skill_2 = SkillFactory.create()
LanguageFactory.create(code="fr", userprofile=profile)
LanguageFactory.create(code="en", userprofile=profile)
group_1.add_member(profile)
group_2.add_member(profile)
profile.skills.add(skill_1)
profile.skills.add(skill_2)
result = UserProfile.extract_document(user.userprofile.id)
ok_(isinstance(result, dict))
eq_(result["id"], profile.id)
eq_(result["is_vouched"], profile.is_vouched)
eq_(result["region"], region.name)
eq_(result["city"], city.name)
eq_(result["allows_community_sites"], profile.allows_community_sites)
eq_(result["allows_mozilla_sites"], profile.allows_mozilla_sites)
eq_(result["country"], country.name)
eq_(result["fullname"], profile.full_name.lower())
eq_(result["name"], profile.full_name.lower())
eq_(result["bio"], profile.bio)
eq_(result["has_photo"], False)
eq_(result["groups"], [group_1.name, group_2.name])
eq_(result["skills"], [skill_1.name, skill_2.name])
eq_(set(result["languages"]), set([u"en", u"fr", u"english", u"french", u"français"]))
示例3: test_extract_document
# 需要导入模块: from mozillians.users.models import UserProfile [as 别名]
# 或者: from mozillians.users.models.UserProfile import extract_document [as 别名]
def test_extract_document(self):
group_1 = GroupFactory.create()
group_2 = GroupFactory.create()
skill_1 = SkillFactory.create()
skill_2 = SkillFactory.create()
language_1 = LanguageFactory.create()
language_2 = LanguageFactory.create()
user = UserFactory.create(userprofile={'website': 'bestplaceonthenet.com',
'city': 'athens',
'region': 'attika',
'allows_community_sites': False,
'allows_mozilla_sites': False,
'country': 'gr',
'full_name': 'Nikos Koukos',
'bio': 'This is my bio'})
profile = user.userprofile
profile.groups.add(group_1)
profile.groups.add(group_2)
profile.skills.add(skill_1)
profile.skills.add(skill_2)
profile.languages.add(language_1)
profile.languages.add(language_2)
result = UserProfile.extract_document(user.userprofile.id)
ok_(isinstance(result, dict))
eq_(result['id'], profile.id)
eq_(result['is_vouched'], profile.is_vouched)
eq_(result['website'], profile.website)
eq_(result['region'], profile.region)
eq_(result['city'], profile.city)
eq_(result['allows_community_sites'], profile.allows_community_sites)
eq_(result['allows_mozilla_sites'], profile.allows_mozilla_sites)
eq_(result['country'], ['gr', 'greece'])
eq_(result['fullname'], profile.full_name.lower())
eq_(result['name'], profile.full_name.lower())
eq_(result['bio'], profile.bio)
eq_(result['has_photo'], False)
eq_(result['groups'], [group_1.name, group_2.name])
eq_(result['skills'], [skill_1.name, skill_2.name])
eq_(result['languages'], [language_1.name, language_2.name])