mirror of
https://git.linux-kernel.at/oliver/ivatar.git
synced 2025-11-15 12:38:03 +00:00
Adapt/add tests for handling default and redirect
This commit is contained in:
@@ -1124,12 +1124,52 @@ class Tester(TestCase): # pylint: disable=too-many-public-methods
|
|||||||
self.user.confirmedemail_set.first().delete()
|
self.user.confirmedemail_set.first().delete()
|
||||||
url = '%s?%s' % (urlobj.path, urlobj.query)
|
url = '%s?%s' % (urlobj.path, urlobj.query)
|
||||||
response = self.client.get(url, follow=True)
|
response = self.client.get(url, follow=True)
|
||||||
self.assertEqual(
|
self.assertRedirects(
|
||||||
response['Content-Type'],
|
response=response,
|
||||||
'image/png',
|
expected_url='/static/img/mm/80.png',
|
||||||
'Content type wrong!?')
|
msg_prefix='Why does this not redirect to the default img?')
|
||||||
# Eventually one should check if the data is the same
|
# Eventually one should check if the data is the same
|
||||||
|
|
||||||
|
def test_avatar_url_default(self): # pylint: disable=invalid-name
|
||||||
|
'''
|
||||||
|
Test fetching avatar for not existing mail with default specified
|
||||||
|
'''
|
||||||
|
urlobj = urlsplit(
|
||||||
|
libravatar_url(
|
||||||
|
'xxx@xxx.xxx',
|
||||||
|
size=80,
|
||||||
|
default='/static/img/nobody.png',
|
||||||
|
)
|
||||||
|
)
|
||||||
|
url = '%s?%s' % (urlobj.path, urlobj.query)
|
||||||
|
response = self.client.get(url, follow=True)
|
||||||
|
self.assertRedirects(
|
||||||
|
response=response,
|
||||||
|
expected_url='/static/img/nobody.png',
|
||||||
|
msg_prefix='Why does this not redirect to the default img?')
|
||||||
|
|
||||||
|
def test_avatar_url_default_external(self): # pylint: disable=invalid-name
|
||||||
|
'''
|
||||||
|
Test fetching avatar for not existing mail with external default specified
|
||||||
|
'''
|
||||||
|
default = 'http://host.tld/img.png'
|
||||||
|
urlobj = urlsplit(
|
||||||
|
libravatar_url(
|
||||||
|
'xxx@xxx.xxx',
|
||||||
|
size=80,
|
||||||
|
default=default,
|
||||||
|
)
|
||||||
|
)
|
||||||
|
url = '%s?%s' % (urlobj.path, urlobj.query)
|
||||||
|
response = self.client.get(url, follow=False)
|
||||||
|
print(response)
|
||||||
|
print(response.content)
|
||||||
|
self.assertRedirects(
|
||||||
|
response=response,
|
||||||
|
expected_url=default,
|
||||||
|
fetch_redirect_response=False,
|
||||||
|
msg_prefix='Why does this not redirect to the default img?')
|
||||||
|
|
||||||
def test_crop_photo(self):
|
def test_crop_photo(self):
|
||||||
'''
|
'''
|
||||||
Test cropping photo
|
Test cropping photo
|
||||||
|
|||||||
Reference in New Issue
Block a user