Skip to content

Commit

Permalink
Dump audit table to file specified by DANDI_TESTS_AUDIT_CSV envvar
Browse files Browse the repository at this point in the history
  • Loading branch information
jwodder committed Aug 14, 2024
1 parent 37b6350 commit 782e959
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions dandi/tests/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,27 @@ def docker_compose_setup() -> Iterator[dict[str, str]]:
raise RuntimeError("Django container did not start up in time")
yield {"django_api_key": django_api_key}
finally:
if auditfile := os.environ.get("DANDI_TESTS_AUDIT_CSV", ""):
with open(auditfile, "wb") as fp:
run(

Check warning on line 493 in dandi/tests/fixtures.py

View check run for this annotation

Codecov / codecov/patch

dandi/tests/fixtures.py#L492-L493

Added lines #L492 - L493 were not covered by tests
[
"docker",
"compose",
"exec",
"postgres",
"psql",
"-U",
"postgres",
"-d",
"django",
"--csv",
"-c",
"SELECT * FROM api_auditrecord;",
],
stdout=fp,
cwd=str(LOCAL_DOCKER_DIR),
check=True,
)
if persist in (None, "0"):
run(
["docker", "compose", "down", "-v"],
Expand Down

0 comments on commit 782e959

Please sign in to comment.