Files
training.django/source/advanced/various/tests/room.py
Steve Kossouho e3ebf6bf4f Add documentation and source
Added documentation, source and extra files.
2025-07-02 20:26:50 +02:00

56 lines
1.3 KiB
Python

from django import test
from various.models import Room
class RoomTestCase(test.TestCase):
"""
Basic test case for rooms.
This method is executed before every `test_` function.
To run those automatic tests, in a terminal, just run
`./manage.py test`
"""
def setUp(self) -> None:
self.room1 = Room(name="Kitchen", width=260, length=320, height=250) # basic
self.room2 = Room(name="Fake", width=0, length=320, height=250) # a 2D object
@classmethod
def setUpClass(cls):
"""Cette méthode est exécutée une seule fois avant ous les tests."""
pass
@classmethod
def tearDownClass(cls):
pass
def tearDown(self) -> None:
"""
End unit test.
Is executed after every `test_` method.
"""
def test_base_room(self):
"""
Basic test using the fixture set up in the `setUp` method.
"""
self.assertEqual(self.room2.get_volume(), 0)
self.assertEqual(self.room1.get_area(), 83200)
def test_dummy_page(self):
"""
Test the Django test client.
Used to test that pages of the projet answer properly.
"""
client = test.Client()
response = client.get("/admin/")
self.assertNotEqual(response.status_code, 404)