Skip to content

test(api): build account, forms, comms and misc API fixtures with factories - #544

Merged
harshtandiya merged 11 commits into
refactor/test-to-factories-1from
refactor/test-to-factories-8
Oct 6, 2026
Merged

harshtandiya merged 11 commits into
refactor/test-to-factories-1from
refactor/test-to-factories-8

Conversation

@harshtandiya

Copy link
Copy Markdown
Collaborator

What changed

This is lane 7 of the test refactor. It is stacked on #540.

Files converted to factories. These files now build their fixtures with factories:

  • api/account, api/auth, api/campaigns, api/test_exceptions, api/forms, api/communications, api/maps, api/tickets
  • test_telemetry
  • test_uninstall is unchanged. It was already clean.

New factories:

  • BuzzCampaignFactory
  • TicketCancellationRequestFactory (trait accepted)
  • EventBookingRefundFactory

New support module: buzz/tests/telemetry_capture.py, with the telemetry capture helpers.

Settings: Buzz Settings changes now go through self.change_settings.

Moved to UnitTestCase:

  • test_exceptions
  • the maps link parsers
  • the telemetry entry_* / count_bucket helpers
  • TestParseExcludedFields

Split files. Every file is now under 300 lines:

Original file Split out
api/forms/test_forms.py test_custom_forms.py, test_event_proposal_form.py
api/tickets/test_tickets.py test_ticket_windows.py
test_telemetry.py test_telemetry_events.py

Tests: 175 → 160.

  • 13 tests are deleted from the plan's Delete list: the status_codes, shape and keys tests, and settings_flags_stay_integers.
  • 2 more tests are deleted because they only restated an exception's status code: unknown_language_maps_to_400 and unknown_timezone_maps_to_400.

Kept for other importers: ensure_prompt_named_record and ensure_event_host stay in api/forms/test_forms.py. 9 modules still import them. The cleanup PR deletes them.

Candidates for the cleanup PR:

  • Move the telemetry_capture helpers into buzz/tests/utils.py.
  • Add a custom_form trait to BuzzCustomFieldFactory.
  • Drop one of the two duplicate zero-cutoff tests in test_ticket_windows.

Demo

Not applicable. This PR changes only tests (skip-demo).

Testing

  • ruff 0.8.1 format and check pass.
  • py_compile passes on every changed file.
  • No get_doc({, new_doc(, date literals, test-route or cross-test imports remain, apart from the two kept helpers.
  • I could not run the test suite locally. CI runs the full suite.

🤖 Generated with Claude Code

https://claude.ai/code/session_01SWM6kF7ncqfQx9eYpBKcbm


Generated by Claude Code

claude added 6 commits October 6, 2026 13:28
…igns and errors

Move the BuzzAPIError tests to UnitTestCase and the login banner to change_settings.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SWM6kF7ncqfQx9eYpBKcbm
Map link parsers move to UnitTestCase.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SWM6kF7ncqfQx9eYpBKcbm
Custom form tests move to test_custom_forms, event proposal form tests to
test_event_proposal_form. Drop the status-code tests.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SWM6kF7ncqfQx9eYpBKcbm
Drop the details shape and plain-boolean tests.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SWM6kF7ncqfQx9eYpBKcbm
…ptures

Entry and count bucket tests move to UnitTestCase.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SWM6kF7ncqfQx9eYpBKcbm
@harshtandiya harshtandiya added the skip-demo Skip adding a video / screenshot in PR description. Passes the failing CI for demo addition label Oct 6, 2026 — with Claude

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Your trial has ended. Reactivate Greptile to resume code reviews.

The maps outsider was created after setUp switched to the team owner,
who cannot create Users. Build it in setUpClass instead.

The communications list reads User.full_name from the database, while
get_fullname caches per process and kept a name from an earlier class's
rolled-back user. Pin the sender's name and assert it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SWM6kF7ncqfQx9eYpBKcbm

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Your trial has ended. Reactivate Greptile to resume code reviews.

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Your trial has ended. Reactivate Greptile to resume code reviews.

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Your trial has ended. Reactivate Greptile to resume code reviews.

@harshtandiya
harshtandiya merged commit cee6ea9 into refactor/test-to-factories-1 Oct 6, 2026
8 checks passed
@harshtandiya
harshtandiya deleted the refactor/test-to-factories-8 branch October 6, 2026 13:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip-demo Skip adding a video / screenshot in PR description. Passes the failing CI for demo addition

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants