Repository navigation
test: build every backend test fixture with factories - #540
Conversation
Group factories into core, events, ticketing and proposals packages. The package index still re-exports every factory. Add EventBookingFactory, EventTicketFactory, BuzzTeamMembershipFactory, EventVenueFactory, SponsorshipTierFactory, TalkProposalFactory, EmailTemplateFactory, PaymentGatewayFactory and FileFactory. Add the unpublished, in_person and with_tax traits on BuzzEventFactory and the unpublished trait on EventTicketTypeFactory. Rename BuzzTeamFactory.set_feature to set_settings, which takes a dict. test_factories smoke-tests each factory and trait. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SWM6kF7ncqfQx9eYpBKcbm
buzz/tests/utils.py holds clear_map_link_cache and the email queue readers. buzz/tests/base_test_cases.py holds BookingTestCase and SponsorshipTestCase. The old modules import them back. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SWM6kF7ncqfQx9eYpBKcbm
Tracer for the test refactor: factories, set_settings and the set_user context manager in one module. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SWM6kF7ncqfQx9eYpBKcbm
There was a problem hiding this comment.
Your trial has ended. Reactivate Greptile to resume code reviews.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SWM6kF7ncqfQx9eYpBKcbm
There was a problem hiding this comment.
Your trial has ended. Reactivate Greptile to resume code reviews.
frappe.set_user outside a test_*.py file trips the frappe-setuser semgrep rule. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SWM6kF7ncqfQx9eYpBKcbm
There was a problem hiding this comment.
Your trial has ended. Reactivate Greptile to resume code reviews.
Read the list from factories.__all__, so a new factory is covered without a second list to keep in sync. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SWM6kF7ncqfQx9eYpBKcbm
There was a problem hiding this comment.
Your trial has ended. Reactivate Greptile to resume code reviews.
Buzz Event names are autoincrement integers in memory, and the whitelisted methods type-check event as str. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SWM6kF7ncqfQx9eYpBKcbm
There was a problem hiding this comment.
Your trial has ended. Reactivate Greptile to resume code reviews.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SWM6kF7ncqfQx9eYpBKcbm
Split into discount, free-ticket, scope and validity modules that share CouponTestCase. Drop buzz_coupon_code_auto_generated. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SWM6kF7ncqfQx9eYpBKcbm
Zoom sessions come from the event's own create_*_on_zoom methods. Drop make_qr_image_returns_png_bytes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SWM6kF7ncqfQx9eYpBKcbm
Drop the private-helper and empty-list tests; the column tests now cover disabled custom fields, disabled add-ons and distinct UTM names. Merge the two execute_returns_empty tests. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SWM6kF7ncqfQx9eYpBKcbm
Lane-owned factories for the booking refund tests. EventPayment's received trait gives each payment a unique gateway id, since refund webhooks look the payment up by it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SWM6kF7ncqfQx9eYpBKcbm
test_event_booking.py splits into totals, offline, emails and confirmation files; it keeps ticket availability, process_booking and the Zoom last-name tests. test_event_booking_refund.py keeps refund requests and the refund ceiling; webhook and sync tests move to test_refund_sync.py. Both share BookingRefundTestCase in refund_test_case.py. Every class builds its own event instead of reading test-route. Drops the UTM child-table persistence tests, tax_exclusive_still_works and tax_inclusive_with_single_ticket, which repeat total_calculation_with_taxes and tax_inclusive_calculation. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SWM6kF7ncqfQx9eYpBKcbm
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SWM6kF7ncqfQx9eYpBKcbm
…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
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SWM6kF7ncqfQx9eYpBKcbm
Drop name_is_a_bteam_series: it restates the doctype's naming series. The exported helpers stay until the cleanup PR. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SWM6kF7ncqfQx9eYpBKcbm
test(ticketing): build coupon, ticket and report fixtures with factories
test(events): build events doctype fixtures with factories and split by behaviour
test(teams): build team and permission fixtures with factories and split by behaviour
There was a problem hiding this comment.
Your trial has ended. Reactivate Greptile to resume code reviews.
test(events): build event API and public page fixtures with factories
test(proposals): build proposal and sponsorship fixtures with factories
There was a problem hiding this comment.
Your trial has ended. Reactivate Greptile to resume code reviews.
There was a problem hiding this comment.
Your trial has ended. Reactivate Greptile to resume code reviews.
test(api): build account, forms, comms and misc API fixtures with factories
There was a problem hiding this comment.
Your trial has ended. Reactivate Greptile to resume code reviews.
There was a problem hiding this comment.
Your trial has ended. Reactivate Greptile to resume code reviews.
There was a problem hiding this comment.
Your trial has ended. Reactivate Greptile to resume code reviews.
CouponTestCase and BookingRefundTestCase move into base_test_cases.py, and the telemetry capture helpers into utils.py. They were separate modules only because the parallel lanes could not edit shared files. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SWM6kF7ncqfQx9eYpBKcbm
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SWM6kF7ncqfQx9eYpBKcbm
Replaces three copies of a guest-proposal helper in the proposal tests, and the two base classes that only held it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SWM6kF7ncqfQx9eYpBKcbm
… team No test reads the shared test-route event, Test Venue, Test Host or Test Category any more; each test class builds its own fixtures. Administrator keeps one team, because Event Template and event proposal submissions fill team from the user's only membership. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SWM6kF7ncqfQx9eYpBKcbm
…stCase The role-matrix, tenant-isolation and ticket-access files each built the same two teams and events and repeated the same helpers. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SWM6kF7ncqfQx9eYpBKcbm
Factories live in subpackages and are imported from the package. Shared base classes and helpers have fixed homes. Adds the traps CI found during the refactor: integer event names, the get_fullname cache, and the set_user semgrep rule. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SWM6kF7ncqfQx9eYpBKcbm
There was a problem hiding this comment.
Your trial has ended. Reactivate Greptile to resume code reviews.
Backend test coverage: 91%Commit 2749fbc. Test modules are excluded. Coverage by file
88 empty files skipped. |
User Invitation mails on insert, and CI has no outgoing email account, so the newly exported UserInvitationFactory failed its default create. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SWM6kF7ncqfQx9eYpBKcbm
There was a problem hiding this comment.
Your trial has ended. Reactivate Greptile to resume code reviews.
Each factory maps to one doctype, so the names never clash and the core/events/ticketing/proposals subpackages only added a level to look through. Call sites import from buzz.tests.factories and do not change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SWM6kF7ncqfQx9eYpBKcbm
There was a problem hiding this comment.
Your trial has ended. Reactivate Greptile to resume code reviews.
Conflicts with the factory rewrite (#540): its EventVenueFactory replaces this branch's identical one, and the public page tests move onto TeamTestCase and BuzzTeamMembershipFactory.
What changed
buzz/tests/factories/<doctype>_factory.py. All of them are exported frombuzz.tests.factories, and each one is smoke-tested inbuzz/tests/test_factories.py.get_doc({...}).insert(). The one exception is the Zoom template, because Zoom is an optional app.test-routeevent, and they no longer use hard-coded dates.buzz/tests/base_test_cases.py.buzz/tests/utils.py.self.set_user,self.change_settingsandUnitTestCasefor pure logic.FrappeTestCaseis no longer used.setup_test_records()now creates only the talk statuses and the Administrator team.create_administrator_teamusedfrappe.db.exists("Buzz Team"), which always returnedNone. It now usesdb.count. fix(install): check for existing teams with a real query #550 has the same fix.Left for you
git rmthe 15 empty doctype test scaffolds andevent_category/test_event_category.py.test_event_sponsor.py, because it is the only test of the gateway-paid sponsor route.Demo
Not applicable. This PR changes only tests (
skip-demo).Testing
🤖 Generated with Claude Code
https://claude.ai/code/session_01SWM6kF7ncqfQx9eYpBKcbm