Skip to content

Commit 782e959

Browse files
committed
Dump audit table to file specified by DANDI_TESTS_AUDIT_CSV envvar
1 parent 37b6350 commit 782e959

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

dandi/tests/fixtures.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -488,6 +488,27 @@ def docker_compose_setup() -> Iterator[dict[str, str]]:
488488
raise RuntimeError("Django container did not start up in time")
489489
yield {"django_api_key": django_api_key}
490490
finally:
491+
if auditfile := os.environ.get("DANDI_TESTS_AUDIT_CSV", ""):
492+
with open(auditfile, "wb") as fp:
493+
run(
494+
[
495+
"docker",
496+
"compose",
497+
"exec",
498+
"postgres",
499+
"psql",
500+
"-U",
501+
"postgres",
502+
"-d",
503+
"django",
504+
"--csv",
505+
"-c",
506+
"SELECT * FROM api_auditrecord;",
507+
],
508+
stdout=fp,
509+
cwd=str(LOCAL_DOCKER_DIR),
510+
check=True,
511+
)
491512
if persist in (None, "0"):
492513
run(
493514
["docker", "compose", "down", "-v"],

0 commit comments

Comments
 (0)