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

Feat: initial testing setup #41

Merged
merged 5 commits into from
Dec 10, 2024
Merged

Feat: initial testing setup #41

merged 5 commits into from
Dec 10, 2024

Conversation

lalver1
Copy link
Member

@lalver1 lalver1 commented Dec 9, 2024

Closes #6

This PR

  • adds test dependencies
  • configures VS Code for pytest
  • creates a test file and a test that requests a /healthcheck endpoint from the app and asserts a 200 response code and "Healthy" response text. The endpoint is implemented as Django middleware.
  • create a GitHub Actions workflow to run pytests on push and pull_request, upload coverage report, comment w/coverage report

The Pytest workflow is failing probably due to a pending python-coverage-comment-action-data branch.

@lalver1 lalver1 self-assigned this Dec 9, 2024
pyproject.toml Outdated Show resolved Hide resolved
tests/pytest/__init__.py Outdated Show resolved Hide resolved
@thekaveman
Copy link
Member

thekaveman commented Dec 10, 2024

The Pytest workflow is failing probably due to a pending python-coverage-comment-action-data branch.

This is probably related to GitHub Actions permissions somehow...

I feel like it should be able to create that branch? I can't remember what we did in the past, but I'm pretty sure I never created the branch by hand. The docs say

GitHub Actions will create this branch with initial data at the first run if it doesn't exist, and will independently commit to that branch after each commit to your default branch.

There's also this note in the docs: https://github.com/py-cov-action/python-coverage-comment-action?tab=readme-ov-file#setup

Please ensure that your .coverage file(s) is created with the option relative_files = true.

Copy link

github-actions bot commented Dec 10, 2024

Coverage report

Click to see where and how coverage changed

FileStatementsMissingCoverageCoverage
(new stmts)
Lines missing
  pems/core
  middleware.py 19
Project Total  

This report was generated by python-coverage-comment-action

@lalver1
Copy link
Member Author

lalver1 commented Dec 10, 2024

Ah, I had forgotten to configure coverage in pyproject.toml, looks like the GitHub Actions workflow runs now 😅

implements the healthcheck as a middleware before the HOST_HEADER verification (in django.middleware.common.CommonMiddleware), so healthcheck requests always pass

based on https://stackoverflow.com/a/64623669
- sets Python version for GitHub workflows
- adds workflow and shell script that runs pytest
this is needed since we don't want to allow unit tests to go out to the internet
@lalver1 lalver1 marked this pull request as ready for review December 10, 2024 16:36
@lalver1 lalver1 requested a review from a team as a code owner December 10, 2024 16:36
Copy link
Member

@thekaveman thekaveman left a comment

Choose a reason for hiding this comment

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

Looks great! I was able to run the tests locally in the devcontainer too.

@lalver1 lalver1 merged commit 8a70f2e into main Dec 10, 2024
8 checks passed
@lalver1 lalver1 deleted the feat/testing-setup branch December 10, 2024 16:59
@thekaveman thekaveman added this to the Initial project setup milestone Dec 10, 2024
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.

Initial testing setup
2 participants