aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorAlban Gruin2018-09-23 16:40:14 +0200
committerAlban Gruin2018-12-31 12:14:03 +0100
commit0bafcacdad912a598cdf4e031cab5059efb30b18 (patch)
tree86dfafc35de34942fea53bcc3d3dc0d1dd8bad54 /tests
parent171472d7dc42e2d3b390ad8b052c7e88fca21722 (diff)
tests: ajout de tests pour le parseur UPS2018
Le parseur est une des parties les plus importantes de celcatsanitizer, mais ni le parseur 2017, ni le parseur 2018 n’ont eu de test unitaires à proprement parler. Jusqu’ici, pour tester ce composant, on ajoutait une source dans la base, on la récupérait, et on regardait si tout correspondait plus ou moins. Cette technique a plusieurs inconvénients : c’était une tâche rébarbative et pas systématiquement effectuée, ce qui a posé quelques problèmes par le passé, certains cas pouvaient ne pas se trouver dans la source au moment de la récupération, et ce n’était pas reproductible proprement. Rajouter des tests permettra donc de tester efficacement le parseur, avec tous les cas de figure, rapidement et en utilisant seulement des ressources locales. Pour éviter d’utiliser le réseau, le module requests est mocké lorsqu’on teste des fonctions qui l’utilisent. L’initialisation du parseur et ses fonctions __get_event(), get_events(), get_source() et get_update_date() (ainsi que la fonction find_events_list() de manière indirecte) sont testées. Signed-off-by: Alban Gruin <alban at pa1ch dot fr>
Diffstat (limited to 'tests')
-rw-r--r--tests/data/2018/october.html50
-rw-r--r--tests/data/2018/september.html51
2 files changed, 101 insertions, 0 deletions
diff --git a/tests/data/2018/october.html b/tests/data/2018/october.html
new file mode 100644
index 0000000..6f326f9
--- /dev/null
+++ b/tests/data/2018/october.html
@@ -0,0 +1,50 @@
+<script>
+function do_something() {
+alert("something");
+}
+</script>
+
+ <option value="August, 2017">August, 2017</option>
+ <option value="September, 2017">September, 2017</option>
+ <option value="October, 2017">October, 2017</option>
+ <option value="November, 2017">November, 2017</option>
+ <option value="December, 2017">December, 2017</option>
+ <option value="January, 2018">January, 2018</option>
+ <option value="February, 2018">February, 2018</option>
+ <option value="March, 2018">March, 2018</option>
+ <option value="April, 2018">April, 2018</option>
+ <option value="May, 2018">May, 2018</option>
+ <option value="June, 2018">June, 2018</option>
+ <option value="July, 2018">July, 2018</option>
+ <option value="August, 2018">August, 2018</option>
+ <option value="September, 2018">September, 2018</option>
+ <option selected="selected" value="October, 2018">October, 2018</option>
+ <option value="November, 2018">November, 2018</option>
+ <option value="December, 2018">December, 2018</option>
+ <option value="January, 2019">January, 2019</option>
+ <option value="February, 2019">February, 2019</option>
+ <option value="March, 2019">March, 2019</option>
+ <option value="April, 2019">April, 2019</option>
+ <option value="May, 2019">May, 2019</option>
+ <option value="June, 2019">June, 2019</option>
+ <option value="July, 2019">July, 2019</option>
+
+<script>
+function do_something_else() {
+var v = "a variable";
+var vv = "another_variable";
+do_something();
+}
+</script>
+
+<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"}];;
+}
+</script>
+
+<script>
+courses();
+do_something_else();
+</script>
diff --git a/tests/data/2018/september.html b/tests/data/2018/september.html
new file mode 100644
index 0000000..3db6cbc
--- /dev/null
+++ b/tests/data/2018/september.html
@@ -0,0 +1,51 @@
+<script>
+function do_something() {
+alert("something");
+}
+</script>
+
+ <option value="August, 2017">August, 2017</option>
+ <option value="September, 2017">September, 2017</option>
+ <option value="October, 2017">October, 2017</option>
+ <option value="November, 2017">November, 2017</option>
+ <option value="December, 2017">December, 2017</option>
+ <option value="January, 2018">January, 2018</option>
+ <option value="February, 2018">February, 2018</option>
+ <option value="March, 2018">March, 2018</option>
+ <option value="April, 2018">April, 2018</option>
+ <option value="May, 2018">May, 2018</option>
+ <option value="June, 2018">June, 2018</option>
+ <option value="July, 2018">July, 2018</option>
+ <option value="August, 2018">August, 2018</option>
+ <option selected="selected" value="September, 2018">September, 2018</option>
+ <option value="October, 2018">October, 2018</option>
+ <option value="November, 2018">November, 2018</option>
+ <option value="December, 2018">December, 2018</option>
+ <option value="January, 2019">January, 2019</option>
+ <option value="February, 2019">February, 2019</option>
+ <option value="March, 2019">March, 2019</option>
+ <option value="April, 2019">April, 2019</option>
+ <option value="May, 2019">May, 2019</option>
+ <option value="June, 2019">June, 2019</option>
+ <option value="July, 2019">July, 2019</option>
+
+<script>
+ function do_something_else() {
+ var v = "a variable";
+ var vv = "another_variable";
+
+ do_something();
+ }
+</script>
+
+<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"}];;
+}
+</script>
+
+<script>
+courses();
+do_something_else();
+</script>