Skip to content

Commit 06a516e

Browse files
committed
[GPCAPIM-395]: Update environment configuration for testing
- Change the Python environment file path for pytest runs - Load repository-level test environment variables for VS Code
1 parent 14b4ee1 commit 06a516e

2 files changed

Lines changed: 13 additions & 1 deletion

File tree

.vscode/settings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666
"gitlens.ai.enabled": false,
6767
"python.testing.unittestEnabled": false,
6868
"python.testing.pytestEnabled": true,
69-
"python.envFile": "${workspaceFolder}/.env.test",
69+
"python.envFile": "${workspaceFolder}/.env",
7070
"git.enableCommitSigning": true,
7171
"sonarlint.connectedMode.project": {
7272
"connectionId": "nhsdigital",

gateway-api/tests/conftest.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@
44
import os
55
from collections.abc import Callable
66
from datetime import timedelta
7+
from pathlib import Path
78
from typing import Any, cast
89

910
import pytest
1011
import requests
12+
from dotenv import load_dotenv
1113
from fhir.constants import FHIRSystem
1214

1315
DEFAULT_REQUEST_HEADERS = {
@@ -17,6 +19,16 @@
1719
}
1820

1921

22+
def _load_test_env_file() -> None:
23+
"""Load repository-level test env vars for VS Code pytest runs."""
24+
workspace_root = Path(__file__).resolve().parents[2]
25+
test_env_file = workspace_root / ".env.test"
26+
load_dotenv(dotenv_path=test_env_file, override=True)
27+
28+
29+
_load_test_env_file()
30+
31+
2032
SIMPLE_PAYLOAD = {
2133
"resourceType": "Parameters",
2234
"parameter": [

0 commit comments

Comments
 (0)