Skip to content

test: get pytest working with basic DB tests#45

Open
AlexCLeduc wants to merge 10 commits intomainfrom
add-testing
Open

test: get pytest working with basic DB tests#45
AlexCLeduc wants to merge 10 commits intomainfrom
add-testing

Conversation

@AlexCLeduc
Copy link
Copy Markdown

@AlexCLeduc AlexCLeduc commented Apr 22, 2026

introducing backend/tests/

if you're writing a test that need the database (most tests I think), make sure it's nested under backend/tests/with_db/ (we may combine these tests later, but I wanted to have an area people could test non-DB dependent tests easily without needing the DB infrastructure configured)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I'm surprised we've gotten this far without __init__.py modules, but they're at least required for coverage to properly index/identify files, so please add __init__.py files all around from now on

Comment thread backend/README.md
Comment on lines +525 to +534
## Running tests

From the backend/ directory,
1. `pip install -r requirements_dev.txt`
2. `pytest`

To calculate coverage,
1. `coverage run -m pytest`
2. `coverage html`
3. Open `./htmlcov/index.html` in a browser to view the report and browse around line by line
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Note testing instructions

Comment on lines +105 to +124
- name: Publish diff coverage comment
if: github.event.pull_request.base.sha != ''
continue-on-error: true
uses: edumserrano/find-create-or-update-comment@v2
with:
issue-number: ${{ github.event.pull_request.number }}
body-includes: '<!-- can-sr-diff-coverage -->'
comment-author: 'github-actions[bot]'
body-path: backend/diff-coverage-comment.md
edit-mode: replace

- name: Upload coverage artifacts
if: always()
uses: actions/upload-artifact@v4
with:
name: coverage-reports
if-no-files-found: ignore
path: |
backend/coverage.xml
backend/diff-cover.html
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Ideally, this action would add a comment on each PR listing the coverage of its diff. Unfortunately I can't easily get this working, running into permission issues I don't have time to debug.

It does hoever successfully upload an artifact you can download, but that's not much faster than checking coverage yourself locally

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant