test: stop the trial-end POST tests expiring with the calendar #674

Merged
tobru merged 1 commit from fix/trial-end-post-tests into main 2026-09-16 18:30:36 +00:00
Member

Summary

Three staff view tests have failed on main, and on every PR, since 2026-09-11:

  • test_trial_end_post_writes_to_odoo
  • test_trial_end_post_rejected_when_portal_manages_window
  • test_trial_end_post_reports_odoo_failure

Each creates its organization at test time and posts a fixed trial end of 2026-09-10. OrganizationTrialEndForm only accepts dates from the organization's creation day onward, so once that date was in the past the form refused it: no Odoo write happened (0 writes instead of 1), a second error message appeared, and the failure message was never rendered.

The product code is correct. The tests expired with the calendar.

Fix

A helper pins the organization's created_at to the fixture sale order's trial start (2026-06-01) in the three tests. The fixed date then stays valid permanently: the lower bound is fixed, and the upper bound moves forward with today. Keeping the date fixed, rather than relative to today, also keeps the expected Odoo value (2026-09-10 23:59:59) in summer time, so the tests cannot start failing at a daylight saving change either.

I checked the rest of the suite for other tests posting a fixed trial end: there are none.

Testing

  • The three tests failed before the change and pass after.
  • src/tests/test_staff_views.py: 131 passed.
  • Full suite on this branch: 2052 passed.

This unblocks CI on PR 673 (Plausible attribution), which inherited the failures from main.

Design Decisions

  • Pin created_at instead of adding a time-freezing library: the project has no freezegun or time-machine, and only the organization's age matters to the form. The file already backdates created_at with a queryset update (_backdate), which also avoids firing the trial-window signals.
  • Fixed date, not one relative to today: a relative date would move the expected Odoo value across daylight saving changes and swap one time bomb for another.
  • Separate PR from the attribution work: the failures are on main and unrelated to that change.

🤖 Generated with Claude Code

https://claude.ai/code/session_014S5eLBkR9DQyhYAG11hBZw

## Summary Three staff view tests have failed on `main`, and on every PR, since 2026-09-11: - `test_trial_end_post_writes_to_odoo` - `test_trial_end_post_rejected_when_portal_manages_window` - `test_trial_end_post_reports_odoo_failure` Each creates its organization at test time and posts a fixed trial end of `2026-09-10`. `OrganizationTrialEndForm` only accepts dates from the organization's creation day onward, so once that date was in the past the form refused it: no Odoo write happened (0 writes instead of 1), a second error message appeared, and the failure message was never rendered. The product code is correct. The tests expired with the calendar. ## Fix A helper pins the organization's `created_at` to the fixture sale order's trial start (2026-06-01) in the three tests. The fixed date then stays valid permanently: the lower bound is fixed, and the upper bound moves forward with today. Keeping the date fixed, rather than relative to today, also keeps the expected Odoo value (`2026-09-10 23:59:59`) in summer time, so the tests cannot start failing at a daylight saving change either. I checked the rest of the suite for other tests posting a fixed trial end: there are none. ## Testing - The three tests failed before the change and pass after. - `src/tests/test_staff_views.py`: 131 passed. - Full suite on this branch: 2052 passed. This unblocks CI on PR 673 (Plausible attribution), which inherited the failures from `main`. ## Design Decisions - **Pin `created_at` instead of adding a time-freezing library**: the project has no freezegun or time-machine, and only the organization's age matters to the form. The file already backdates `created_at` with a queryset update (`_backdate`), which also avoids firing the trial-window signals. - **Fixed date, not one relative to today**: a relative date would move the expected Odoo value across daylight saving changes and swap one time bomb for another. - **Separate PR from the attribution work**: the failures are on `main` and unrelated to that change. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_014S5eLBkR9DQyhYAG11hBZw
test: stop the trial-end POST tests expiring with the calendar
All checks were successful
Tests / test (push) Successful in 1m42s
400774124d
The three tests posted a fixed trial end of 2026-09-10 for an organization
created at test time. The form's earliest valid date is the organization's
creation day, so from 2026-09-11 the posted date fell before it: the form
refused it, no Odoo write happened and a second error message appeared.
They have failed on main, and on every PR, since then.

Pin created_at to the fixture sale order's trial start instead. The fixed
date then stays valid for good, since the upper bound moves forward with
today, and the expected Odoo value keeps its summer-time offset.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014S5eLBkR9DQyhYAG11hBZw
tobru merged commit 3bf35775aa into main 2026-09-16 18:30:36 +00:00
tobru deleted branch fix/trial-end-post-tests 2026-09-16 18:30:36 +00:00
Sign in to join this conversation.
No description provided.