From 1bffc87074162097e2f30840127311d2230de2d8 Mon Sep 17 00:00:00 2001 From: peterdudfield Date: Fri, 20 Dec 2024 08:35:37 +0000 Subject: [PATCH] split national tests --- src/tests/fake/test_national.py | 40 +++++++++++++++++++++++++++++++++ src/tests/test_national.py | 37 ------------------------------ 2 files changed, 40 insertions(+), 37 deletions(-) create mode 100644 src/tests/fake/test_national.py diff --git a/src/tests/fake/test_national.py b/src/tests/fake/test_national.py new file mode 100644 index 0000000..a468a90 --- /dev/null +++ b/src/tests/fake/test_national.py @@ -0,0 +1,40 @@ +""" Test for main app """ + +from national import is_fake +from pydantic_models import NationalForecastValue + + +def test_is_fake_national_all_available_forecasts(monkeypatch, api_client): + """Test FAKE environment for all GSPs are populating + with fake data. + """ + + monkeypatch.setenv("FAKE", "1") + assert is_fake() == 1 + # Connect to DB endpoint + response = api_client.get("/v0/solar/GB/national/forecast") + assert response.status_code == 200 + + national_forecast_values = [NationalForecastValue(**f) for f in response.json()] + assert national_forecast_values is not None + + # Disable is_fake environment + monkeypatch.setenv("FAKE", "0") + + +def test_is_fake_national_get_truths_for_all_gsps(monkeypatch, api_client): + """Test FAKE environment for all GSPs for yesterday and today + are populating with fake data. + """ + + monkeypatch.setenv("FAKE", "1") + assert is_fake() == 1 + # Connect to DB endpoint + response = api_client.get("/v0/solar/GB/national/pvlive/") + assert response.status_code == 200 + + national_forecast_values = [NationalForecastValue(**f) for f in response.json()] + assert national_forecast_values is not None + + # Disable is_fake environment + monkeypatch.setenv("FAKE", "0") diff --git a/src/tests/test_national.py b/src/tests/test_national.py index 2db1554..583083b 100644 --- a/src/tests/test_national.py +++ b/src/tests/test_national.py @@ -12,7 +12,6 @@ from database import get_session from main import app -from national import is_fake from pydantic_models import NationalForecast, NationalForecastValue @@ -257,39 +256,3 @@ def test_read_truth_national_gsp(db_session, api_client): r_json = response.json() assert len(r_json) == 3 _ = [GSPYield(**gsp_yield) for gsp_yield in r_json] - - -def test_is_fake_national_all_available_forecasts(monkeypatch, api_client): - """Test FAKE environment for all GSPs are populating - with fake data. - """ - - monkeypatch.setenv("FAKE", "1") - assert is_fake() == 1 - # Connect to DB endpoint - response = api_client.get("/v0/solar/GB/national/forecast") - assert response.status_code == 200 - - national_forecast_values = [NationalForecastValue(**f) for f in response.json()] - assert national_forecast_values is not None - - # Disable is_fake environment - monkeypatch.setenv("FAKE", "0") - - -def test_is_fake_national_get_truths_for_all_gsps(monkeypatch, api_client): - """Test FAKE environment for all GSPs for yesterday and today - are populating with fake data. - """ - - monkeypatch.setenv("FAKE", "1") - assert is_fake() == 1 - # Connect to DB endpoint - response = api_client.get("/v0/solar/GB/national/pvlive/") - assert response.status_code == 200 - - national_forecast_values = [NationalForecastValue(**f) for f in response.json()] - assert national_forecast_values is not None - - # Disable is_fake environment - monkeypatch.setenv("FAKE", "0")