diff options
author | luxagraf <sng@luxagraf.net> | 2018-11-14 13:17:42 -0600 |
---|---|---|
committer | luxagraf <sng@luxagraf.net> | 2018-11-14 13:17:42 -0600 |
commit | a0b95dc2dfb84c682bb8f677e5d471f84e5028fe (patch) | |
tree | 6dd1919856f736c5b644270d59b57e4bb20336c5 /apps/accounts/tests |
wrote out basic notes skeleton
Diffstat (limited to 'apps/accounts/tests')
-rw-r--r-- | apps/accounts/tests/__init__.py | 0 | ||||
-rw-r--r-- | apps/accounts/tests/test_models.py | 13 | ||||
-rw-r--r-- | apps/accounts/tests/test_views.py | 23 |
3 files changed, 36 insertions, 0 deletions
diff --git a/apps/accounts/tests/__init__.py b/apps/accounts/tests/__init__.py new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/apps/accounts/tests/__init__.py diff --git a/apps/accounts/tests/test_models.py b/apps/accounts/tests/test_models.py new file mode 100644 index 0000000..f9b33f6 --- /dev/null +++ b/apps/accounts/tests/test_models.py @@ -0,0 +1,13 @@ +from django.test import TestCase +from mixer.backend.django import mixer + +from accounts.models import User, UserProfile + + +class UserProfileModelTest(TestCase): + + def test_string_representation(self): + user = mixer.blend(User, username='test') + user.save() + profile = UserProfile.objects.get(user=user) + self.assertEqual(str(profile), str(user.username)) diff --git a/apps/accounts/tests/test_views.py b/apps/accounts/tests/test_views.py new file mode 100644 index 0000000..39dcb31 --- /dev/null +++ b/apps/accounts/tests/test_views.py @@ -0,0 +1,23 @@ +from django.test import Client +from django.test import RequestFactory, TestCase +from mixer.backend.django import mixer + +from accounts.models import User +from accounts.views import ProfileView + + +class ProfileViewTest(TestCase): + def setUp(self): + # Every test needs access to the request factory. + self.factory = RequestFactory() + self.user = mixer.blend(User, username='tpynchon', password="gravity") + + def test_profile_view(self): + request = self.factory.get('/settings/') + request.user = self.user + response = ProfileView.as_view()(request) + self.assertEqual(response.status_code, 200) + response.render() + html = response.content.decode('utf8') + self.assertTrue(html.startswith('<!DOCTYPE html>')) + self.assertIn('<h1>Account Settings</h1>', html) |