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

Musa and James' Django Validations #7

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions django_validations/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django_validations',
]

MIDDLEWARE = [
Expand Down
12 changes: 0 additions & 12 deletions swimrecords/models.py

This file was deleted.

10 changes: 9 additions & 1 deletion swimrecords/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,27 +10,35 @@ class SwimRecordTestCase(TestCase):

def test_01_validate_first_name_presence(self):
"""validates presence of first_name"""

valid_first_name = SwimRecord(first_name='Musa', last_name='Shogunle', team_name='Coder', relay= True, stroke='Butterfly', distance=100)
try:
self.record.full_clean()
except ValidationError as e:
self.assertTrue('This field cannot be blank.' in e.message_dict['first_name'])

def test_02_validate_last_name_presence(self):
"""validates presence of last_name"""

valid_last_name = SwimRecord(first_name='Musa', last_name='Shogunle', team_name='Coder', relay= True, stroke='Butterfly', distance=100)
try:
self.record.full_clean()
except ValidationError as e:
self.assertTrue('This field cannot be blank.' in e.message_dict['last_name'])

def test_03_validate_team_name_presence(self):
"""validates presence of team_name"""

valid_team_name = SwimRecord(first_name='Musa', last_name='Shogunle', team_name='Coder', relay= True, stroke='Butterfly', distance=100)
try:
self.record.full_clean()
except ValidationError as e:
self.assertTrue('This field cannot be blank.' in e.message_dict['team_name'])

def test_04_validate_relay_presence(self):
"""validates presence of relay"""

valid_relay = SwimRecord(first_name='Musa', last_name='Shogunle', team_name='Coder', relay= True, stroke='Butterfly', distance=100)
try:
self.record.full_clean()
except ValidationError as e:
Expand All @@ -42,7 +50,7 @@ def test_05_valid_stroke(self):
try:
stroke_record.full_clean()
except ValidationError as e:
self.assertTrue("doggie paddle is not a valid stroke" in e.message_dict['stroke'])
self.assertTrue(f"doggie paddle is not a valid stroke" in e.message_dict['stroke'])

def test_06_valid_distance(self):
"""must be greater than or equal to 50"""
Expand Down