Write real Django unit tests for SCHA and gate merges + deploy on them passing — same pattern as company_site (also aligned with dta_service “tests before deploy”).
Today schasite/tests.py is an empty stub. Local draft workflows already mirror company_site; this ticket covers shipping meaningful tests and confirming the CI/deploy gate ends up on master.
Reference: how the other repos do it
company_site (preferred model for scha)
Workflow
Trigger
Purpose
unittests.yml (Unit Tests)
push + PR → master
uv sync + manage.py test
ci.yml
PR → master
same unit tests on PRs
deploy.yml
workflow_run after Unit Tests succeeds on master
only if conclusion == successand original event was push (not PR) → docker build + containerized tests → deploy.sh
Deploy never runs from a PR.
dta_service
PR: unit-tests.yml runs manage.py test (with coverage + PR comment).
Prod deploy (deploy-prod.yml, workflow_dispatch): job order unit-tests → docker (build + containerized tests) → deploy-prod via needs:.
Same idea: no deploy until tests pass. Prefer company_site’s automated workflow_run chain for scha.
Scope
1. Unit tests
Expand schasite/tests.py (or split into a tests/ package if it gets large). Follow company_site style: TestCase / Client, mock external side effects (Stripe, email, captcha).
Minimum coverage:
Public pages render (index, about, calendar, newsletters, dues, membership form, board, useful links)
Membership / person model helpers (address string, person accessors, etc.)
Membership form validation (happy path + required-field failures)
Auth views when DEBUG (login, signup, password reset) — authz redirects when anonymous
Stripe endpoints: config/ and create-checkout-session/ with Stripe mocked (no live API calls)
CalendarEvent date helpers (has_date, past_event, future_event, no_date)
Community post flows that already exist (create/detail/like/report) where stable enough to assert
2. CI on pull requests
Land .gitea/workflows/unittests.yml and/or ci.yml so PRs to master run uv sync --frozen + uv run python manage.py test on self-hosted
Use test-safe env (DJANGO_ENV=dev, dummy DJANGO_SECRET_KEY) — match company_site
Confirm failed tests block merge (required status / branch protection if used)
3. Tests before deploy
Land .gitea/workflows/deploy.yml so deploy only starts after Unit Tests succeeds on a push to master (workflow_run + gitea.event.workflow_run.event == 'push')
Keep docker job: build image, run containerized manage.py test against compose Postgres, then deploy.sh --app scha --env prod
Verify a failing unit-test run does not deploy
Acceptance criteria
uv run python manage.py test passes locally with non-trivial assertions (not an empty suite)
Opening a PR to master runs unit tests in Gitea Actions
Pushing to master runs unit tests; deploy runs only after success
Deploy path still includes containerized tests before deploy.sh
Notes
Draft workflows already exist in the working tree and match company_site closely; finish by adding real tests and merging the workflow files.
No need to copy dta_service coverage-comment machinery unless we want it later.
Supersedes the empty body on this issue from 2025-04.
## Summary
Write real Django unit tests for SCHA and gate merges + deploy on them passing — same pattern as [company_site](https://git.aimloperations.com/ai_ml_operations/company_site) (also aligned with [dta_service](https://git.aimloperations.com/Ditch_The_Agent/dta_service) “tests before deploy”).
Today `schasite/tests.py` is an empty stub. Local draft workflows already mirror company_site; this ticket covers shipping meaningful tests and confirming the CI/deploy gate ends up on `master`.
## Reference: how the other repos do it
### company_site (preferred model for scha)
| Workflow | Trigger | Purpose |
|----------|---------|---------|
| `unittests.yml` (`Unit Tests`) | push + PR → `master` | `uv sync` + `manage.py test` |
| `ci.yml` | PR → `master` | same unit tests on PRs |
| `deploy.yml` | `workflow_run` after **Unit Tests** succeeds on `master` | only if `conclusion == success` **and** original event was `push` (not PR) → docker build + containerized tests → `deploy.sh` |
Deploy never runs from a PR.
### dta_service
- PR: `unit-tests.yml` runs `manage.py test` (with coverage + PR comment).
- Prod deploy (`deploy-prod.yml`, `workflow_dispatch`): job order `unit-tests` → `docker` (build + containerized tests) → `deploy-prod` via `needs:`.
Same idea: no deploy until tests pass. Prefer company_site’s automated `workflow_run` chain for scha.
## Scope
### 1. Unit tests
Expand `schasite/tests.py` (or split into a `tests/` package if it gets large). Follow company_site style: `TestCase` / `Client`, mock external side effects (Stripe, email, captcha).
Minimum coverage:
- [ ] Public pages render (index, about, calendar, newsletters, dues, membership form, board, useful links)
- [ ] Membership / person model helpers (address string, person accessors, etc.)
- [ ] Membership form validation (happy path + required-field failures)
- [ ] Auth views when `DEBUG` (login, signup, password reset) — authz redirects when anonymous
- [ ] Stripe endpoints: `config/` and `create-checkout-session/` with Stripe mocked (no live API calls)
- [ ] CalendarEvent date helpers (`has_date`, `past_event`, `future_event`, `no_date`)
- [ ] Community post flows that already exist (create/detail/like/report) where stable enough to assert
### 2. CI on pull requests
- [ ] Land `.gitea/workflows/unittests.yml` and/or `ci.yml` so PRs to `master` run `uv sync --frozen` + `uv run python manage.py test` on self-hosted
- [ ] Use test-safe env (`DJANGO_ENV=dev`, dummy `DJANGO_SECRET_KEY`) — match company_site
- [ ] Confirm failed tests block merge (required status / branch protection if used)
### 3. Tests before deploy
- [ ] Land `.gitea/workflows/deploy.yml` so deploy only starts after **Unit Tests** succeeds on a **push** to `master` (`workflow_run` + `gitea.event.workflow_run.event == 'push'`)
- [ ] Keep docker job: build image, run containerized `manage.py test` against compose Postgres, then `deploy.sh --app scha --env prod`
- [ ] Verify a failing unit-test run does **not** deploy
## Acceptance criteria
- [ ] `uv run python manage.py test` passes locally with non-trivial assertions (not an empty suite)
- [ ] Opening a PR to `master` runs unit tests in Gitea Actions
- [ ] Pushing to `master` runs unit tests; deploy runs only after success
- [ ] Deploy path still includes containerized tests before `deploy.sh`
## Notes
- Draft workflows already exist in the working tree and match company_site closely; finish by adding real tests and merging the workflow files.
- No need to copy dta_service coverage-comment machinery unless we want it later.
- Supersedes the empty body on this issue from 2025-04.
westfarn
changed title from Create unittests to Create unit tests and gate PR + deploy on them2026-07-14 03:15:31 -07:00
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Summary
Write real Django unit tests for SCHA and gate merges + deploy on them passing — same pattern as company_site (also aligned with dta_service “tests before deploy”).
Today
schasite/tests.pyis an empty stub. Local draft workflows already mirror company_site; this ticket covers shipping meaningful tests and confirming the CI/deploy gate ends up onmaster.Reference: how the other repos do it
company_site (preferred model for scha)
unittests.yml(Unit Tests)masteruv sync+manage.py testci.ymlmasterdeploy.ymlworkflow_runafter Unit Tests succeeds onmasterconclusion == successand original event waspush(not PR) → docker build + containerized tests →deploy.shDeploy never runs from a PR.
dta_service
unit-tests.ymlrunsmanage.py test(with coverage + PR comment).deploy-prod.yml,workflow_dispatch): job orderunit-tests→docker(build + containerized tests) →deploy-prodvianeeds:.Same idea: no deploy until tests pass. Prefer company_site’s automated
workflow_runchain for scha.Scope
1. Unit tests
Expand
schasite/tests.py(or split into atests/package if it gets large). Follow company_site style:TestCase/Client, mock external side effects (Stripe, email, captcha).Minimum coverage:
DEBUG(login, signup, password reset) — authz redirects when anonymousconfig/andcreate-checkout-session/with Stripe mocked (no live API calls)has_date,past_event,future_event,no_date)2. CI on pull requests
.gitea/workflows/unittests.ymland/orci.ymlso PRs tomasterrunuv sync --frozen+uv run python manage.py teston self-hostedDJANGO_ENV=dev, dummyDJANGO_SECRET_KEY) — match company_site3. Tests before deploy
.gitea/workflows/deploy.ymlso deploy only starts after Unit Tests succeeds on a push tomaster(workflow_run+gitea.event.workflow_run.event == 'push')manage.py testagainst compose Postgres, thendeploy.sh --app scha --env prodAcceptance criteria
uv run python manage.py testpasses locally with non-trivial assertions (not an empty suite)masterruns unit tests in Gitea Actionsmasterruns unit tests; deploy runs only after successdeploy.shNotes
Create unitteststo Create unit tests and gate PR + deploy on them