Skip to content

Commit 2a4af9a

Browse files
added test for checking the api key
1 parent 82a964a commit 2a4af9a

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

app/tests/conftest.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
from pathlib import Path
2+
import pytest
3+
from dotenv import load_dotenv
4+
5+
# to load env variables to an interactive session for tests to work run the export $(grep -v '^#' .env | xargs) command
6+
7+
@pytest.fixture(scope="session", autouse=True)
8+
def load_env():
9+
load_dotenv(dotenv_path=Path("../../../config/.env"))

app/tests/test_load_env.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import os
2+
3+
def test_env_loaded():
4+
ret = os.getenv("API_KEY", "")
5+
assert ret is not None, "API_KEY not loaded!"
6+
print(ret)

0 commit comments

Comments
 (0)