aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tests.py36
1 files changed, 35 insertions, 1 deletions
diff --git a/tests.py b/tests.py
index 3c58558..b6b9a70 100644
--- a/tests.py
+++ b/tests.py
@@ -15,7 +15,41 @@
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
from django.test import TestCase
-from .models import Timetable, Group
+from django.utils import timezone
+
+from .models import Course, Group, Timetable
+
+
+class CourseTestCase(TestCase):
+ def setUp(self):
+ dt = timezone.now()
+
+ self.timetable = Timetable(name="Test timetable 2", url="http://example.org/", 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)
+
+ 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)
+
+ 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.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_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"]
+
+ for courses, names in ((tpa21_courses, tpa21_course_names,), (tpb21_courses, tpb21_course_names,),):
+ for course in courses:
+ self.assertIn(course.name, names)
+ names.remove(course.name)
class GroupTestCase(TestCase):