From 5d7eb5c4cb3b4ae9a72003c1b2db5ffb51e4d135ed6d3c12228bf1332055de90 Mon Sep 17 00:00:00 2001 From: f4lco Date: Thu, 23 Apr 2020 13:07:44 +0200 Subject: [PATCH] Fix str/unicode inconsistencies (#7) --- stw_potsdam/feed.py | 5 ++--- tests/test_views.py | 4 ++-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/stw_potsdam/feed.py b/stw_potsdam/feed.py index 35e1acf..93e49b9 100644 --- a/stw_potsdam/feed.py +++ b/stw_potsdam/feed.py @@ -33,9 +33,8 @@ def _prices(offer): price = offer[api_role] # When no price is set, this can be empty dict - if isinstance(price, (unicode, str)) and price.strip(): - # Convert unicode to str for PyOpenMensa -> misses type check - result[role] = str(price) + if isinstance(price, str) and price.strip(): + result[role] = price return result diff --git a/tests/test_views.py b/tests/test_views.py index 955a1b9..65d9588 100644 --- a/tests/test_views.py +++ b/tests/test_views.py @@ -17,7 +17,7 @@ from tests.stub_api import api_offline, api_online_one_shot def test_health_check(client): response = client.get('/health_check') assert response.status_code == 200 - assert response.data == 'OK' + assert response.data == b'OK' def test_index(client): @@ -36,7 +36,7 @@ def test_index(client): def test_canteen_not_found(client, url): response = client.get(url) assert response.status_code == 404 - assert "Canteen 'spam' not found" in response.data + assert b"Canteen 'spam' not found" in response.data @pytest.mark.xfail(strict=True)