diff options
-rw-r--r-- | tests.py | 54 | ||||
-rw-r--r-- | tests/data/2018/october.html | 2 | ||||
-rw-r--r-- | tests/data/2018/september.html | 2 |
3 files changed, 40 insertions, 18 deletions
@@ -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): diff --git a/tests/data/2018/october.html b/tests/data/2018/october.html index 6f326f9..ab3da0b 100644 --- a/tests/data/2018/october.html +++ b/tests/data/2018/october.html @@ -40,7 +40,7 @@ do_something(); <script> function courses() { var v = {}; -v.events.list = [{"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"}, {"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"}];; +v.events.list = [{"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", "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", "id": "2", "tag": []}];; } </script> diff --git a/tests/data/2018/september.html b/tests/data/2018/september.html index 3db6cbc..c81fc3b 100644 --- a/tests/data/2018/september.html +++ b/tests/data/2018/september.html @@ -41,7 +41,7 @@ alert("something"); <script> function courses() { var v = {}; -v.events.list = [{"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"}];; +v.events.list = [{"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", "id": "0", "tag": []}];; } </script> |