From: Gustav Eek Date: Sun, 10 Sep 2017 15:12:10 +0000 (+0200) Subject: Update to python api test and stations requests X-Git-Url: https://git.g-eek.se/?a=commitdiff_plain;h=863322d0af11227f23d27dea0107938a7f11c51d;p=eti2-trainhack-2017.git Update to python api test and stations requests --- diff --git a/apitest/tests/a-test.py b/apitest/tests/a-test.py index a5f99a0..71d0aad 100644 --- a/apitest/tests/a-test.py +++ b/apitest/tests/a-test.py @@ -3,7 +3,6 @@ import xml.etree.ElementTree as ET import re - tree = ET.parse('respons.xml') response = root = tree.getroot() @@ -28,3 +27,7 @@ for c in n: print c.tag, c.attrib, len(c), c.text station_names = [n[0].text for n in result] + +p = re.compile('.*B.*') +matching_station_names = [n[0].text for n in result if p.match(n[0].text)] +print matching_station_names diff --git a/stations.py b/stations.py index 130d3b3..2d0954e 100644 --- a/stations.py +++ b/stations.py @@ -25,7 +25,7 @@ def get_train_stations (): """ conn = httplib.HTTPConnection(BASE_URL, PORT) - conn.request("POST", "", xml_request, HEADERS) + conn.request("POST", BASE_URL, xml_request, HEADERS) response = conn.getresponse() print response.status, response.reason # 303 Found xml_data = response.read()