Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dump audit table to file specified by DANDI_TESTS_AUDIT_CSV envvar #1486

Merged
merged 2 commits into from
Aug 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,17 @@ jobs:
- name: Run Dandi API tests only
if: matrix.mode == 'dandi-api'
run: |
export DANDI_TESTS_AUDIT_CSV=/tmp/audit.csv
python -m pytest -s -v --cov=dandi --cov-report=xml --dandi-api dandi
if [ ! -e /tmp/audit.csv ]
then echo Audit file not created
exit 1
fi
lines="$(wc -l /tmp/audit.csv | awk '{print $1}')"
if [ "$lines" -lt 100 ]
then echo Audit file shorter than expected - only "$lines" lines
exit 1
fi

- name: Dump Docker Compose logs
if: failure() && startsWith(matrix.os, 'ubuntu')
Expand Down
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 @@
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#L491-L493

Added lines #L491 - L493 were not covered by tests
[
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

codecov still reports this block not covered by tests -- any idea why?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that's just due to the annotations on GitHub not being updated. If I go to the Codecov site, the lines are marked covered.

"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
Loading