Skip to content

tests: refactor test_sort.py#6718

Open
snejus wants to merge 10 commits into
migrate-helper-test-classesfrom
refactor-test-sort
Open

tests: refactor test_sort.py#6718
snejus wants to merge 10 commits into
migrate-helper-test-classesfrom
refactor-test-sort

Conversation

@snejus

@snejus snejus commented Jun 7, 2026

Copy link
Copy Markdown
Member
  • Consolidates test/dbcore/test_sort.py around a smaller set of parameterized pytest cases instead of many near-duplicate test branches.

  • Simplifies the test architecture by:

    • sharing library setup through fixtures,
    • expressing sort coverage through query strings instead of separate sort object permutations,
    • grouping related behavior into broader, table-driven tests.
  • Tightens config-related tests to use the config fixture, which keeps sort override assertions local to each test and avoids leaking global config state.

  • Reduces duplicate edge-case coverage for missing fields and mixed field presence by keeping one clear representative path for each behavior.

  • High-level impact:

    • no production sorting logic changes,
    • same core sort behavior remains covered,
    • test suite becomes easier to read, maintain, and extend,
    • future sort changes should require updating fewer places.

Copilot AI review requested due to automatic review settings June 7, 2026 16:36
@snejus snejus requested a review from a team as a code owner June 7, 2026 16:36
@github-actions

github-actions Bot commented Jun 7, 2026

Copy link
Copy Markdown

Thank you for the PR! The changelog has not been updated, so here is a friendly reminder to check if you need to add an entry.

@codecov

codecov Bot commented Jun 7, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 74.51%. Comparing base (2ad2368) to head (e003c31).
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@                       Coverage Diff                       @@
##           migrate-helper-test-classes    #6718      +/-   ##
===============================================================
- Coverage                        74.72%   74.51%   -0.22%     
===============================================================
  Files                              162      162              
  Lines                            20820    20820              
  Branches                          3298     3298              
===============================================================
- Hits                             15558    15514      -44     
- Misses                            4505     4549      +44     
  Partials                           757      757              

see 2 files with indirect coverage changes

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copilot AI 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.

Pull request overview

grug see PR want make test/dbcore/test_sort.py smaller and less copy-paste. grug like less duplicate, but grug see some new tests now depend on tie order / same-path tricks, so test may go flaky and maybe break on windows.

Changes:

  • replace many small test classes with a few parametrized pytest tests
  • move library setup into class-scoped fixtures via TestHelper
  • move sort coverage to query-string form (ex: "year+") instead of many sort object combos

Comment thread test/dbcore/test_sort.py Outdated
Comment thread test/dbcore/test_sort.py Outdated
Comment thread test/dbcore/test_sort.py Outdated
Comment thread test/dbcore/test_sort.py Outdated
Comment thread test/dbcore/test_sort.py Outdated
Comment thread test/dbcore/test_sort.py Outdated
Comment thread test/dbcore/test_sort.py
Comment thread test/dbcore/test_sort.py
@snejus snejus force-pushed the refactor-test-sort branch 3 times, most recently from c0ff2bb to 1080ae6 Compare June 8, 2026 03:01
@snejus snejus requested a review from Copilot June 8, 2026 03:14

Copilot AI 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.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 2 comments.

Comment thread test/dbcore/test_sort.py
Comment on lines +160 to +167
def test_config_overrides(self, config):
config.set({"sort_item": "artist-", "sort_album": "albumartist-"})

def test_fixed_field_case_insensitive(self):
config["sort_case_insensitive"] = True
q = "album+"
results = list(self.lib.albums(q))
assert results[0].album == "album"
assert results[1].album == "Album A"
artists = [r.artist for r in self.lib.items()]
albumartists = [r.albumartist for r in self.lib.albums()]

def test_fixed_field_case_sensitive(self):
config["sort_case_insensitive"] = False
q = "album+"
results = list(self.lib.albums(q))
assert results[0].album == "Album A"
assert results[-1].album == "album"
assert artists == ["Two", "Three", "Three", "One"]
assert albumartists == ["Foo", "Baz", "Bar"]
Comment thread test/dbcore/test_sort.py
@snejus snejus force-pushed the migrate-helper-test-classes branch from f38bad8 to b6610ac Compare June 8, 2026 22:45
@snejus snejus force-pushed the refactor-test-sort branch from 1080ae6 to 4fe22c5 Compare June 8, 2026 22:45
@snejus snejus force-pushed the migrate-helper-test-classes branch from b6610ac to 8e7195c Compare June 11, 2026 16:05
@snejus snejus force-pushed the refactor-test-sort branch from 4fe22c5 to 52a1b78 Compare June 11, 2026 16:05
@snejus snejus force-pushed the migrate-helper-test-classes branch from 8e7195c to 9080832 Compare June 11, 2026 16:11
snejus added 10 commits June 11, 2026 20:42
- Consolidate duplicate ascending sort tests across item and album fixed and
  flexible fields.
- Replace duplicate direct MultipleSort checks with parametrized query-string
  cases covering single-field, multi-field, fixed, flex, and computed sort
  behavior.
- Reduce test repetition while keeping the same sort behavior coverage.
- Consolidate duplicate sort test coverage with parametrized cases.
- Keep missing-field and mixed-presence behavior covered while reducing repeated
  assertions.
- Combine default and override sort assertions for items and albums.
- Use the config fixture and exact ordered results to avoid global config state.
@snejus snejus force-pushed the migrate-helper-test-classes branch from 9080832 to 2ad2368 Compare June 11, 2026 19:43
@snejus snejus force-pushed the refactor-test-sort branch from 52a1b78 to e003c31 Compare June 11, 2026 20:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants