mirror of
https://github.com/TrentSPalmer/trentpalmerdotorg.git
synced 2024-12-22 04:52:49 -08:00
add some more tests
This commit is contained in:
parent
f53640ec4f
commit
1ddc459ed3
1
.gitignore
vendored
1
.gitignore
vendored
@ -2,6 +2,7 @@
|
||||
db.sqlite3
|
||||
accounts/__pycache__
|
||||
accounts/migrations/__pycache__
|
||||
accounts/tests/__pycache__
|
||||
audio/__pycache__
|
||||
audio/migrations/__pycache__
|
||||
audio/tests/__pycache__
|
||||
|
@ -1,3 +0,0 @@
|
||||
from django.test import TestCase
|
||||
|
||||
# Create your tests here.
|
0
accounts/tests/__init__.py
Normal file
0
accounts/tests/__init__.py
Normal file
23
accounts/tests/test_email_white_list_model.py
Normal file
23
accounts/tests/test_email_white_list_model.py
Normal file
@ -0,0 +1,23 @@
|
||||
from django.test import TestCase
|
||||
from uuid import UUID
|
||||
from accounts.models import EmailWhiteList
|
||||
|
||||
|
||||
class EmailWhiteListModelTest(TestCase):
|
||||
|
||||
def setUp(self):
|
||||
email_a = EmailWhiteList(email='user_a@example.com')
|
||||
email_a.save()
|
||||
EmailWhiteList.objects.create(email='user_b@example.com')
|
||||
|
||||
def test_email(self):
|
||||
white_listed_emails = EmailWhiteList.objects.all()
|
||||
|
||||
self.assertTrue(len(white_listed_emails) == 2)
|
||||
|
||||
email_a = white_listed_emails.filter(pk=1)
|
||||
self.assertTrue(len(email_a) == 0)
|
||||
|
||||
for i, x in enumerate(white_listed_emails):
|
||||
self.assertTrue(isinstance(white_listed_emails[i].pk, UUID))
|
||||
self.assertTrue(isinstance(white_listed_emails[i].email, str))
|
29
accounts/tests/test_user_model.py
Normal file
29
accounts/tests/test_user_model.py
Normal file
@ -0,0 +1,29 @@
|
||||
from django.test import TestCase
|
||||
from django.contrib.auth.models import User
|
||||
|
||||
|
||||
class UserModelTest(TestCase):
|
||||
|
||||
def setUp(self):
|
||||
user_a = User(email='user_a@example.com', username='user_a')
|
||||
user_a.set_password('password123456')
|
||||
user_a.save()
|
||||
user_b = User(email='user_b@example.com', username='user_b')
|
||||
user_b.set_password('123456password')
|
||||
user_b.save()
|
||||
|
||||
def test_user(self):
|
||||
test_users = User.objects.all()
|
||||
for i, x in enumerate(test_users):
|
||||
self.assertTrue(isinstance(test_users[i].email, str))
|
||||
self.assertTrue(isinstance(test_users[i].username, str))
|
||||
|
||||
user_a = User.objects.get(username='user_a')
|
||||
self.assertTrue(user_a.check_password('password123456'))
|
||||
self.assertFalse(user_a.check_password('foo'))
|
||||
self.assertEqual(user_a.pk, 1)
|
||||
|
||||
user_b = User.objects.get(username='user_b')
|
||||
self.assertTrue(user_b.check_password('123456password'))
|
||||
self.assertFalse(user_b.check_password('bar'))
|
||||
self.assertEqual(user_b.pk, 2)
|
Loading…
Reference in New Issue
Block a user