本文整理汇总了Python中myjobs.tests.factories.UserFactory.get_gravatar_url方法的典型用法代码示例。如果您正苦于以下问题:Python UserFactory.get_gravatar_url方法的具体用法?Python UserFactory.get_gravatar_url怎么用?Python UserFactory.get_gravatar_url使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类myjobs.tests.factories.UserFactory
的用法示例。
在下文中一共展示了UserFactory.get_gravatar_url方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_gravatar_url
# 需要导入模块: from myjobs.tests.factories import UserFactory [as 别名]
# 或者: from myjobs.tests.factories.UserFactory import get_gravatar_url [as 别名]
def test_gravatar_url(self):
"""
Test that email is hashed correctly and returns a 200 response
"""
user = UserFactory()
gravatar_url = "http://www.gravatar.com/avatar/c160f8cc69a4f0b" \
"f2b0362752353d060?s=20&d=mm"
no_gravatar_url = ("<div class='gravatar-blank gravatar-danger' "
"style='height: 20px; width: 20px'>"
"<span class='gravatar-text' "
"style='font-size:13.0px;'>A</span></div>")
generated_gravatar_url = user.get_gravatar_url()
self.assertEqual(no_gravatar_url, generated_gravatar_url)
status_code = urllib.urlopen(gravatar_url).getcode()
self.assertEqual(status_code, 200)
示例2: MyJobsViewsTests
# 需要导入模块: from myjobs.tests.factories import UserFactory [as 别名]
# 或者: from myjobs.tests.factories.UserFactory import get_gravatar_url [as 别名]
#.........这里部分代码省略.........
Else, assert that it does not exist
"""
communication_div = contents.find('div',
{'id': 'as-communication'})
if is_verified is True:
self.assertTrue(communication_div)
else:
self.assertFalse(communication_div)
unverified_user = UserFactory(email='[email protected]',
is_verified=False)
for user in [self.user, unverified_user]:
self.client.login_user(user)
response = self.client.get(reverse('edit_account'))
soup = BeautifulSoup(response.content)
assert_communication_settings_presence(user.is_verified, soup)
def test_case_insensitive_login(self):
"""
Test that emails are case-insensitive when logging in
"""
for email in [self.user.email, self.user.email.upper()]:
response = self.client.post(reverse('home'),
data={'username': email,
'password': '[email protected]',
'action': 'login'})
self.assertEqual(response.status_code, 200)
self.assertEqual(response.content, '{"url": null,' +
' "units": false,' +
' "gravatar_url": "' +
self.user.get_gravatar_url(
size=100)+'",' +
' "validation": "valid"}')
self.client.get(reverse('auth_logout'))
def test_guid_cookies_login_and_off(self):
"""
Tests logging in and recieving a guid cookie. Logging out deletes guid
cookie.
"""
response = self.client.post(reverse('home'),
data={'username': self.user.email,
'password': '[email protected]',
'action': 'login'})
self.assertTrue(response.cookies['myguid'])
cookie_guid = response.cookies['myguid']
guid = cookie_guid.value
self.assertEqual(guid, self.user.user_guid)
resp_logoff = self.client.post(reverse('auth_logout'))
cookie_guid_off = resp_logoff.cookies['myguid']
guid_off = cookie_guid_off.value
self.assertEqual(guid_off, '')
def test_jira_login(self):
jira = JIRA(options=options, basic_auth=my_agent_auth)
self.assertIsNotNone(jira)
def test_anonymous_unsubscribe_all_myjobs_emails(self):
Session.objects.all().delete()
self.assertTrue(self.user.opt_in_myjobs)