From 8edc5a0cedbb9eea461226abbee2ac2fb899eca47e1a7bc506899792ff05fbba Mon Sep 17 00:00:00 2001 From: f4lco Date: Fri, 7 Jun 2019 11:22:40 +0200 Subject: [PATCH] Set retrieval test result to XFAIL on invalid JSON (#6) This increases build stability - in case we did not receive valid JSON in the retrieval test, we cannot exercise the parser at all. Disadvantage: if the endpoint stops returning JSON, we will never know. --- tests/test_retrieval.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tests/test_retrieval.py b/tests/test_retrieval.py index ae22cf9..1ca8790 100644 --- a/tests/test_retrieval.py +++ b/tests/test_retrieval.py @@ -37,5 +37,12 @@ requires_online_api = pytest.mark.skipif( def test_retrieval(canteen): feed.render_meta(canteen, "/canteens/{}/menu".format(canteen.key)) params = MenuParams(canteen_id=canteen.id, chash=canteen.chash) - menu = download_menu(params) + + try: + menu = download_menu(params) + except ValueError as e: + if e.message == 'No JSON object could be decoded': + pytest.xfail('JSON endpoint returned garbage (issue #6)') + raise e + feed.render_menu(menu)