Coverage for ivatar/test_auxiliary.py: 100%
19 statements
« prev ^ index » next coverage.py v7.6.9, created at 2024-12-26 00:11 +0000
« prev ^ index » next coverage.py v7.6.9, created at 2024-12-26 00:11 +0000
1# -*- coding: utf-8 -*-
2"""
3Test various other parts of ivatar/libravatar in order
4to increase the overall test coverage. Test in here, didn't
5fit anywhere else.
6"""
8from django.test import TestCase
9from django.contrib.auth.models import User
11from ivatar.utils import random_string
12from ivatar.ivataraccount.models import pil_format, UserPreference
15class Tester(TestCase):
16 """
17 Main test class
18 """
20 user = None
21 username = random_string()
23 def setUp(self):
24 """
25 Prepare tests.
26 - Create user
27 """
28 self.user = User.objects.create_user(
29 username=self.username,
30 )
32 def test_pil_format(self):
33 """
34 Test pil format function
35 """
36 self.assertEqual(pil_format("jpg"), "JPEG")
37 self.assertEqual(pil_format("jpeg"), "JPEG")
38 self.assertEqual(pil_format("png"), "PNG")
39 self.assertEqual(pil_format("gif"), "GIF")
40 self.assertEqual(pil_format("webp"), "WEBP")
41 self.assertEqual(pil_format("abc"), None)
43 def test_userprefs_str(self):
44 """
45 Test if str representation of UserPreferences is as expected
46 """
47 up = UserPreference(theme="default", user=self.user)
48 print(up)