Skip to content

Commit 718e219

Browse files
committed
fix environment variable mismatch
1 parent ebeab88 commit 718e219

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

pyproject.toml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ datajoint = "datajoint.cli:cli"
8282
test = [
8383
"pytest",
8484
"pytest-cov",
85+
"pytest-env",
8586
"docker",
8687
"requests",
8788
]
@@ -107,3 +108,15 @@ package-dir = {"" = "src"}
107108

108109
[tool.setuptools.dynamic]
109110
version = { attr = "datajoint.version.__version__"}
111+
112+
[tool.pytest_env]
113+
# Default values - pytest fixtures will override with actual container details
114+
DJ_USER="root"
115+
DJ_PASS="password"
116+
DJ_TEST_USER="datajoint"
117+
DJ_TEST_PASSWORD="datajoint"
118+
S3_ACCESS_KEY="datajoint"
119+
S3_SECRET_KEY="datajoint"
120+
S3_BUCKET="datajoint.test"
121+
PYTHON_USER="dja"
122+
JUPYTER_PASSWORD="datajoint"

tests/conftest.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,14 @@ def enable_filepath_feature(monkeypatch):
298298
@pytest.fixture(scope="session")
299299
def db_creds_test(mysql_container) -> Dict:
300300
_, host, port = mysql_container
301+
# Set environment variables for DataJoint at module level
302+
os.environ["DJ_TEST_HOST"] = host
303+
os.environ["DJ_TEST_PORT"] = str(port)
304+
305+
# Also update DataJoint's test configuration directly
306+
dj.config["database.test.host"] = host
307+
dj.config["database.test.port"] = port
308+
301309
return dict(
302310
host=f"{host}:{port}",
303311
user=os.getenv("DJ_TEST_USER", "datajoint"),
@@ -308,6 +316,14 @@ def db_creds_test(mysql_container) -> Dict:
308316
@pytest.fixture(scope="session")
309317
def db_creds_root(mysql_container) -> Dict:
310318
_, host, port = mysql_container
319+
# Set environment variables for DataJoint at module level
320+
os.environ["DJ_HOST"] = host
321+
os.environ["DJ_PORT"] = str(port)
322+
323+
# Also update DataJoint's configuration directly
324+
dj.config["database.host"] = host
325+
dj.config["database.port"] = port
326+
311327
return dict(
312328
host=f"{host}:{port}",
313329
user=os.getenv("DJ_USER", "root"),
@@ -434,6 +450,8 @@ def connection_test(connection_root, prefix, db_creds_test):
434450
@pytest.fixture(scope="session")
435451
def s3_creds(minio_container) -> Dict:
436452
_, host, port = minio_container
453+
# Set environment variable for S3 endpoint at module level
454+
os.environ["S3_ENDPOINT"] = f"{host}:{port}"
437455
return dict(
438456
endpoint=f"{host}:{port}",
439457
access_key=os.environ.get("S3_ACCESS_KEY", "datajoint"),

0 commit comments

Comments
 (0)