From 079e405942e29127b31a57d1b3c742e3bcdbcbb8 Mon Sep 17 00:00:00 2001 From: paulmart-n Date: Tue, 4 Jun 2024 10:28:34 +0200 Subject: [PATCH] Suppress Cron when testing --- fetchMENSA.py | 5 +++-- fetchRAPLA.py | 5 +++-- tests_examples/test_app.py | 7 +++++-- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/fetchMENSA.py b/fetchMENSA.py index 7a5960a..c893700 100644 --- a/fetchMENSA.py +++ b/fetchMENSA.py @@ -146,5 +146,6 @@ def mensaSchedule(): """ Nutzt vormittags die Funktion refreshMeals(), um die Essen zu aktualisieren """ - with flaskApp.app_context(): - asyncio.run(refreshMeals()) + if not flaskApp.config["TESTING"]: + with flaskApp.app_context(): + asyncio.run(refreshMeals()) diff --git a/fetchRAPLA.py b/fetchRAPLA.py index f4915e8..e7c2348 100644 --- a/fetchRAPLA.py +++ b/fetchRAPLA.py @@ -171,8 +171,9 @@ def raplaSchedule(): """ Nutzt alle 3 Minuten refreshRapla() um die Stundenpläne zu aktualisieren. """ - with flaskApp.app_context(): - asyncio.run(refreshRapla()) + if not flaskApp.config["TESTING"]: + with flaskApp.app_context(): + asyncio.run(refreshRapla()) async def buildICALfromKey(url, onlyUpdate, testing=False): diff --git a/tests_examples/test_app.py b/tests_examples/test_app.py index 8fb91fe..52076f1 100644 --- a/tests_examples/test_app.py +++ b/tests_examples/test_app.py @@ -157,9 +157,12 @@ async def test_url_anweisung_whitebox(app): :param app: """ with app.app_context(): - rapla = await fetchRAPLA.getNewRapla("http://www.rapla.dhbw-karlsruhe.de/rapla?page=calendar&user=vollmer" + raplaPage = await fetchRAPLA.getNewRapla("http://www.rapla.dhbw-karlsruhe.de/rapla?page=calendar&user=vollmer" "&file=tinf22b3", True) - assert "TINF22B3" in rapla + assert "TINF22B3" in raplaPage + raplaFile = await fetchRAPLA.getNewRapla("http://www.rapla.dhbw-karlsruhe.de/rapla?page=ical&user=vollmer" + "&file=tinf22b3", True) + assert "TINF22B3" in raplaFile @pytest.mark.asyncio()