diff options
-rw-r--r-- | models.py | 11 | ||||
-rw-r--r-- | tests.py | 12 |
2 files changed, 13 insertions, 10 deletions
@@ -97,12 +97,15 @@ class Group(models.Model): hidden = models.BooleanField(verbose_name="caché", default=False) - def corresponds_to(self, timetable_id, mention, subgroup, td, tp): + def corresponds_to(self, timetable_id, mention, subgroup): + subgroup_corresponds = True + if self.subgroup is not None and subgroup is not None: + subgroup_corresponds = subgroup.startswith(self.subgroup) or \ + self.subgroup.startswith(subgroup) + return self.timetable.id == timetable_id and \ self.mention.startswith(mention) and \ - (self.subgroup == subgroup or self.subgroup is None) and \ - (self.td == td or self.td is None or td is None) and \ - (self.tp == tp or self.tp is None or tp is None) + subgroup_corresponds @property def group_info(self): @@ -128,10 +128,10 @@ class GroupTestCase(TestCase): tdb2 = Group.objects.get(celcat_name="L1 info s2 TDB2", timetable=self.timetable) tpb21 = Group.objects.get(celcat_name="L1 info s2 TPB21", timetable=self.timetable) - self.assertEqual(cma.group_info, (self.timetable.id, "L1 info s2", "A", None, None)) - self.assertEqual(tda2.group_info, (self.timetable.id, "L1 info s2", "A", 2, None)) - self.assertEqual(tpa21.group_info, (self.timetable.id, "L1 info s2", "A", 2, 1)) + self.assertEqual(cma.group_info, (self.timetable.id, "L1 info", "A")) + self.assertEqual(tda2.group_info, (self.timetable.id, "L1 info", "A2")) + self.assertEqual(tpa21.group_info, (self.timetable.id, "L1 info", "A21")) - self.assertEqual(cmb.group_info, (self.timetable.id, "L1 info s2", "B", None, None)) - self.assertEqual(tdb2.group_info, (self.timetable.id, "L1 info s2", "B", 2, None)) - self.assertEqual(tpb21.group_info, (self.timetable.id, "L1 info s2", "B", 2, 1)) + self.assertEqual(cmb.group_info, (self.timetable.id, "L1 info", "B")) + self.assertEqual(tdb2.group_info, (self.timetable.id, "L1 info", "B2")) + self.assertEqual(tpb21.group_info, (self.timetable.id, "L1 info", "B21")) |