Skip to content

Commit afcd52e

Browse files
[CDAPI-18]: Added support for using a .env file for local testing
1 parent d7b78fd commit afcd52e

File tree

6 files changed

+23
-5
lines changed

6 files changed

+23
-5
lines changed

.github/workflows/stage-2-test.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: "Test stage"
22

33
env:
44
BASE_URL: "http://localhost:5001"
5-
HOSTNAME: "localhost"
5+
HOST: "localhost"
66

77
on:
88
workflow_call:

pathology-api/poetry.lock

Lines changed: 15 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pathology-api/pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ dev = [
4949
"schemathesis>=4.4.1",
5050
"types-requests (>=2.32.4.20250913,<3.0.0.0)",
5151
"types-pyyaml (>=6.0.12.20250915,<7.0.0.0)",
52+
"python-dotenv (>=1.2.1,<2.0.0)",
5253
]
5354

5455
[tool.mypy]

pathology-api/tests/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ tests/
2828
> When running tests the following environment variables need to be provided:
2929
>
3030
> - `BASE_URL` - defines the protocol, hostname and port that should used to access the running APIs. Should be included as a URL in the format <protocol>:<hostname>:<port>, for example "<http://localhost:5000>" if the APIs are available on the "localhost" host via HTTP using port 5000.
31-
> - `HOSTNAME` - defines the hostname that should be used to access the running APIs. This should match the host portion of the URL provided in the `BASE_URL` environment variable above.
31+
> - `HOST` - defines the hostname that should be used to access the running APIs. This should match the host portion of the URL provided in the `BASE_URL` environment variable above.
3232
3333
### Install Dependencies (if not using Dev container)
3434

pathology-api/tests/conftest.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77

88
import pytest
99
import requests
10+
from dotenv import load_dotenv
11+
12+
load_dotenv()
1013

1114

1215
class Client:
@@ -59,7 +62,7 @@ def base_url() -> str:
5962
@pytest.fixture(scope="module")
6063
def hostname() -> str:
6164
"""Retrieves the hostname of the currently deployed application."""
62-
return _fetch_env_variable("HOSTNAME", str)
65+
return _fetch_env_variable("HOST", str)
6366

6467

6568
def _fetch_env_variable[T](name: str, t: type[T]) -> T:

scripts/tests/test.mk

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,15 +61,14 @@ test: # Run all the test tasks @Testing
6161
make \
6262
test-unit \
6363
test-lint \
64-
test-coverage \
6564
test-contract \
6665
test-security \
6766
test-ui \
6867
test-ui-performance \
6968
test-integration \
7069
test-accessibility \
7170
test-load \
72-
test-acceptance\
71+
test-acceptance \
7372
test-schema
7473

7574
_test:

0 commit comments

Comments
 (0)