aboutsummaryrefslogtreecommitdiff
path: root/tests.py
diff options
context:
space:
mode:
authorAlban Gruin2019-02-13 22:39:19 +0100
committerAlban Gruin2019-06-09 18:21:06 +0200
commit924ff4766e3d592f2bb397b0672c4b30d2549c33 (patch)
tree5e6e2ea47f1426d3005090f567d64e763d593f30 /tests.py
parent297632390e6ec051e315e6d9545d0110a41a8880 (diff)
tests: test du parsage des ID de cours Celcat
Signed-off-by: Alban Gruin <alban at pa1ch dot fr>
Diffstat (limited to 'tests.py')
-rw-r--r--tests.py54
1 files changed, 38 insertions, 16 deletions
diff --git a/tests.py b/tests.py
index 627602c..e3b2310 100644
--- a/tests.py
+++ b/tests.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2017-2018 Alban Gruin
+# Copyright (C) 2017-2019 Alban Gruin
#
# celcatsanitizer is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published
@@ -84,7 +84,7 @@ class CourseTestCase(TestCase):
for group in (cma, tda2, self.tpa21, cmb, tdb2, self.tpb21,):
course = Course.objects.create(
name="{0} course".format(group.name), type="cours",
- source=source, begin=dt, end=dt)
+ source=source, begin=dt, end=dt, celcat_id=0)
course.groups.add(group)
def test_get_courses_for_group(self):
@@ -359,7 +359,8 @@ class RoomTestCase(TestCase):
end = begin + datetime.timedelta(hours=rn.get("duration", 2))
course = Course.objects.create(source=self.source,
- begin=begin, end=end)
+ begin=begin, end=end,
+ celcat_id=0)
course.groups.add(group)
course.rooms.add(room)
@@ -418,7 +419,8 @@ class UPS2018ParserTestCase(TestCase):
{"start": "2018-09-21T10:00:00", "end": "2018-09-21T12:00:00",
"text": "(10:00-12:00)<br>COURS/TD<br>Cours quelconque;AAA"
"<br>L3 Info s1 CMA;L3 Info s1 TDA2<br>"
- "Salle quelconque;Salle quelconque 2<br>Commentaire"},
+ "Salle quelconque;Salle quelconque 2<br>Commentaire", "id": "0",
+ "tag": []},
timezone.make_aware(datetime.datetime(2018, 9, 21)),
timezone.make_aware(datetime.datetime(2018, 9, 1)),
timezone.make_aware(datetime.datetime(2018, 10, 1)),
@@ -436,6 +438,7 @@ class UPS2018ParserTestCase(TestCase):
self.assertIn(self.room2, event.rooms.all())
self.assertEqual(event.rooms.count(), 2)
self.assertEqual(event.notes, "Commentaire")
+ self.assertEqual(event.celcat_id, 0)
self.assertEqual(event.begin, timezone.make_aware(
datetime.datetime(2018, 9, 21, 10, 0, 0)))
self.assertEqual(event.end, timezone.make_aware(
@@ -451,6 +454,7 @@ class UPS2018ParserTestCase(TestCase):
"name": "Cours quelconque", "type": "COURS/TD",
"group": self.group,
"room": self.room,
+ "id": "1"
},
{
"text": "(10:00-12:00)<br>COURS/TD<br>Cours quelconque"
@@ -458,7 +462,8 @@ class UPS2018ParserTestCase(TestCase):
"name": "Cours quelconque",
"type": "COURS/TD",
"group": ngroup,
- "notes": "Salle quelconque 3"
+ "notes": "Salle quelconque 3",
+ "id": "2"
},
{
"text": "(10:00-12:00)<br>COURS/TD<br>Cours quelconque"
@@ -467,44 +472,50 @@ class UPS2018ParserTestCase(TestCase):
"type": "COURS/TD",
"group": self.group,
"notes": "Salle quelconque 3\nCommentaire",
+ "id": "3"
},
{
"text": "(10:00-12:00)<br>COURS/TD"
"<br>L3 Info s1 CMA<br>Salle quelconque 3",
"name": "COURS/TD",
"group": self.group,
- "notes": "Salle quelconque 3"
+ "notes": "Salle quelconque 3",
+ "id": "4"
},
{
"text": "COURS/TD<br>L3 Info s1 CMA<br>Salle quelconque 3",
"name": "COURS/TD",
"group": self.group,
- "notes": "Salle quelconque 3"
+ "notes": "Salle quelconque 3",
+ "id": "5"
},
{
"text": "L3 Info s1 CMA<br>Salle quelconque",
"name": "Sans nom",
"group": self.group,
- "room": self.room
+ "room": self.room,
+ "id": "6"
},
{
"text": "L3 Info s1 CMA<br>Salle quelconque 3",
"name": "Sans nom",
"group": self.group,
- "notes": "Salle quelconque 3"
+ "notes": "Salle quelconque 3",
+ "id": "7"
},
{
"text": "(10:00-12:00)<br>L3 Info s1 CMA<br>Salle quelconque",
"name": "Sans nom",
"group": self.group,
- "room": self.room
+ "room": self.room,
+ "id": "8"
}
]
for e in events:
event = get_event(
{"start": "2018-09-21T10:00:00", "end": "2018-09-21T12:00:00",
- "text": e["text"]},
+ "text": e["text"], "id": e["id"], "tag": []},
timezone.make_aware(datetime.datetime(2018, 9, 21)),
timezone.make_aware(datetime.datetime(2018, 9, 1)),
timezone.make_aware(datetime.datetime(2018, 10, 1)),
@@ -513,6 +524,7 @@ class UPS2018ParserTestCase(TestCase):
self.assertEqual(event.name, e["name"])
self.assertIn(e["group"], event.groups.all())
self.assertEqual(event.groups.count(), 1)
+ self.assertEqual(str(event.celcat_id), e["id"])
if "type" in e:
self.assertEqual(event.type, e["type"])
@@ -560,11 +572,13 @@ class UPS2018ParserTestCase(TestCase):
{"begin":
timezone.make_aware(datetime.datetime(2018, 9, 21, 10, 00, 00)),
"end":
- timezone.make_aware(datetime.datetime(2018, 9, 21, 12, 00, 00))},
+ timezone.make_aware(datetime.datetime(2018, 9, 21, 12, 00, 00)),
+ "id": 0},
{"begin":
timezone.make_aware(datetime.datetime(2018, 10, 22, 10, 00, 00)),
"end":
- timezone.make_aware(datetime.datetime(2018, 10, 22, 12, 00, 00))}
+ timezone.make_aware(datetime.datetime(2018, 10, 22, 12, 00, 00)),
+ "id": 2}
]
for i, course in enumerate(self.parser.get_events(
@@ -578,6 +592,8 @@ class UPS2018ParserTestCase(TestCase):
self.assertIsNone(course.notes)
self.assertEqual(course.begin, courses[i]["begin"])
self.assertEqual(course.end, courses[i]["end"])
+ self.assertEqual(course.celcat_id, courses[i]["id"])
+ self.assertEqual(course.module, None)
self.assertEqual(i, len(courses) - 1)
@@ -588,15 +604,21 @@ class UPS2018ParserTestCase(TestCase):
[{
"start": "2018-09-21T10:00:00", "end": "2018-09-21T12:00:00",
"text": "(10:00-12:00)<br>COURS/TD<br>Cours quelconque"
- "<br>L3 Info s1 CMA<br>Salle quelconque"
+ "<br>L3 Info s1 CMA<br>Salle quelconque",
+ "id": "0",
+ "tag": [],
}], [{
"start": "2018-09-21T10:00:00", "end": "2018-09-21T12:00:00",
"text": "(10:00-12:00)<br>COURS/TD<br>Cours quelconque"
- "<br>L3 Info s1 CMA<br>Salle quelconque"
+ "<br>L3 Info s1 CMA<br>Salle quelconque",
+ "id": "1",
+ "tag": [],
}, {
"start": "2018-10-22T10:00:00", "end": "2018-10-22T12:00:00",
"text": "(10:00-12:00)<br>COURS/TD<br>Cours quelconque"
- "<br>L3 Info s1 CMA<br>Salle quelconque"
+ "<br>L3 Info s1 CMA<br>Salle quelconque",
+ "id": "2",
+ "tag": [],
}], [], [], [], [], [], [], [], [], []])
def test_get_update_date(self):