aboutsummaryrefslogtreecommitdiff
path: root/tests.py
diff options
context:
space:
mode:
authorAlban Gruin2018-09-06 17:10:54 +0200
committerAlban Gruin2018-09-06 21:03:49 +0200
commit4b53705a15d07caa12c2ca43b00ad03a81e600bd (patch)
tree774c6a0a7f3d76be29ae8b2dfbae78680f11f022 /tests.py
parenteaed30e578f7e403a83fe0adff555e5c95654989 (diff)
groupes: ajout du support d’une nouvelle syntaxe
Certains groupes ont la syntaxe suivante : L1 4L s1 CM4L L1 4L s1 TD4L1 L1 4L s1 TP4L12 etc. Le « 4 » entre le CM/TD/TP et le « numéro » fait échouer la regex. Ce commit rajoute le support de cette syntaxe, et ajoute les cas de test adéquats. Signed-off-by: Alban Gruin <alban at pa1ch dot fr>
Diffstat (limited to 'tests.py')
-rw-r--r--tests.py33
1 files changed, 33 insertions, 0 deletions
diff --git a/tests.py b/tests.py
index c3d34fd..2568688 100644
--- a/tests.py
+++ b/tests.py
@@ -113,6 +113,11 @@ class GroupTestCase(TestCase):
Group.objects.create(celcat_name="M1 CHI-TCCM (EM) s2 TPA12",
source=self.source)
+ # Cas spécial avec un nombre supplémentaire dans le nom de groupe
+ Group.objects.create(celcat_name="L1 4L s1 CM4L", source=self.source)
+ Group.objects.create(celcat_name="L1 4L s1 TD4L1", source=self.source)
+ Group.objects.create(celcat_name="L1 4L s1 TP4L12", source=self.source)
+
def test_corresponds(self):
cma = Group.objects.get(celcat_name="L1 info s2 CMA",
source=self.source)
@@ -178,6 +183,22 @@ class GroupTestCase(TestCase):
self.assertTrue(ga111.corresponds_to(*general.group_info))
self.assertFalse(general.corresponds_to(*ga111.group_info))
+ def test_corresponds_number(self):
+ cm4l = Group.objects.get(celcat_name="L1 4L s1 CM4L",
+ source=self.source)
+ td4l1 = Group.objects.get(celcat_name="L1 4L s1 TD4L1",
+ source=self.source)
+ tp4l12 = Group.objects.get(celcat_name="L1 4L s1 TP4L12",
+ source=self.source)
+
+ self.assertFalse(cm4l.corresponds_to(*td4l1.group_info))
+ self.assertFalse(cm4l.corresponds_to(*tp4l12.group_info))
+ self.assertFalse(td4l1.corresponds_to(*tp4l12.group_info))
+
+ self.assertTrue(td4l1.corresponds_to(*cm4l.group_info))
+ self.assertTrue(tp4l12.corresponds_to(*cm4l.group_info))
+ self.assertTrue(tp4l12.corresponds_to(*td4l1.group_info))
+
def test_correspond_parenthesis(self):
general = Group.objects.get(celcat_name="M1 CHI-TCCM (EM) (toutes"
" sections et semestres confondus)")
@@ -246,6 +267,18 @@ class GroupTestCase(TestCase):
self.assertEqual(general.group_info, ("M1 GC", None, ""))
self.assertEqual(ga111.group_info, ("M1 GC", 2, "A111"))
+ def test_parse_number(self):
+ cm4l = Group.objects.get(celcat_name="L1 4L s1 CM4L",
+ source=self.source)
+ td4l1 = Group.objects.get(celcat_name="L1 4L s1 TD4L1",
+ source=self.source)
+ tp4l12 = Group.objects.get(celcat_name="L1 4L s1 TP4L12",
+ source=self.source)
+
+ self.assertEqual(cm4l.group_info, ("L1 4L", 1, "4L"))
+ self.assertEqual(td4l1.group_info, ("L1 4L", 1, "4L1"))
+ self.assertEqual(tp4l12.group_info, ("L1 4L", 1, "4L12"))
+
def test_parse_parenthesis(self):
general = Group.objects.get(celcat_name="M1 CHI-TCCM (EM) (toutes"
" sections et semestres confondus)")