add some more tests

This commit is contained in:
Trent Palmer 2021-04-06 23:16:54 -07:00
parent f53640ec4f
commit 1ddc459ed3
5 changed files with 53 additions and 3 deletions

1
.gitignore vendored
View File

@ -2,6 +2,7 @@
db.sqlite3 db.sqlite3
accounts/__pycache__ accounts/__pycache__
accounts/migrations/__pycache__ accounts/migrations/__pycache__
accounts/tests/__pycache__
audio/__pycache__ audio/__pycache__
audio/migrations/__pycache__ audio/migrations/__pycache__
audio/tests/__pycache__ audio/tests/__pycache__

View File

@ -1,3 +0,0 @@
from django.test import TestCase
# Create your tests here.

View File

View 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))

View 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)