Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test wasn't relevant enough, this fix makes it much faster as well. #12

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 17 additions & 6 deletions longerusername/tests.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,30 @@
from django.contrib.auth.models import User
from django.test import TestCase


class LongerUsernameTests(TestCase):
"""
Unit tests for longerusername app
"""

def setUp(self):
"""
creates a user with a terribly long username
"""
"""creates a user with a terribly long username"""
long_username = ''.join([str(i) for i in range(100)])
self.user = User.objects.create_user('test' + long_username, '[email protected]', 'testpassword')
def testUserCreation(self):
self.user = User.objects.create_user('test' + long_username,
'[email protected]', 'testpassword')

def test_user_creation(self):
"""
tests that self.user was successfully saved, and can be retrieved
"""
self.assertNotEqual(self.user,None)
User.objects.get(id=self.user.id) # returns DoesNotExist error if the user wasn't created
# returns DoesNotExist error if the user wasn't created
User.objects.get(id=self.user.id)

def test_username_max_length(self):
"""
tests that User.username field has now a max_length = 255 instead of
the django default 30
"""
self.assertEqual(User._meta.get_field('username').max_length, 255,
msg='user.signals changed the max_length from 30 to 255')