aboutsummaryrefslogtreecommitdiff
path: root/tests.py
diff options
context:
space:
mode:
authorAlban Gruin2018-09-20 23:57:21 +0200
committerAlban Gruin2018-09-21 00:18:04 +0200
commitaba3214efa86d3631bd74b81be56b60e92de265f (patch)
treec2addf9c1a7ef8f08ad0fbb55404517d69116ea9 /tests.py
parent3dc64cf994737910f70c47cd772d60101f7f84dc (diff)
tests: test du tag format_roomsdev/alban
Signed-off-by: Alban Gruin <alban at pa1ch dot fr>
Diffstat (limited to 'tests.py')
-rw-r--r--tests.py32
1 files changed, 25 insertions, 7 deletions
diff --git a/tests.py b/tests.py
index 2568688..fe29232 100644
--- a/tests.py
+++ b/tests.py
@@ -17,6 +17,7 @@ from django.test import TestCase
from django.utils import timezone
from .models import Course, Group, Room, Source, Timetable, Year
+from .templatetags.rooms import format_rooms
from .utils import tz_now
import datetime
@@ -300,13 +301,13 @@ class RoomTestCase(TestCase):
group = Group.objects.create(celcat_name="L1 info s2 CMA",
source=self.source)
- self.rooms = [Room.objects.create(name="0"),
- Room.objects.create(name="1"),
- Room.objects.create(name="2"),
- Room.objects.create(name="3"),
- Room.objects.create(name="4"),
- Room.objects.create(name="5"),
- Room.objects.create(name="6")]
+ self.rooms = [
+ Room.objects.create(name=str(i))
+ for i in range(5)
+ ] + [
+ Room.objects.create(name="Amphi {}".format(i))
+ for i in range(5, 7)
+ ]
hours = [({"begin": datetime.time(hour=14, minute=0)},),
({"begin": datetime.time(hour=16, minute=0)},),
@@ -330,6 +331,23 @@ class RoomTestCase(TestCase):
course.groups.add(group)
course.rooms.add(room)
+ def test_format(self):
+ amphis = self.rooms[-2:]
+
+ self.assertEqual(format_rooms([]), "")
+ self.assertEqual(format_rooms(self.rooms[:1]), "Salle 0")
+ self.assertEqual(format_rooms(self.rooms[:2]), "Salles 0, 1")
+ self.assertEqual(format_rooms([amphis[0]]), "Amphi 5")
+ self.assertEqual(format_rooms(amphis), "Amphi 5, Amphi 6")
+ self.assertEqual(format_rooms([amphis[0]] + self.rooms[:1]),
+ "Amphi 5, salle 0")
+ self.assertEqual(format_rooms([amphis[0]] + self.rooms[:2]),
+ "Amphi 5, salles 0, 1")
+ self.assertEqual(format_rooms(amphis + self.rooms[:1]),
+ "Amphi 5, Amphi 6, salle 0")
+ self.assertEqual(format_rooms(amphis + self.rooms[:2]),
+ "Amphi 5, Amphi 6, salles 0, 1")
+
def test_qsjps(self):
begin = timezone.make_aware(datetime.datetime.combine(
self.day, datetime.time(hour=15, minute=0)))