Skip to content

Test: Add tests to ensure every DB table has a default entry in schem…#8341

Open
CarolineDenis wants to merge 2 commits into
mainfrom
issue-8078
Open

Test: Add tests to ensure every DB table has a default entry in schem…#8341
CarolineDenis wants to merge 2 commits into
mainfrom
issue-8078

Conversation

@CarolineDenis

@CarolineDenis CarolineDenis commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

…a_localization_en.json

Fixes #8078

Checklist

  • Self-review the PR after opening it to make sure the changes look good and
    self-explanatory (or properly documented)
  • Add relevant issue to release milestone
  • Add pr to documentation list
  • Add automated tests
  • Add a reverse migration if a migration is present in the PR
  • Add migration function to
    def fix_schema_config(stdout: WriteToStdOut | None = None):

Testing instructions

Summary by CodeRabbit

  • Tests
    • Added automated coverage checks to ensure all model-backed database tables have corresponding schema localization entries.
    • Added validation to flag unexpected localization entries and report missing or extra tables clearly.

@github-actions

Copy link
Copy Markdown

Warning

One or more dependencies are approaching or past End-of-Life.
Please plan upgrades accordingly.

STATUS=WARNING
NODE_VERSION=20
NODE_CYCLE=20
EOL_DATE=2026-04-30
DAYS_REMAINING=-83

--- Node.js ---
Version: 20
EOL: 2026-04-30
Status: WARNING

STATUS=OK
PYTHON_VERSION=3.12
PYTHON_CYCLE=3.12
EOL_DATE=2028-10-31
DAYS_REMAINING=832

--- Python ---
Version: 3.12
EOL: 2028-10-31
Status: OK

STATUS=WARNING
DJANGO_VERSION=4.2
DJANGO_CYCLE=4.2
EOL_DATE=2026-04-07
DAYS_REMAINING=-106

--- Django ---
Version: 4.2
EOL: 2026-04-07
Status: WARNING


@coderabbitai

coderabbitai Bot commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@CarolineDenis, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 54 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 4558f54f-c80d-4222-9575-000c7fdb891e

📥 Commits

Reviewing files that changed from the base of the PR and between f35ca7c and b4156a5.

📒 Files selected for processing (1)
  • specifyweb/specify/tests/test_schema_localization_contract.py
📝 Walkthrough

Walkthrough

Adds a Django test that parses model table declarations, compares them with schema_localization_en.json, permits approved JSON-only tables, and reports missing or unexpected entries.

Changes

Schema localization coverage

Layer / File(s) Summary
Table discovery and test setup
specifyweb/specify/tests/test_schema_localization_contract.py
Loads the localization JSON and extracts lowercased Meta.db_table values from model classes using the Python AST.
Localization coverage validation
specifyweb/specify/tests/test_schema_localization_contract.py
Compares model tables with localization keys, applies an allowlist for JSON-only tables, and fails with actionable missing or unexpected entries.
🚥 Pre-merge checks | ✅ 5 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Testing Instructions ⚠️ Warning The PR adds a schema-localization contract test, but the description’s Testing instructions section is empty, so the affected component isn’t explained or reproducible. Add concrete steps to run the new test and mention the impacted files/components: config/common/schema_localization_en.json and specifyweb/specify/models.py.
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title is directly related to the new schema localization coverage test.
Linked Issues check ✅ Passed The new test matches issue #8078 by comparing model tables to schema_localization_en.json and honoring an allowlist for JSON-only entries.
Out of Scope Changes check ✅ Passed The change is scoped to a single test module and does not introduce unrelated functionality.
Automatic Tests ✅ Passed The PR adds an automated Django TestCase module at specifyweb/specify/tests/test_schema_localization_contract.py.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch issue-8078

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai 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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@specifyweb/specify/tests/test_schema_localization_contract.py`:
- Around line 37-38: Update the AST extraction logic in the schema localization
contract test to retain each associated model name alongside the lowercased
table slug instead of storing only stmt.value.value. Propagate that model name
into the missing-entry failure reported by the test so failures identify the
model and table involved, while preserving the existing table-name matching
behavior.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 1c06851d-778a-4988-93e0-6cf5860402e3

📥 Commits

Reviewing files that changed from the base of the PR and between 8f38321 and f35ca7c.

📒 Files selected for processing (1)
  • specifyweb/specify/tests/test_schema_localization_contract.py

Comment thread specifyweb/specify/tests/test_schema_localization_contract.py Outdated
@github-project-automation github-project-automation Bot moved this from 📋Back Log to Dev Attention Needed in General Tester Board Jul 22, 2026
@grantfitzsimmons
grantfitzsimmons self-requested a review July 23, 2026 12:56

@grantfitzsimmons grantfitzsimmons left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Pretty cool idea! Nice!

  • When there are no unexpected extras, printing "Unexpected schema localization-only tables:" with nothing after it is not needed.
  • The allowlist is also part of the body, but should we maintain this list elsewhere? Are these tables excluded from any other part of the app (e.g. schema config) or should be?
  • We could add feedback for future developers here like "Add entries to the schema_localization_en.json file or update the allowlist"
  • A count summary of the number of tables at the top would be nice, but totally optional

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Dev Attention Needed

Development

Successfully merging this pull request may close these issues.

Ensure every DB table has a default entry in schema_localization_en.json

2 participants