Add tests for Flask views

This commit is contained in:
f4lco
2019-01-27 18:55:42 +01:00
parent e4814cf8dc
commit 523cc8ba62
5 changed files with 259 additions and 104 deletions
+13
View File
@@ -0,0 +1,13 @@
# -*- encoding: utf-8 -*-
from xml.etree import ElementTree
def meal_names(response):
"""Extract meal names from OpenMensa XML.
By no means below parsing is robust or complete. Below just helps ensuring that the parser indeed returns proper XML
instead of arbitrary responses."""
root = ElementTree.fromstring(response)
namespace = {'om': 'http://openmensa.org/open-mensa-v2'}
nodes = root.findall('om:canteen/om:day/om:category/om:meal/om:name', namespace)
return [node.text for node in nodes]