mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-06-30 13:10:47 +00:00
changes pytest config
This commit is contained in:
parent
6af6ba4656
commit
cf55aac64b
1 changed files with 26 additions and 29 deletions
55
conftest.py
55
conftest.py
|
|
@ -1,34 +1,31 @@
|
||||||
# conftest.py
|
|
||||||
import os
|
import os
|
||||||
import pytest
|
|
||||||
from backend.app.config import get_settings
|
from backend.app.config import get_settings
|
||||||
|
|
||||||
|
DEFAULT_ENV = {
|
||||||
|
"API_KEY": "test",
|
||||||
|
"SECRET_KEY": "test",
|
||||||
|
"ENVIRONMENT": "test",
|
||||||
|
"DATA_BUCKET": "test",
|
||||||
|
"PLAN_TRIGGER_BUCKET": "test",
|
||||||
|
"ENGINE_SQS_URL": "test",
|
||||||
|
"EPC_AUTH_TOKEN": "test", # overridden in GitHub Actions
|
||||||
|
"GOOGLE_SOLAR_API_KEY": "test",
|
||||||
|
"DB_HOST": "localhost",
|
||||||
|
"DB_USERNAME": "test",
|
||||||
|
"DB_PASSWORD": "test",
|
||||||
|
"DB_PORT": "5432",
|
||||||
|
"DB_NAME": "test",
|
||||||
|
"SAP_PREDICTIONS_BUCKET": "test",
|
||||||
|
"CARBON_PREDICTIONS_BUCKET": "test",
|
||||||
|
"HEAT_PREDICTIONS_BUCKET": "test",
|
||||||
|
"HEATING_KWH_PREDICTIONS_BUCKET": "test",
|
||||||
|
"HOTWATER_KWH_PREDICTIONS_BUCKET": "test",
|
||||||
|
"ENERGY_ASSESSMENTS_BUCKET": "test",
|
||||||
|
}
|
||||||
|
|
||||||
@pytest.fixture(autouse=True, scope="session")
|
# runs immediately when pytest starts, BEFORE collection
|
||||||
def fake_env():
|
for k, v in DEFAULT_ENV.items():
|
||||||
vars = {
|
os.environ.setdefault(k, v)
|
||||||
"API_KEY": "test",
|
|
||||||
"SECRET_KEY": "test",
|
|
||||||
"ENVIRONMENT": "test",
|
|
||||||
"DATA_BUCKET": "test",
|
|
||||||
"PLAN_TRIGGER_BUCKET": "test",
|
|
||||||
"ENGINE_SQS_URL": "test",
|
|
||||||
"EPC_AUTH_TOKEN": "test", # Will be overwritten in CI/CD
|
|
||||||
"GOOGLE_SOLAR_API_KEY": "test",
|
|
||||||
"DB_HOST": "localhost",
|
|
||||||
"DB_USERNAME": "test",
|
|
||||||
"DB_PASSWORD": "test",
|
|
||||||
"DB_PORT": "5432",
|
|
||||||
"DB_NAME": "test",
|
|
||||||
"SAP_PREDICTIONS_BUCKET": "test",
|
|
||||||
"CARBON_PREDICTIONS_BUCKET": "test",
|
|
||||||
"HEAT_PREDICTIONS_BUCKET": "test",
|
|
||||||
"HEATING_KWH_PREDICTIONS_BUCKET": "test",
|
|
||||||
"HOTWATER_KWH_PREDICTIONS_BUCKET": "test",
|
|
||||||
"ENERGY_ASSESSMENTS_BUCKET": "test",
|
|
||||||
}
|
|
||||||
|
|
||||||
for k, v in vars.items():
|
# clear cached settings AFTER env is final
|
||||||
os.environ.setdefault(k, v)
|
get_settings.cache_clear()
|
||||||
|
|
||||||
get_settings.cache_clear()
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue