TST: Coverage and adding new model tests
This commit is contained in:
parent
5c69e774f9
commit
31714215d0
10 changed files with 65 additions and 11 deletions
0
ccdb/users/tests/__init__.py
Normal file
0
ccdb/users/tests/__init__.py
Normal file
19
ccdb/users/tests/test_models.py
Normal file
19
ccdb/users/tests/test_models.py
Normal file
|
@ -0,0 +1,19 @@
|
|||
from django.test import TestCase
|
||||
from django.db import IntegrityError, transaction
|
||||
|
||||
from ..models import User
|
||||
from ..factories import UserFactory
|
||||
|
||||
|
||||
class UserTestCase(TestCase):
|
||||
def test_creation(self):
|
||||
u = UserFactory()
|
||||
self.assertTrue(isinstance(u, User))
|
||||
self.assertEqual(u.__str__(), u.username)
|
||||
|
||||
def test_uniqueness(self):
|
||||
u1 = UserFactory()
|
||||
with transaction.atomic(), self.assertRaises(IntegrityError):
|
||||
UserFactory(username=u1.username)
|
||||
u3 = UserFactory()
|
||||
self.assertTrue(isinstance(u3, User))
|
Loading…
Add table
Add a link
Reference in a new issue