aboutsummaryrefslogtreecommitdiff
path: root/tests.py
diff options
context:
space:
mode:
authorAlban Gruin2018-01-18 13:26:37 +0100
committerAlban Gruin2018-01-18 13:26:37 +0100
commit3a5e355f92881597c22a434ea300175a624586ea (patch)
tree145cdefb474e04e56e0ed2c4fdeaf8058ac37375 /tests.py
parent175e1c1139a77a02f3c52d77a4d2b118c2b2e578 (diff)
Adaptation des tests à la nouvelle structure de la base de données
Diffstat (limited to 'tests.py')
-rw-r--r--tests.py86
1 files changed, 46 insertions, 40 deletions
diff --git a/tests.py b/tests.py
index 1425a84..ac6bdaf 100644
--- a/tests.py
+++ b/tests.py
@@ -14,7 +14,7 @@
# along with celcatsanitizer. If not, see <http://www.gnu.org/licenses/>.
from django.test import TestCase
-from .models import Course, Group, Timetable, Year
+from .models import Course, Group, Source, Timetable, Year
from .utils import tz_now
@@ -25,24 +25,27 @@ class CourseTestCase(TestCase):
self.year = Year(name="L2", slug="l2")
self.year.save()
- self.timetable = Timetable(year=self.year, name="Test timetable 2", url="http://example.org/", slug="test-timetable2")
+ source = Source(url="http://example.org/")
+ source.save()
+
+ self.timetable = Timetable(year=self.year, name="Test timetable 2", source=source, slug="test-timetable2")
self.timetable.save()
- cma = Group.objects.create(celcat_name="L1 info s2 CMA", timetable=self.timetable)
- tda2 = Group.objects.create(celcat_name="L1 info s2 TDA2", timetable=self.timetable)
- self.tpa21 = Group.objects.create(celcat_name="L1 info s2 TPA21", timetable=self.timetable)
+ cma = Group.objects.create(celcat_name="L1 info s2 CMA", source=source)
+ tda2 = Group.objects.create(celcat_name="L1 info s2 TDA2", source=source)
+ self.tpa21 = Group.objects.create(celcat_name="L1 info s2 TPA21", source=source)
- cmb = Group.objects.create(celcat_name="L1 info s2 CMB", timetable=self.timetable)
- tdb2 = Group.objects.create(celcat_name="L1 info s2 TDB2", timetable=self.timetable)
- self.tpb21 = Group.objects.create(celcat_name="L1 info s2 TPB21", timetable=self.timetable)
+ cmb = Group.objects.create(celcat_name="L1 info s2 CMB", source=source)
+ tdb2 = Group.objects.create(celcat_name="L1 info s2 TDB2", source=source)
+ self.tpb21 = Group.objects.create(celcat_name="L1 info s2 TPB21", source=source)
for group in (cma, tda2, self.tpa21, cmb, tdb2, self.tpb21,):
- course = Course.objects.create(name="{0} course".format(group.name), type="cours", timetable=self.timetable, begin=dt, end=dt)
+ course = Course.objects.create(name="{0} course".format(group.name), type="cours", source=source, begin=dt, end=dt)
course.groups.add(group)
def test_get_courses_for_group(self):
- tpa21_courses = Course.objects.get_courses_for_group(self.tpa21)
- tpb21_courses = Course.objects.get_courses_for_group(self.tpb21)
+ tpa21_courses = Course.objects.get_courses(self.tpa21)
+ tpb21_courses = Course.objects.get_courses(self.tpb21)
tpa21_course_names = ["L1 info s2 CMA course", "L1 info s2 TDA2 course", "L1 info s2 TPA21 course"]
tpb21_course_names = ["L1 info s2 CMB course", "L1 info s2 TDB2 course", "L1 info s2 TPB21 course"]
@@ -58,29 +61,32 @@ class GroupTestCase(TestCase):
self.year = Year(name="L1", slug="l1")
self.year.save()
- self.timetable = Timetable(year=self.year, name="Test timetable", url="http://example.com/", slug="test-timetable")
+ self.source = Source(url="http://example.org/")
+ self.source.save()
+
+ self.timetable = Timetable(year=self.year, name="Test timetable", source=self.source, slug="test-timetable")
self.timetable.save()
- Group.objects.create(celcat_name="L1 info s2 CMA", timetable=self.timetable)
- Group.objects.create(celcat_name="L1 info s2 TDA2", timetable=self.timetable)
- Group.objects.create(celcat_name="L1 info s2 TPA21", timetable=self.timetable)
+ Group.objects.create(celcat_name="L1 info s2 CMA", source=self.source)
+ Group.objects.create(celcat_name="L1 info s2 TDA2", source=self.source)
+ Group.objects.create(celcat_name="L1 info s2 TPA21", source=self.source)
- Group.objects.create(celcat_name="L1 info s2 CMB", timetable=self.timetable)
- Group.objects.create(celcat_name="L1 info s2 TDB2", timetable=self.timetable)
- Group.objects.create(celcat_name="L1 info s2 TPB21", timetable=self.timetable)
+ Group.objects.create(celcat_name="L1 info s2 CMB", source=self.source)
+ Group.objects.create(celcat_name="L1 info s2 TDB2", source=self.source)
+ Group.objects.create(celcat_name="L1 info s2 TPB21", source=self.source)
- Group.objects.create(celcat_name="L1 info (toutes sections et semestres confondus)", timetable=self.timetable)
+ Group.objects.create(celcat_name="L1 info (toutes sections et semestres confondus)", source=self.source)
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)
- tpa21 = Group.objects.get(celcat_name="L1 info s2 TPA21", timetable=self.timetable)
+ cma = Group.objects.get(celcat_name="L1 info s2 CMA", source=self.source)
+ tda2 = Group.objects.get(celcat_name="L1 info s2 TDA2", source=self.source)
+ tpa21 = Group.objects.get(celcat_name="L1 info s2 TPA21", source=self.source)
- cmb = Group.objects.get(celcat_name="L1 info s2 CMB", timetable=self.timetable)
- 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)
+ cmb = Group.objects.get(celcat_name="L1 info s2 CMB", source=self.source)
+ tdb2 = Group.objects.get(celcat_name="L1 info s2 TDB2", source=self.source)
+ tpb21 = Group.objects.get(celcat_name="L1 info s2 TPB21", source=self.source)
- general = Group.objects.get(celcat_name="L1 info (toutes sections et semestres confondus)", timetable=self.timetable)
+ general = Group.objects.get(celcat_name="L1 info (toutes sections et semestres confondus)", source=self.source)
self.assertFalse(cma.corresponds_to(*tda2.group_info))
self.assertFalse(cma.corresponds_to(*tpa21.group_info))
@@ -121,15 +127,15 @@ class GroupTestCase(TestCase):
self.assertTrue(tpb21.corresponds_to(*general.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)
- tpa21 = Group.objects.get(name="L1 info s2 TPA21", timetable=self.timetable)
+ cma = Group.objects.get(name="L1 info s2 CMA", source=self.source)
+ tda2 = Group.objects.get(name="L1 info s2 TDA2", source=self.source)
+ tpa21 = Group.objects.get(name="L1 info s2 TPA21", source=self.source)
- cmb = Group.objects.get(name="L1 info s2 CMB", timetable=self.timetable)
- tdb2 = Group.objects.get(name="L1 info s2 TDB2", timetable=self.timetable)
- tpb21 = Group.objects.get(name="L1 info s2 TPB21", timetable=self.timetable)
+ cmb = Group.objects.get(name="L1 info s2 CMB", source=self.source)
+ tdb2 = Group.objects.get(name="L1 info s2 TDB2", source=self.source)
+ tpb21 = Group.objects.get(name="L1 info s2 TPB21", source=self.source)
- general = Group.objects.get(celcat_name="L1 info (toutes sections et semestres confondus)", timetable=self.timetable)
+ general = Group.objects.get(celcat_name="L1 info (toutes sections et semestres confondus)", source=self.source)
self.assertEqual(cma.celcat_name, "L1 info s2 CMA")
self.assertEqual(tda2.celcat_name, "L1 info s2 TDA2")
@@ -142,15 +148,15 @@ class GroupTestCase(TestCase):
self.assertEqual(general.celcat_name, "L1 info (toutes sections et semestres confondus)")
def test_parse(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)
- tpa21 = Group.objects.get(celcat_name="L1 info s2 TPA21", timetable=self.timetable)
+ cma = Group.objects.get(celcat_name="L1 info s2 CMA", source=self.source)
+ tda2 = Group.objects.get(celcat_name="L1 info s2 TDA2", source=self.source)
+ tpa21 = Group.objects.get(celcat_name="L1 info s2 TPA21", source=self.source)
- cmb = Group.objects.get(celcat_name="L1 info s2 CMB", timetable=self.timetable)
- 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)
+ cmb = Group.objects.get(celcat_name="L1 info s2 CMB", source=self.source)
+ tdb2 = Group.objects.get(celcat_name="L1 info s2 TDB2", source=self.source)
+ tpb21 = Group.objects.get(celcat_name="L1 info s2 TPB21", source=self.source)
- general = Group.objects.get(celcat_name="L1 info (toutes sections et semestres confondus)", timetable=self.timetable)
+ general = Group.objects.get(celcat_name="L1 info (toutes sections et semestres confondus)", source=self.source)
self.assertEqual(cma.group_info, ("L1 info", 2, "A"))
self.assertEqual(tda2.group_info, ("L1 info", 2, "A2"))