Created
July 9, 2021 21:03
-
-
Save godfather68/707ac8d6b36cc1bf621d33a6219b4a02 to your computer and use it in GitHub Desktop.
Testing Models
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.test import TestCase | |
from django.contrib.auth import get_user_model | |
from core import models | |
class ModelTests(TestCase): | |
def test_house_title_str(self): | |
"""Test the House string representation""" | |
house = models.House.objects.create( | |
name='2 rooms appartment downtown Toronto' | |
) | |
self.assertEqual(str(house), house.name) | |
def test_no_of_rooms_less_than_or_equal_to_five(self): | |
"""Test that the no of rooms options is <= to 5""" | |
option1 = models.Options.objects.create(no_of_rooms = 5) | |
option2 = models.Options.objects.create(no_of_rooms = 6) | |
self.assertLessEqual(option1.no_of_rooms, 5) | |
self.assertNotEqual(option2.no_of_rooms, 5) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment