diff --git a/accounts/tests/test_user_model.py b/accounts/tests/test_user_model.py index 14b5300..9c8ad2a 100644 --- a/accounts/tests/test_user_model.py +++ b/accounts/tests/test_user_model.py @@ -1,5 +1,7 @@ from django.test import TestCase from django.contrib.auth.models import User +from accounts.models import Account +from uuid import UUID class UserModelTest(TestCase): @@ -11,6 +13,8 @@ class UserModelTest(TestCase): user_b = User(email='user_b@example.com', username='user_b') user_b.set_password('123456password') user_b.save() + Account.objects.create(user=user_a, twitter_handle='@user_a') + Account.objects.create(user=user_b) def test_user(self): test_users = User.objects.all() @@ -19,11 +23,25 @@ class UserModelTest(TestCase): self.assertTrue(isinstance(test_users[i].username, str)) user_a = User.objects.get(username='user_a') + account_a = Account.objects.get(user=user_a) self.assertTrue(user_a.check_password('password123456')) + self.assertTrue(account_a.user.check_password('password123456')) self.assertFalse(user_a.check_password('foo')) + self.assertFalse(account_a.user.check_password('foo')) self.assertEqual(user_a.pk, 1) + self.assertEqual(account_a.twitter_handle, '@user_a') + self.assertTrue(account_a.totp_key is None) + self.assertFalse(account_a.use_totp) + self.assertTrue(isinstance(account_a.pk, UUID)) user_b = User.objects.get(username='user_b') + account_b = Account.objects.get(user=user_b) self.assertTrue(user_b.check_password('123456password')) + self.assertTrue(account_b.user.check_password('123456password')) self.assertFalse(user_b.check_password('bar')) + self.assertFalse(account_b.user.check_password('bar')) self.assertEqual(user_b.pk, 2) + self.assertEqual(account_b.twitter_handle, '@Twitter') + self.assertTrue(user_b.account.totp_key is None) + self.assertFalse(user_b.account.use_totp) + self.assertTrue(isinstance(user_b.account.pk, UUID))