mirror of
https://git.linux-kernel.at/oliver/ivatar.git
synced 2025-11-18 05:58:02 +00:00
Merge branch 'devel' into 'master'
X-Mas release Closes #77 See merge request oliver/ivatar!177
This commit is contained in:
46
ivatar/test_auxiliary.py
Normal file
46
ivatar/test_auxiliary.py
Normal file
@@ -0,0 +1,46 @@
|
||||
'''
|
||||
Test various other parts of ivatar/libravatar in order
|
||||
to increase the overall test coverage. Test in here, didn't
|
||||
fit anywhere else.
|
||||
'''
|
||||
|
||||
from django.test import TestCase
|
||||
from django.contrib.auth.models import User
|
||||
|
||||
from ivatar.utils import random_string
|
||||
from ivatar.ivataraccount.models import pil_format, UserPreference
|
||||
|
||||
|
||||
class Tester(TestCase):
|
||||
'''
|
||||
Main test class
|
||||
'''
|
||||
user = None
|
||||
username = random_string()
|
||||
|
||||
def setUp(self):
|
||||
'''
|
||||
Prepare tests.
|
||||
- Create user
|
||||
'''
|
||||
self.user = User.objects.create_user(
|
||||
username=self.username,
|
||||
)
|
||||
|
||||
def test_pil_format(self):
|
||||
'''
|
||||
Test pil format function
|
||||
'''
|
||||
self.assertEqual(pil_format('jpg'), 'JPEG')
|
||||
self.assertEqual(pil_format('jpeg'), 'JPEG')
|
||||
self.assertEqual(pil_format('png'), 'PNG')
|
||||
self.assertEqual(pil_format('gif'), 'GIF')
|
||||
self.assertEqual(pil_format('abc'), None)
|
||||
|
||||
def test_userprefs_str(self):
|
||||
'''
|
||||
Test if str representation of UserPreferences is as expected
|
||||
'''
|
||||
up = UserPreference(theme='default', user=self.user)
|
||||
print(up)
|
||||
|
||||
@@ -99,3 +99,12 @@ class CheckForm(forms.Form):
|
||||
if not mail and not openid:
|
||||
raise ValidationError(_('Either OpenID or mail must be specified'))
|
||||
return self.cleaned_data
|
||||
|
||||
def clean_openid(self):
|
||||
data = self.cleaned_data['openid']
|
||||
return data.lower()
|
||||
|
||||
def clean_mail(self):
|
||||
data = self.cleaned_data['mail']
|
||||
print(data)
|
||||
return data.lower()
|
||||
|
||||
Reference in New Issue
Block a user