with one click
write-backend-unit-test
// Write or update Baserow backend tests for core, premium, or enterprise code using pytest, Django, DRF APIClient, and the repo's shared fixture patterns.
// Write or update Baserow backend tests for core, premium, or enterprise code using pytest, Django, DRF APIClient, and the repo's shared fixture patterns.
Create or update Baserow runtime formulas in `core/formula/runtime_formula_types.py`. Use when adding or updating a runtime formula.
Add or update a Baserow Application Builder element type across backend models, backend ElementType registration, frontend element registry/components/forms/icons/translations, migrations, and targeted tests. Use when creating or changing an element shown in the builder add-element modal, page preview, public page rendering, form elements, collection elements, container elements, or enterprise-only builder elements.
Create or update a Baserow in-app notification for an event. Use when adding a backend `NotificationType`, wiring frontend notification rendering and routing, defining the notification target, or preventing duplicate notifications for the same event object.
Create or update Baserow integration and service types, including services exposed as Application Builder data sources, Builder workflow actions, Automation node actions, Automation node triggers, or dashboard data sources. Use when adding a ServiceType/IntegrationType subclass, registering backend/frontend types, or wiring service wrappers in builder or automation.
Manage Baserow backend feature layers across Django models, handlers, services, undoable actions, serializers, API views, URLs, permissions, signals, migrations, and tests. Use when adding or changing backend CRUD/domain behavior that spans model, handler, service, action, and view layers; use the automation modules as the preferred modern pattern.
Create, edit, or debug Baserow permission operations and permission managers across backend and frontend, including OperationType, PermissionManagerType, PERMISSION_MANAGERS ordering, frontend permission managers, and permission tests.
| name | write-backend-unit-test |
| description | Write or update Baserow backend tests for core, premium, or enterprise code using pytest, Django, DRF APIClient, and the repo's shared fixture patterns. |
Use this skill when a task is to add, fix, or extend a backend test in backend/tests, premium/backend/tests, or enterprise/backend/tests.
Do not invent a generic Django testing style. This repo already has strong pytest and fixture conventions. Start by finding the closest existing test in the same backend area and copy its setup shape.
Before editing, identify the test target:
Then inspect the nearest existing test file in the same module area.
Useful searches:
Use rg as a faster equivalent when it is available.
find backend/tests premium/backend/tests enterprise/backend/tests -type f | grep 'test_.*\.py$'grep -RInE "@pytest\\.mark\\.django_db|api_client|data_fixture|premium_data_fixture|enterprise_data_fixture" backend/tests premium/backend/tests enterprise/backend/testsgrep -RInE "pytest\\.raises|@patch\\(|override_settings|django_assert_num_queries" backend/tests premium/backend/tests enterprise/backend/testsCurrent backend tests use:
pytestpytest-djangoreverseAPIClient from the shared api_client fixturebackend/src/baserow/test_utils/pytest_conftest.pydata_fixture, premium_data_fixture, and enterprise_data_fixtureImportant local files:
backend/src/baserow/test_utils/pytest_conftest.pypremium/backend/tests/baserow_premium_tests/conftest.pyenterprise/backend/tests/baserow_enterprise_tests/conftest.pypytest_conftest.py already provides data_fixture, api_client, api_request_factory, registry reset helpers, env helpers, and automatic signal deferral. Reuse those instead of building bespoke fixtures unless the nearby test already does something more specific.
For core business logic, keep the test direct:
@pytest.mark.django_db when it touches the database.data_fixture or the premium or enterprise equivalent.Good examples:
backend/tests/baserow/core/test_core_handler.pybackend/tests/baserow/core/service/test_service_handler.pyenterprise/backend/tests/baserow_enterprise_tests/teams/test_team_handler.pyUse pytest.raises(...) for error paths. Prefer asserting the specific domain exception over broad response or string checks when testing non-API code.
For API endpoints, match the common DRF style:
data_fixture.create_user_and_token() when JWT auth is needed.reverse(...).api_client.get, post, patch, or delete.HTTP_AUTHORIZATION=f"JWT {token}".Good examples:
backend/tests/baserow/api/groups/test_workspace_views.pybackend/tests/baserow/contrib/database/api/rows/test_row_views.pypremium/backend/tests/baserow_premium_tests/api/license/test_premium_license_views.pyPrefer focused payload assertions. Only construct a large expected JSON object when the endpoint response shape is the behavior being tested.
When the important behavior is that a signal or side effect fires:
Good examples:
backend/tests/baserow/core/test_core_handler.pyenterprise/backend/tests/baserow_enterprise_tests/teams/test_team_receivers.pyThe shared test setup already defers many heavy async tasks. Do not add extra mocking for those unless the test specifically needs to assert the call.
Use the repo helpers already in use nearby:
override_settings(...) when the behavior is controlled by Django settings.django_assert_num_queries(...) only when query count is part of the contract.Good examples:
backend/tests/baserow/config/test_read_replica_router.pypremium/backend/tests/baserow_premium_tests/api/license/test_premium_license_views.pyenterprise/backend/tests/baserow_enterprise_tests/sso/test_auth_provider_handler.pyDo not turn ordinary behavior tests into performance tests.
Prefer fixture builders over hand-rolling model graphs:
data_fixture for core backend objects.premium_data_fixture in premium tests.enterprise_data_fixture in enterprise tests.api_client instead of instantiating APIClient manually.If you need premium or enterprise-only entities, start by checking the corresponding conftest.py and nearby test files instead of guessing the fixture name.
Follow the existing test tree:
backend/tests/baserow/**premium/backend/tests/baserow_premium_tests/**enterprise/backend/tests/baserow_enterprise_tests/**Keep the new test near the feature area rather than creating a new generic test module.
Run the narrowest relevant test command first.
Examples:
just b test baserow/core/test_core_handler.pyjust b test baserow/api/groups/test_workspace_views.pyjust b test premium/backend/tests/baserow_premium_tests/api/license/test_premium_license_views.pyjust b test enterprise/backend/tests/baserow_enterprise_tests/teams/test_team_handler.pyIf you changed settings-sensitive or query-count-sensitive tests, check the exact failure instead of weakening the assertion immediately.
unittest.TestCase or Django TestCase patterns when the repo already uses plain pytest functions.data_fixture already provides the needed factory.@pytest.mark.django_db on database-touching tests.