Skip to content

[change] Added default ordering to timestamped models - #728

Open
nemesifier wants to merge 4 commits into
masterfrom
change/timestamped-model-ordering
Open

[change] Added default ordering to timestamped models#728
nemesifier wants to merge 4 commits into
masterfrom
change/timestamped-model-ordering

Conversation

@nemesifier

@nemesifier nemesifier commented Aug 3, 2026

Copy link
Copy Markdown
Member

Checklist

Reference to Existing Issue

Closes #727.

Description of Changes

Adds deterministic newest-first default ordering, ("-created", "-pk"), to TimeStampedEditableModel and preserves it in local test models that declare Meta.

Adds metadata-only migrations, behavioral queryset coverage, and developer documentation. The autocomplete filter test selects the expected shelf by label instead of relying on database result order.

Screenshot

N/A

@coderabbitai

coderabbitai Bot commented Aug 3, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: ddc10281-78b7-4bcd-a1ee-5f4465f86763

📥 Commits

Reviewing files that changed from the base of the PR and between f6293d0 and 9e95aa3.

📒 Files selected for processing (8)
  • docs/developer/other-utilities.rst
  • openwisp_utils/base.py
  • openwisp_utils/metric_collection/migrations/0002_alter_consent_options.py
  • openwisp_utils/metric_collection/tests/test_models.py
  • tests/test_project/migrations/0010_alter_book_options_alter_shelf_options.py
  • tests/test_project/models.py
  • tests/test_project/tests/test_model.py
  • tests/test_project/tests/test_selenium.py
📜 Recent review details
🧰 Additional context used
📓 Path-based instructions (6)
**/*.py

📄 CodeRabbit inference engine (AGENTS.md)

**/*.py: Place imports at the top of the file; only defer imports when necessary (e.g., Django model imports inside functions or methods where the app registry is not yet ready)
Avoid unnecessary blank lines inside function and method bodies
Add or update tests for every behavior change
Run openwisp-qa-format after editing
Prefer in-process tests so coverage tools can measure changed code
When checking coverage for a changed module, use python -m pytest <test_path> --cov=<dotted.module.path> --cov-report=term-missing
Watch for unsafe file paths, unsafe subprocess usage, token or secret exposure, and changes that could weaken QA or release safeguards
Write comments and docstrings only when they explain why code is shaped a certain way; place comments before the relevant code block instead of scattering them inside it

In Django code, mark all user-facing strings as translatable using the Django internationalization framework.

Files:

  • openwisp_utils/metric_collection/migrations/0002_alter_consent_options.py
  • tests/test_project/models.py
  • openwisp_utils/metric_collection/tests/test_models.py
  • tests/test_project/migrations/0010_alter_book_options_alter_shelf_options.py
  • tests/test_project/tests/test_selenium.py
  • tests/test_project/tests/test_model.py
  • openwisp_utils/base.py
**/*

📄 CodeRabbit inference engine (Custom checks)

**/*: For bug fixes in core user-facing functionality, fix the root cause rather than hiding or bypassing the problem.
Bug fixes must include a regression test that reproduces the bug and fails when the fix is removed, except for valid exceptions such as one-line fixes or impractical GitHub Actions workflow fixes.
User-interface bug fixes must include a Selenium browser regression test; missing coverage should be reported as a warning.
Tests must be deterministic and non-flaky; avoid dependence on timing, sleeps, system time, randomness without a fixed seed, race conditions, network services, filesystem state, environment-specific configuration, execution order, shared global state, hardcoded ports, or improperly awaited asynchronous operations.
When a change request modifies documented behavior, update the documentation to describe the new behavior.
Pull requests containing UI changes must include screenshots or screen recordings in the pull request description.
Update tests for non-trivial behavior changes and validate the modified behavior.
Flag changes that may break existing behavior or public APIs unless a clear migration path is provided.
Feature requests must have an issue explaining the feature, validated and accepted by an organization member through labels or project assignment.
New features must be documented; heavily UI-related features should have a dedicated documentation section or page.
Add tests for new features without significantly decreasing coverage; prefer Selenium browser tests for UI-impacting features.
Non-organization members must target maintainer-validated issues with at least one label other than wontfix or invalid and assignment to either the OpenWISP Contributor's Board or OpenWISP Priorities for next releases project.
Flag potential security vulnerabilities.
Flag obvious performance regressions such as heavy loops, repeated I/O, or unoptimized queries.
Cryptic or non-obvious code, including regexes, complex shell commands, and ...

Files:

  • openwisp_utils/metric_collection/migrations/0002_alter_consent_options.py
  • tests/test_project/models.py
  • openwisp_utils/metric_collection/tests/test_models.py
  • docs/developer/other-utilities.rst
  • tests/test_project/migrations/0010_alter_book_options_alter_shelf_options.py
  • tests/test_project/tests/test_selenium.py
  • tests/test_project/tests/test_model.py
  • openwisp_utils/base.py

⚙️ CodeRabbit configuration file

**/*: - Flag potential security vulnerabilities

  • Flag obvious performance regressions, such as heavy loops, repeated I/O, or unoptimized queries

  • Flag unused or redundant code

  • Flag outdated or incorrect comments/docstrings

  • Ensure new code handles errors properly:

    • Log errors that cannot be resolved by the user with error level
    • Log unusual conditions with warning level
    • Log important background actions with info level
    • Provide user-facing messages for errors that the user can solve autonomously (for example, validation errors)

Files:

  • openwisp_utils/metric_collection/migrations/0002_alter_consent_options.py
  • tests/test_project/models.py
  • openwisp_utils/metric_collection/tests/test_models.py
  • docs/developer/other-utilities.rst
  • tests/test_project/migrations/0010_alter_book_options_alter_shelf_options.py
  • tests/test_project/tests/test_selenium.py
  • tests/test_project/tests/test_model.py
  • openwisp_utils/base.py
**/tests/**/*.py

📄 CodeRabbit inference engine (AGENTS.md)

For bug fixes, write the regression test first, run it against the unfixed code, confirm it fails for the expected reason, then implement the fix

Files:

  • tests/test_project/models.py
  • openwisp_utils/metric_collection/tests/test_models.py
  • tests/test_project/migrations/0010_alter_book_options_alter_shelf_options.py
  • tests/test_project/tests/test_selenium.py
  • tests/test_project/tests/test_model.py
**/*tests*/**

⚙️ CodeRabbit configuration file

**/*tests*/**: Ensure tests cover relevant success, error, boundary, and unusual
input scenarios.

Flag tests that depend on arbitrary sleeps, uncontrolled system time,
specific timezones, unseeded randomness, network access, external
services, execution order, shared mutable state, hardcoded ports, or
asynchronous operations that are not properly awaited.

Files:

  • tests/test_project/models.py
  • openwisp_utils/metric_collection/tests/test_models.py
  • tests/test_project/migrations/0010_alter_book_options_alter_shelf_options.py
  • tests/test_project/tests/test_selenium.py
  • tests/test_project/tests/test_model.py
**/*.{md,rst,txt}

📄 CodeRabbit inference engine (AGENTS.md)

Update documentation when behavior, settings, public APIs, setup steps, QA rules, or supported versions change

Files:

  • docs/developer/other-utilities.rst
**/*.{md,rst}

⚙️ CodeRabbit configuration file

**/*.{md,rst}: Verify that documentation remains consistent with the implemented
behavior and does not reference deprecated or removed functionality.

Files:

  • docs/developer/other-utilities.rst
🧠 Learnings (1)
📚 Learning: 2026-06-15T22:45:01.529Z
Learnt from: nemesifier
Repo: openwisp/openwisp-utils PR: 701
File: setup.py:72-72
Timestamp: 2026-06-15T22:45:01.529Z
Learning: When reviewing changes that require a minimum Selenium Python version for specific APIs (e.g., BiDi features like `Options.enable_bidi`, console/message handlers like `Script.add_console_message_handler`, or event handlers like `BrowsingContext.add_event_handler`), do not use the Selenium API docs site (`https://www.selenium.dev/selenium/docs/api/py/`) as the source of introduction/version history, since it reflects the latest API shape. Instead, confirm feature availability by checking the official Python changelog (`py/CHANGES` in the Selenium repo) and/or inspecting the Selenium source (tags/commits corresponding to candidate versions). Only accept the stated minimum version after verifying that the referenced APIs exist in that Selenium version (e.g., Selenium 4.32.0 includes the BiDi APIs used by openwisp-utils’ BiDi-related PR `#701` as of that version).

Applied to files:

  • openwisp_utils/metric_collection/migrations/0002_alter_consent_options.py
  • tests/test_project/models.py
  • openwisp_utils/metric_collection/tests/test_models.py
  • tests/test_project/migrations/0010_alter_book_options_alter_shelf_options.py
  • tests/test_project/tests/test_selenium.py
  • tests/test_project/tests/test_model.py
  • openwisp_utils/base.py
🔇 Additional comments (9)
openwisp_utils/metric_collection/tests/test_models.py (1)

1-3: LGTM!

Also applies to: 26-41

tests/test_project/tests/test_model.py (1)

1-3: LGTM!

Also applies to: 18-70

tests/test_project/tests/test_selenium.py (1)

655-658: LGTM!

openwisp_utils/base.py (1)

26-26: LGTM!

docs/developer/other-utilities.rst (1)

30-34: LGTM!

tests/test_project/models.py (2)

59-60: LGTM!


77-79: LGTM!

openwisp_utils/metric_collection/migrations/0002_alter_consent_options.py (1)

1-17: LGTM!

tests/test_project/migrations/0010_alter_book_options_alter_shelf_options.py (1)

1-22: LGTM!


📝 Walkthrough

Walkthrough

TimeStampedEditableModel now orders records by descending creation time and descending primary key. Concrete test models inherit this metadata. Migrations record the updated options for Consent, Book, and Shelf. Documentation and regression tests cover the ordering and its overrides. The autocomplete test selects the expected shelf by displayed name.

Estimated code review effort: 2 (Simple) | ~10 minutes

Suggested reviewers: pandafy


Caution

Pre-merge checks failed

Please resolve all errors before merging. Addressing warnings is optional.

  • Ignore

❌ Failed checks (1 error)

Check name Status Explanation Resolution
Ui Changes, Regression Test, Docs ❌ Error Default model ordering changes admin list and autocomplete results, but the PR description marks Screenshot as N/A; regression tests and documentation are present. Add before-and-after screenshots or a screen recording for the affected admin ordering and autocomplete behavior.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title uses the required [change] prefix and clearly describes the addition of default ordering to timestamped models.
Description check ✅ Passed The description completes all checklist items, references issue #727, explains the changes, and marks screenshots as not applicable.
Linked Issues check ✅ Passed The changes implement issue #727 by adding deterministic ordering, preserving it in subclasses, adding migrations and tests, updating documentation, and fixing order-dependent test logic.
Out of Scope Changes check ✅ Passed All changes support the linked issue objectives, including ordering behavior, migrations, regression tests, documentation, and the autocomplete test correction.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch change/timestamped-model-ordering

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.

@kilo-code-bot

kilo-code-bot Bot commented Aug 3, 2026

Copy link
Copy Markdown

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Files Reviewed (8 files)
  • AGENTS.md
  • docs/developer/admin-utilities.rst
  • docs/developer/qa-checks.rst
  • openwisp_utils/admin.py
  • tests/test_project/migrations/0010_alter_book_options_alter_shelf_options.py
  • tests/test_project/models.py
  • tests/test_project/tests/test_admin.py
  • tests/test_project/tests/test_model.py
Previous Review Summaries (3 snapshots, latest commit a121fe3)

Current summary above is authoritative. Previous snapshots are kept for context only.

Previous review (commit a121fe3)

Status: No Issues Found | Recommendation: Merge

Files Reviewed (2 files)
  • openwisp_utils/metric_collection/tests/test_models.py
  • tests/test_project/tests/test_model.py

Previous review (commit 594c9ce)

Status: No Issues Found | Recommendation: Merge

Files Reviewed (6 files)
  • docs/developer/other-utilities.rst
  • openwisp_utils/base.py
  • openwisp_utils/metric_collection/migrations/0002_alter_consent_options.py
  • openwisp_utils/metric_collection/tests/test_models.py
  • tests/test_project/migrations/0010_alter_book_options_alter_shelf_options.py
  • tests/test_project/tests/test_model.py

Previous review (commit 54bfd28)

Status: No Issues Found | Recommendation: Merge

Files Reviewed (7 files)
  • openwisp_utils/base.py
  • openwisp_utils/metric_collection/migrations/0002_alter_consent_options.py
  • openwisp_utils/metric_collection/tests/test_models.py
  • tests/test_project/migrations/0010_alter_book_options_alter_shelf_options.py
  • tests/test_project/models.py
  • tests/test_project/tests/test_model.py
  • tests/test_project/tests/test_selenium.py

Reviewed by step-3.7-flash · Input: 123.5K · Output: 21.7K · Cached: 935.8K

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

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 `@openwisp_utils/metric_collection/tests/test_models.py`:
- Around line 25-27: Extend test_consent_ordering in
openwisp_utils/metric_collection/tests/test_models.py#L25-L27 with deterministic
Consent records using controlled created values, then assert the default
queryset returns newest records first. In
tests/test_project/tests/test_model.py#L16-L18, add deterministic Shelf and Book
records and assert default queryset ordering, QuerySet.order_by() behavior, and
explicit Meta.ordering overrides; retain the existing metadata checks where
applicable.
🪄 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: ASSERTIVE

Plan: Pro Plus

Run ID: a4440db8-175b-42a5-9b3f-5c8cfe8d7e38

📥 Commits

Reviewing files that changed from the base of the PR and between e0c2bdf and 54bfd28.

📒 Files selected for processing (7)
  • openwisp_utils/base.py
  • openwisp_utils/metric_collection/migrations/0002_alter_consent_options.py
  • openwisp_utils/metric_collection/tests/test_models.py
  • tests/test_project/migrations/0010_alter_book_options_alter_shelf_options.py
  • tests/test_project/models.py
  • tests/test_project/tests/test_model.py
  • tests/test_project/tests/test_selenium.py
📜 Review details
⏰ Context from checks skipped due to timeout. (18)
  • GitHub Check: Kilo Code Review
  • GitHub Check: Python==3.12 | django~=5.1.0
  • GitHub Check: Python==3.10 | django~=4.2.0
  • GitHub Check: Python==3.11 | django~=5.1.0
  • GitHub Check: Python==3.10 | django~=5.1.0
  • GitHub Check: Python==3.10 | django~=5.0.0
  • GitHub Check: Python==3.13 | django~=5.1.0
  • GitHub Check: Python==3.10 | django~=5.2.0
  • GitHub Check: Python==3.12 | django~=5.0.0
  • GitHub Check: Python==3.13 | django~=5.2.0
  • GitHub Check: Python==3.12 | django~=5.2.0
  • GitHub Check: Python==3.11 | django~=4.2.0
  • GitHub Check: Python==3.11 | django~=5.2.0
  • GitHub Check: Python==3.12 | django~=4.2.0
  • GitHub Check: Python==3.11 | django~=5.0.0
  • GitHub Check: Analyze (actions)
  • GitHub Check: Analyze (javascript-typescript)
  • GitHub Check: Analyze (python)
🧰 Additional context used
📓 Path-based instructions (3)
**/*.py

📄 CodeRabbit inference engine (AGENTS.md)

**/*.py: Place imports at the top of the file; only defer imports when necessary (e.g., Django model imports inside functions or methods where the app registry is not yet ready)
Avoid unnecessary blank lines inside function and method bodies
Add or update tests for every behavior change
Run openwisp-qa-format after editing
Prefer in-process tests so coverage tools can measure changed code
When checking coverage for a changed module, use python -m pytest <test_path> --cov=<dotted.module.path> --cov-report=term-missing
Watch for unsafe file paths, unsafe subprocess usage, token or secret exposure, and changes that could weaken QA or release safeguards
Write comments and docstrings only when they explain why code is shaped a certain way; place comments before the relevant code block instead of scattering them inside it

In Django code, mark all user-facing strings as translatable using the Django internationalization framework.

Files:

  • tests/test_project/tests/test_model.py
  • tests/test_project/migrations/0010_alter_book_options_alter_shelf_options.py
  • openwisp_utils/metric_collection/migrations/0002_alter_consent_options.py
  • tests/test_project/tests/test_selenium.py
  • openwisp_utils/base.py
  • tests/test_project/models.py
  • openwisp_utils/metric_collection/tests/test_models.py
**/tests/**/*.py

📄 CodeRabbit inference engine (AGENTS.md)

For bug fixes, write the regression test first, run it against the unfixed code, confirm it fails for the expected reason, then implement the fix

Files:

  • tests/test_project/tests/test_model.py
  • tests/test_project/migrations/0010_alter_book_options_alter_shelf_options.py
  • tests/test_project/tests/test_selenium.py
  • tests/test_project/models.py
  • openwisp_utils/metric_collection/tests/test_models.py
**/*

📄 CodeRabbit inference engine (Custom checks)

**/*: For bug fixes in core user-facing functionality, fix the root cause rather than hiding or bypassing the problem.
Bug fixes must include a regression test that reproduces the bug and fails when the fix is removed, except for valid exceptions such as one-line fixes or impractical GitHub Actions workflow fixes.
User-interface bug fixes must include a Selenium browser regression test; missing coverage should be reported as a warning.
Tests must be deterministic and non-flaky; avoid dependence on timing, sleeps, system time, randomness without a fixed seed, race conditions, network services, filesystem state, environment-specific configuration, execution order, shared global state, hardcoded ports, or improperly awaited asynchronous operations.
When a change request modifies documented behavior, update the documentation to describe the new behavior.
Pull requests containing UI changes must include screenshots or screen recordings in the pull request description.
Update tests for non-trivial behavior changes and validate the modified behavior.
Flag changes that may break existing behavior or public APIs unless a clear migration path is provided.
Feature requests must have an issue explaining the feature, validated and accepted by an organization member through labels or project assignment.
New features must be documented; heavily UI-related features should have a dedicated documentation section or page.
Add tests for new features without significantly decreasing coverage; prefer Selenium browser tests for UI-impacting features.
Non-organization members must target maintainer-validated issues with at least one label other than wontfix or invalid and assignment to either the OpenWISP Contributor's Board or OpenWISP Priorities for next releases project.
Flag potential security vulnerabilities.
Flag obvious performance regressions such as heavy loops, repeated I/O, or unoptimized queries.
Cryptic or non-obvious code, including regexes, complex shell commands, and ...

Files:

  • tests/test_project/tests/test_model.py
  • tests/test_project/migrations/0010_alter_book_options_alter_shelf_options.py
  • openwisp_utils/metric_collection/migrations/0002_alter_consent_options.py
  • tests/test_project/tests/test_selenium.py
  • openwisp_utils/base.py
  • tests/test_project/models.py
  • openwisp_utils/metric_collection/tests/test_models.py
🧠 Learnings (1)
📚 Learning: 2026-06-15T22:45:01.529Z
Learnt from: nemesifier
Repo: openwisp/openwisp-utils PR: 701
File: setup.py:72-72
Timestamp: 2026-06-15T22:45:01.529Z
Learning: When reviewing changes that require a minimum Selenium Python version for specific APIs (e.g., BiDi features like `Options.enable_bidi`, console/message handlers like `Script.add_console_message_handler`, or event handlers like `BrowsingContext.add_event_handler`), do not use the Selenium API docs site (`https://www.selenium.dev/selenium/docs/api/py/`) as the source of introduction/version history, since it reflects the latest API shape. Instead, confirm feature availability by checking the official Python changelog (`py/CHANGES` in the Selenium repo) and/or inspecting the Selenium source (tags/commits corresponding to candidate versions). Only accept the stated minimum version after verifying that the referenced APIs exist in that Selenium version (e.g., Selenium 4.32.0 includes the BiDi APIs used by openwisp-utils’ BiDi-related PR `#701` as of that version).

Applied to files:

  • tests/test_project/tests/test_model.py
  • tests/test_project/migrations/0010_alter_book_options_alter_shelf_options.py
  • openwisp_utils/metric_collection/migrations/0002_alter_consent_options.py
  • tests/test_project/tests/test_selenium.py
  • openwisp_utils/base.py
  • tests/test_project/models.py
  • openwisp_utils/metric_collection/tests/test_models.py
🔇 Additional comments (5)
tests/test_project/models.py (1)

59-60: LGTM!

Also applies to: 77-78

openwisp_utils/metric_collection/migrations/0002_alter_consent_options.py (1)

1-17: LGTM!

tests/test_project/migrations/0010_alter_book_options_alter_shelf_options.py (1)

1-21: LGTM!

tests/test_project/tests/test_selenium.py (1)

655-658: LGTM!

openwisp_utils/base.py (1)

26-26: 🗄️ Data Integrity & Integration

Shared ordering is already preserved.

Comment thread openwisp_utils/metric_collection/tests/test_models.py
@nemesifier nemesifier self-assigned this Aug 5, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

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 `@tests/test_project/tests/test_model.py`:
- Around line 58-71: Extend the ordering test around Shelf and Book to cover a
timestamped descendant with an explicit Meta.ordering override. Assert both that
the model’s _meta.ordering equals its explicit ordering and that querying it
returns records in that declared order, using deterministic fixtures and
primary-key tie-breaking where needed.
🪄 Autofix

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: ASSERTIVE

Plan: Pro Plus

Run ID: 40152959-4556-47f9-9305-7a98f4ef7d1f

📥 Commits

Reviewing files that changed from the base of the PR and between 54bfd28 and 594c9ce.

📒 Files selected for processing (6)
  • docs/developer/other-utilities.rst
  • openwisp_utils/base.py
  • openwisp_utils/metric_collection/migrations/0002_alter_consent_options.py
  • openwisp_utils/metric_collection/tests/test_models.py
  • tests/test_project/migrations/0010_alter_book_options_alter_shelf_options.py
  • tests/test_project/tests/test_model.py
📜 Review details
⏰ Context from checks skipped due to timeout. (1)
  • GitHub Check: Kilo Code Review
🧰 Additional context used
📓 Path-based instructions (6)
**/*.py

📄 CodeRabbit inference engine (AGENTS.md)

**/*.py: Place imports at the top of the file; only defer imports when necessary (e.g., Django model imports inside functions or methods where the app registry is not yet ready)
Avoid unnecessary blank lines inside function and method bodies
Add or update tests for every behavior change
Run openwisp-qa-format after editing
Prefer in-process tests so coverage tools can measure changed code
When checking coverage for a changed module, use python -m pytest <test_path> --cov=<dotted.module.path> --cov-report=term-missing
Watch for unsafe file paths, unsafe subprocess usage, token or secret exposure, and changes that could weaken QA or release safeguards
Write comments and docstrings only when they explain why code is shaped a certain way; place comments before the relevant code block instead of scattering them inside it

In Django code, mark all user-facing strings as translatable using the Django internationalization framework.

Files:

  • openwisp_utils/metric_collection/tests/test_models.py
  • tests/test_project/tests/test_model.py
  • openwisp_utils/base.py
  • openwisp_utils/metric_collection/migrations/0002_alter_consent_options.py
  • tests/test_project/migrations/0010_alter_book_options_alter_shelf_options.py
**/tests/**/*.py

📄 CodeRabbit inference engine (AGENTS.md)

For bug fixes, write the regression test first, run it against the unfixed code, confirm it fails for the expected reason, then implement the fix

Files:

  • openwisp_utils/metric_collection/tests/test_models.py
  • tests/test_project/tests/test_model.py
  • tests/test_project/migrations/0010_alter_book_options_alter_shelf_options.py
**/*

📄 CodeRabbit inference engine (Custom checks)

**/*: For bug fixes in core user-facing functionality, fix the root cause rather than hiding or bypassing the problem.
Bug fixes must include a regression test that reproduces the bug and fails when the fix is removed, except for valid exceptions such as one-line fixes or impractical GitHub Actions workflow fixes.
User-interface bug fixes must include a Selenium browser regression test; missing coverage should be reported as a warning.
Tests must be deterministic and non-flaky; avoid dependence on timing, sleeps, system time, randomness without a fixed seed, race conditions, network services, filesystem state, environment-specific configuration, execution order, shared global state, hardcoded ports, or improperly awaited asynchronous operations.
When a change request modifies documented behavior, update the documentation to describe the new behavior.
Pull requests containing UI changes must include screenshots or screen recordings in the pull request description.
Update tests for non-trivial behavior changes and validate the modified behavior.
Flag changes that may break existing behavior or public APIs unless a clear migration path is provided.
Feature requests must have an issue explaining the feature, validated and accepted by an organization member through labels or project assignment.
New features must be documented; heavily UI-related features should have a dedicated documentation section or page.
Add tests for new features without significantly decreasing coverage; prefer Selenium browser tests for UI-impacting features.
Non-organization members must target maintainer-validated issues with at least one label other than wontfix or invalid and assignment to either the OpenWISP Contributor's Board or OpenWISP Priorities for next releases project.
Flag potential security vulnerabilities.
Flag obvious performance regressions such as heavy loops, repeated I/O, or unoptimized queries.
Cryptic or non-obvious code, including regexes, complex shell commands, and ...

Files:

  • openwisp_utils/metric_collection/tests/test_models.py
  • tests/test_project/tests/test_model.py
  • openwisp_utils/base.py
  • docs/developer/other-utilities.rst
  • openwisp_utils/metric_collection/migrations/0002_alter_consent_options.py
  • tests/test_project/migrations/0010_alter_book_options_alter_shelf_options.py

⚙️ CodeRabbit configuration file

**/*: - Flag potential security vulnerabilities

  • Flag obvious performance regressions, such as heavy loops, repeated I/O, or unoptimized queries

  • Flag unused or redundant code

  • Flag outdated or incorrect comments/docstrings

  • Ensure new code handles errors properly:

    • Log errors that cannot be resolved by the user with error level
    • Log unusual conditions with warning level
    • Log important background actions with info level
    • Provide user-facing messages for errors that the user can solve autonomously (for example, validation errors)

Files:

  • openwisp_utils/metric_collection/tests/test_models.py
  • tests/test_project/tests/test_model.py
  • openwisp_utils/base.py
  • docs/developer/other-utilities.rst
  • openwisp_utils/metric_collection/migrations/0002_alter_consent_options.py
  • tests/test_project/migrations/0010_alter_book_options_alter_shelf_options.py
**/*tests*/**

⚙️ CodeRabbit configuration file

**/*tests*/**: Ensure tests cover relevant success, error, boundary, and unusual
input scenarios.

Flag tests that depend on arbitrary sleeps, uncontrolled system time,
specific timezones, unseeded randomness, network access, external
services, execution order, shared mutable state, hardcoded ports, or
asynchronous operations that are not properly awaited.

Files:

  • openwisp_utils/metric_collection/tests/test_models.py
  • tests/test_project/tests/test_model.py
  • tests/test_project/migrations/0010_alter_book_options_alter_shelf_options.py
**/*.{md,rst,txt}

📄 CodeRabbit inference engine (AGENTS.md)

Update documentation when behavior, settings, public APIs, setup steps, QA rules, or supported versions change

Files:

  • docs/developer/other-utilities.rst
**/*.{md,rst}

⚙️ CodeRabbit configuration file

**/*.{md,rst}: Verify that documentation remains consistent with the implemented
behavior and does not reference deprecated or removed functionality.

Files:

  • docs/developer/other-utilities.rst
🧠 Learnings (1)
📚 Learning: 2026-06-15T22:45:01.529Z
Learnt from: nemesifier
Repo: openwisp/openwisp-utils PR: 701
File: setup.py:72-72
Timestamp: 2026-06-15T22:45:01.529Z
Learning: When reviewing changes that require a minimum Selenium Python version for specific APIs (e.g., BiDi features like `Options.enable_bidi`, console/message handlers like `Script.add_console_message_handler`, or event handlers like `BrowsingContext.add_event_handler`), do not use the Selenium API docs site (`https://www.selenium.dev/selenium/docs/api/py/`) as the source of introduction/version history, since it reflects the latest API shape. Instead, confirm feature availability by checking the official Python changelog (`py/CHANGES` in the Selenium repo) and/or inspecting the Selenium source (tags/commits corresponding to candidate versions). Only accept the stated minimum version after verifying that the referenced APIs exist in that Selenium version (e.g., Selenium 4.32.0 includes the BiDi APIs used by openwisp-utils’ BiDi-related PR `#701` as of that version).

Applied to files:

  • openwisp_utils/metric_collection/tests/test_models.py
  • tests/test_project/tests/test_model.py
  • openwisp_utils/base.py
  • openwisp_utils/metric_collection/migrations/0002_alter_consent_options.py
  • tests/test_project/migrations/0010_alter_book_options_alter_shelf_options.py
🔇 Additional comments (5)
openwisp_utils/base.py (1)

26-26: LGTM!

docs/developer/other-utilities.rst (1)

30-34: LGTM!

openwisp_utils/metric_collection/migrations/0002_alter_consent_options.py (1)

13-16: LGTM!

tests/test_project/migrations/0010_alter_book_options_alter_shelf_options.py (1)

13-20: LGTM!

openwisp_utils/metric_collection/tests/test_models.py (1)

1-3: LGTM!

Also applies to: 26-42

Comment thread tests/test_project/tests/test_model.py
@nemesifier
nemesifier force-pushed the change/timestamped-model-ordering branch from a121fe3 to dc0b2ef Compare August 5, 2026 20:24
@nemesifier

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Aug 5, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai

coderabbitai Bot commented Aug 5, 2026

Copy link
Copy Markdown

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

@nemesifier

Copy link
Copy Markdown
Member Author

@coderabbitai resolve

@coderabbitai

coderabbitai Bot commented Aug 5, 2026

Copy link
Copy Markdown
✅ Action performed

Comments resolved and changes approved.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[change] Standardize default ordering for timestamped models

1 participant