reimplemented openMensaFeedv2 and fixed linting

This commit is contained in:
Hadrian Burkhardt
2023-12-03 02:51:47 +01:00
committed by f4lco
parent 9e37940334
commit d637d71c8f
16 changed files with 632 additions and 598 deletions
+2 -2
View File
@@ -3,7 +3,7 @@ import os
import httpretty
import pytest
from stw_potsdam.swp_webspeiseplan_api import SWP_Webspeiseplan_API
from stw_potsdam.swp_webspeiseplan_api import SWPWebspeiseplanAPI
@pytest.fixture
@@ -35,7 +35,7 @@ def api_online_one_shot():
]
httpretty.register_uri(httpretty.POST,
SWP_Webspeiseplan_API.URL_BASE,
SWPWebspeiseplanAPI.URL_BASE,
responses=responses)
httpretty.enable(allow_net_connect=False)
+21 -21
View File
@@ -29,44 +29,44 @@ def _read_feed(resource_name):
@pytest.mark.xfail(strict=True)
def test_meta_consistency():
raise NotImplementedError()
canteen = _canteen()
menu_feed_url = f"canteens/{canteen.key}/xml"
actual = feed.render_meta(canteen, menu_feed_url)
expected = _read_feed('meta_output.xml')
assert expected == actual
# canteen = _canteen()
# menu_feed_url = f"canteens/{canteen.key}/xml"
# actual = feed.render_meta(canteen, menu_feed_url)
# expected = _read_feed('meta_output.xml')
# assert expected == actual
@pytest.mark.xfail(strict=True)
def test_menu_consistency():
raise NotImplementedError()
menu = _read_menu('input.json')
actual = feed.render_menu(menu)
expected = _read_feed('menu_output.xml')
assert expected == actual
# menu = _read_menu('input.json')
# actual = feed.render_menu(menu)
# expected = _read_feed('menu_output.xml')
# assert expected == actual
@pytest.mark.xfail(strict=True)
def test_empty_menu():
raise NotImplementedError()
menu = _read_menu('empty.json')
actual = feed.render_menu(menu)
expected = _read_feed('empty_menu_output.xml')
assert expected == actual
# menu = _read_menu('empty.json')
# actual = feed.render_menu(menu)
# expected = _read_feed('empty_menu_output.xml')
# assert expected == actual
@pytest.mark.xfail(strict=True)
def test_offers_dictionary():
raise NotImplementedError()
menu = _read_menu('offers-dict.json')
actual = feed.render_menu(menu)
expected = _read_feed('offers-dict-output.xml')
assert expected == actual
# menu = _read_menu('offers-dict.json')
# actual = feed.render_menu(menu)
# expected = _read_feed('offers-dict-output.xml')
# assert expected == actual
@pytest.mark.xfail(strict=True)
def test_missing_category():
raise NotImplementedError()
menu = _read_menu('missing-category.json')
actual = feed.render_menu(menu)
expected = _read_feed('missing-category-output.xml')
assert expected == actual
# menu = _read_menu('missing-category.json')
# actual = feed.render_menu(menu)
# expected = _read_feed('missing-category-output.xml')
# assert expected == actual
+3 -3
View File
@@ -4,9 +4,8 @@ import json
import logging
import os
import pytest
from stw_potsdam.config import read_canteen_config
from stw_potsdam.views import canteen_xml_feed
from stw_potsdam.views import canteen_xml_feed, app
# pragma pylint: disable=invalid-name,redefined-outer-name
@@ -38,7 +37,8 @@ requires_online_api = pytest.mark.skipif(
@requires_online_api
def test_retrieval(canteen):
try:
canteen_xml_feed(canteen.key)
with app.app_context(), app.test_request_context():
canteen_xml_feed(canteen.key)
except json.JSONDecodeError as e:
pytest.xfail('JSON endpoint returned garbage (issue #6)')
raise e # Appease PyCharm inspection - xfail always raises
+7 -10
View File
@@ -2,9 +2,6 @@
import pytest
from stw_potsdam import views
from flask import url_for
from tests.response_util import meal_names
# pytest fixtures are linked via parameter names of test methods
# pragma pylint: disable=unused-import,redefined-outer-name,unused-argument
@@ -52,14 +49,14 @@ def test_canteen_menu_api_unavailable(client, api_offline):
@pytest.mark.xfail(strict=True)
def test_canteen_menu_request(client, api_online_one_shot):
raise NotImplementedError()
_request_check_meals(client)
# _request_check_meals(client)
@pytest.mark.xfail(strict=True)
def test_canteen_menu_cached(client, api_online_one_shot):
raise NotImplementedError()
_request_check_meals(client)
_request_check_meals(client)
# _request_check_meals(client)
# _request_check_meals(client)
@pytest.mark.xfail(strict=True)
@@ -72,10 +69,10 @@ def test_canteen_menu_second_request_indeed_fails(client, api_online_one_shot):
@pytest.mark.xfail(strict=True)
def _request_check_meals(client):
raise NotImplementedError()
response = client.get("/canteens/griebnitzsee/xml")
assert response.status_code == 200
meal = meal_names(response.data)[0]
print(meal)
# response = client.get("/canteens/griebnitzsee/xml")
# assert response.status_code == 200
# meal = meal_names(response.data)[0]
# print(meal)
# assert meal == "Gefüllter Germknödel \nmit Vanillesauce und Mohnzucker"