diff options
author | Alban Gruin | 2019-06-09 18:15:10 +0200 |
---|---|---|
committer | Alban Gruin | 2019-06-09 18:21:06 +0200 |
commit | b9f77648d0fb6897fad180627401c6b9c3e75943 (patch) | |
tree | 106a9ea66829c28f78e6044832b598f51fcdd6d4 | |
parent | 924ff4766e3d592f2bb397b0672c4b30d2549c33 (diff) |
tests: test de la détection du module correspondant à un coursag/parser
Signed-off-by: Alban Gruin <alban at pa1ch dot fr>
-rw-r--r-- | tests.py | 27 |
1 files changed, 21 insertions, 6 deletions
@@ -20,7 +20,7 @@ from django.utils import timezone from .management.parsers.abstractparser import ParserError from .management.parsers.ups2018 import Parser as UPS2018Parser -from .models import Course, Group, Room, Source, Timetable, Year +from .models import Course, Group, Module, Room, Source, Timetable, Year from .templatetags.rooms import format_rooms from .utils import tz_now @@ -414,13 +414,14 @@ class UPS2018ParserTestCase(TestCase): def test_get_event(self): get_event = self.parser._Parser__get_event count = Course.objects.count() + module_count = Module.objects.count() event = get_event( {"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", "id": "0", - "tag": []}, + "tag": ["abc", "def", "AAA"]}, timezone.make_aware(datetime.datetime(2018, 9, 21)), timezone.make_aware(datetime.datetime(2018, 9, 1)), timezone.make_aware(datetime.datetime(2018, 10, 1)), @@ -443,9 +444,13 @@ class UPS2018ParserTestCase(TestCase): datetime.datetime(2018, 9, 21, 10, 0, 0))) self.assertEqual(event.end, timezone.make_aware( datetime.datetime(2018, 9, 21, 12, 0, 0))) + self.assertEqual(event.module.name, "AAA") - self.assertEqual(count, Course.objects.count() - 1) count += 1 + module_count += 1 + + self.assertEqual(count, Course.objects.count()) + self.assertEqual(module_count, Module.objects.count()) events = [ { @@ -454,7 +459,9 @@ class UPS2018ParserTestCase(TestCase): "name": "Cours quelconque", "type": "COURS/TD", "group": self.group, "room": self.room, - "id": "1" + "id": "1", + "tag": ["aaa", "Cours"], + "meta": 1 }, { "text": "(10:00-12:00)<br>COURS/TD<br>Cours quelconque" @@ -515,7 +522,7 @@ class UPS2018ParserTestCase(TestCase): for e in events: event = get_event( {"start": "2018-09-21T10:00:00", "end": "2018-09-21T12:00:00", - "text": e["text"], "id": e["id"], "tag": []}, + "text": e["text"], "id": e["id"], "tag": e.get("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)), @@ -542,9 +549,17 @@ class UPS2018ParserTestCase(TestCase): else: self.assertIsNone(event.notes) - self.assertEqual(count, Course.objects.count() - 1) + if "tag" in e: + self.assertEqual(event.module.name, e["tag"][e["meta"]]) + module_count += 1 + else: + self.assertIsNone(event.module) + count += 1 + self.assertEqual(count, Course.objects.count()) + self.assertEqual(module_count, Module.objects.count()) + event = get_event( {"start": "2018-09-21T10:00:00", "end": "2018-09-21T12:00:00", "text": "Global Event"}, |