Skip to content

Add missing test coverage for full text search filter#9949

Merged
browniebroke merged 2 commits intoencode:mainfrom
browniebroke:ci/setup-postgres
Apr 7, 2026
Merged

Add missing test coverage for full text search filter#9949
browniebroke merged 2 commits intoencode:mainfrom
browniebroke:ci/setup-postgres

Conversation

@browniebroke
Copy link
Copy Markdown
Member

Description

@browniebroke browniebroke added the CI label Apr 6, 2026
@auvipy auvipy self-requested a review April 7, 2026 06:40
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds PostgreSQL-aware CI configuration and introduces new tests to cover DRF’s SearchFilter full-text search (@-prefixed fields), aligning the test suite with upcoming Postgres-specific search behavior (referenced in #9385).

Changes:

  • Add PostgreSQL-backed full-text search tests for SearchFilter using a new requires_postgres pytest marker.
  • Update test configuration to support DATABASE_URL via dj-database-url, and auto-skip Postgres-only tests when not on PostgreSQL.
  • Update GitHub Actions workflow to run the test matrix against a Postgres service.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
tests/test_filters.py Adds Postgres-only full-text search test coverage and a construct_search regression test for @ prefix.
tests/conftest.py Adds DATABASE_URL support and a collection-time skip mechanism for Postgres-only tests.
pyproject.toml Adds dj-database-url test dependency and registers the requires_postgres marker.
.github/workflows/main.yml Runs CI tests against a Postgres service and sets DATABASE_URL in the job environment.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +19 to +21
databases = {
'default': dj_database_url.config(),
'secondary': dj_database_url.config(),
Copy link

Copilot AI Apr 7, 2026

Choose a reason for hiding this comment

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

When DATABASE_URL is set, both the default and secondary database aliases are configured with the exact same connection info. On PostgreSQL, Django will attempt to create a separate test database per alias, and identical NAME/settings can cause test database creation/teardown to collide. Configure secondary as a TEST mirror of default (or give it a distinct TEST/NAME) so multi-db tests can run reliably on Postgres.

Suggested change
databases = {
'default': dj_database_url.config(),
'secondary': dj_database_url.config(),
default_database = dj_database_url.config()
secondary_database = default_database.copy()
secondary_database['TEST'] = {'MIRROR': 'default'}
databases = {
'default': default_database,
'secondary': secondary_database,

Copilot uses AI. Check for mistakes.
run: python -m pip install --upgrade tox

- name: Create unaccent extension
run: PGPASSWORD=postgres psql -h localhost -U postgres -d postgres -c 'CREATE EXTENSION IF NOT EXISTS unaccent;'
Copy link

Copilot AI Apr 7, 2026

Choose a reason for hiding this comment

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

This CI step creates the unaccent extension in the postgres database, but Django/pytest will run tests against a newly created test database (e.g. test_postgres), which will not automatically inherit extensions from the original DB. If unaccent is needed for tests, create it in the test DB during test setup (e.g. in a pytest fixture after DB creation) or create it in a template DB used for test DB creation.

Suggested change
run: PGPASSWORD=postgres psql -h localhost -U postgres -d postgres -c 'CREATE EXTENSION IF NOT EXISTS unaccent;'
run: |
PGPASSWORD=postgres psql -h localhost -U postgres -d template1 -c 'CREATE EXTENSION IF NOT EXISTS unaccent;'
PGPASSWORD=postgres psql -h localhost -U postgres -d postgres -c 'CREATE EXTENSION IF NOT EXISTS unaccent;'

Copilot uses AI. Check for mistakes.
@browniebroke browniebroke merged commit 99f619f into encode:main Apr 7, 2026
11 checks passed
@browniebroke browniebroke deleted the ci/setup-postgres branch April 7, 2026 18:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants