aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tests.py32
1 files changed, 25 insertions, 7 deletions
diff --git a/tests.py b/tests.py
index 89aefdb..627602c 100644
--- a/tests.py
+++ b/tests.py
@@ -21,6 +21,7 @@ from django.utils import timezone
from .management.parsers.abstractparser import ParserError
from .management.parsers.ups2018 import Parser as UPS2018Parser
from .models import Course, Group, Room, Source, Timetable, Year
+from .templatetags.rooms import format_rooms
from .utils import tz_now
import datetime
@@ -332,13 +333,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)},),
@@ -362,6 +363,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)))