aboutsummaryrefslogtreecommitdiff
path: root/tests.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests.py')
-rw-r--r--tests.py29
1 files changed, 29 insertions, 0 deletions
diff --git a/tests.py b/tests.py
index 1425a84..38c0ed8 100644
--- a/tests.py
+++ b/tests.py
@@ -71,6 +71,16 @@ class GroupTestCase(TestCase):
Group.objects.create(celcat_name="L1 info (toutes sections et semestres confondus)", timetable=self.timetable)
+ # Cas spéciaux de groupes sans semestre. Normalement un groupe
+ # sans semestre ne possède pas de sous-groupe non plus, mais
+ # certains cas font foirer la regex. Voici un exemple trouvé
+ # dans la base de données de production.
+ Group.objects.create(celcat_name="M1 GC (toutes sections et semestres "
+ "confondus)", timetable=self.timetable)
+
+ # Doit appartenir au groupe au-dessus.
+ Group.objects.create(celcat_name="M1 GC s2 GA111", timetable=self.timetable)
+
def test_corresponds(self):
cma = Group.objects.get(celcat_name="L1 info s2 CMA", timetable=self.timetable)
tda2 = Group.objects.get(celcat_name="L1 info s2 TDA2", timetable=self.timetable)
@@ -120,6 +130,15 @@ class GroupTestCase(TestCase):
self.assertTrue(tpa21.corresponds_to(*general.group_info))
self.assertTrue(tpb21.corresponds_to(*general.group_info))
+ def test_corresponds_no_semester(self):
+ general = Group.objects.get(celcat_name="M1 GC (toutes sections et "
+ "semestres confondus)", timetable=self.timetable)
+ ga111 = Group.objects.get(celcat_name="M1 GC s2 GA111",
+ timetable=self.timetable)
+
+ self.assertTrue(ga111.corresponds_to(*general.group_info))
+ self.assertFalse(general.corresponds_to(*ga111.group_info))
+
def test_get(self):
cma = Group.objects.get(name="L1 info s2 CMA", timetable=self.timetable)
tda2 = Group.objects.get(name="L1 info s2 TDA2", timetable=self.timetable)
@@ -161,3 +180,13 @@ class GroupTestCase(TestCase):
self.assertEqual(tpb21.group_info, ("L1 info", 2, "B21"))
self.assertEqual(general.group_info, ("L1 info", None, ""))
+
+ def test_parse_no_semester(self):
+ general = Group.objects.get(celcat_name="M1 GC (toutes sections et "
+ "semestres confondus)", timetable=self.timetable)
+ ga111 = Group.objects.get(celcat_name="M1 GC s2 GA111",
+ timetable=self.timetable)
+
+ self.assertEqual(general.group_info, ("M1 GC", None, ""))
+ self.assertEqual(ga111.group_info, ("M1 GC", 2, "A111"))
+