-
-
Notifications
You must be signed in to change notification settings - Fork 598
feat(scan): per-field artwork priority overrides #3838
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| from types import SimpleNamespace | ||
| from unittest.mock import patch | ||
|
|
||
| from handler.scan_handler import ( | ||
| MetadataSource, | ||
| get_priority_ordered_metadata_sources, | ||
| ) | ||
|
|
||
|
|
||
| def _fake_config(**overrides): | ||
| return SimpleNamespace( | ||
| SCAN_METADATA_PRIORITY=["igdb", "moby", "ss"], | ||
| SCAN_ARTWORK_PRIORITY=["igdb", "moby", "ss"], | ||
| SCAN_ARTWORK_PRIORITY_OVERRIDES=overrides, | ||
| ) | ||
|
|
||
|
|
||
| def test_artwork_field_falls_back_to_shared_priority(): | ||
| """A field with no override uses SCAN_ARTWORK_PRIORITY.""" | ||
| available = [MetadataSource.SS, MetadataSource.IGDB] | ||
| with patch("handler.scan_handler.cm.get_config", return_value=_fake_config()): | ||
| ordered = get_priority_ordered_metadata_sources(available, "url_cover") | ||
|
|
||
| assert ordered == [MetadataSource.IGDB, MetadataSource.SS] | ||
|
|
||
|
|
||
| def test_per_field_override_reorders_only_that_field(): | ||
| """A cover override wins for url_cover but not for url_screenshots.""" | ||
| available = [MetadataSource.IGDB, MetadataSource.SS] | ||
| config = _fake_config(url_cover=["ss", "igdb"]) | ||
| with patch("handler.scan_handler.cm.get_config", return_value=config): | ||
| cover = get_priority_ordered_metadata_sources(available, "url_cover") | ||
| screenshots = get_priority_ordered_metadata_sources( | ||
| available, "url_screenshots" | ||
| ) | ||
|
|
||
| # Cover honors the override (ss first)... | ||
| assert cover == [MetadataSource.SS, MetadataSource.IGDB] | ||
| # ...while screenshots keep the shared artwork order (igdb first). | ||
| assert screenshots == [MetadataSource.IGDB, MetadataSource.SS] | ||
|
|
||
|
|
||
| def test_sources_absent_from_priority_are_appended(): | ||
| """Available sources not named in the priority list still appear, last.""" | ||
| available = [MetadataSource.SS, MetadataSource.MOBY, MetadataSource.LAUNCHBOX] | ||
| config = _fake_config(url_cover=["ss"]) | ||
| with patch("handler.scan_handler.cm.get_config", return_value=config): | ||
| ordered = get_priority_ordered_metadata_sources(available, "url_cover") | ||
|
|
||
| assert ordered[0] == MetadataSource.SS | ||
| assert set(ordered) == set(available) | ||
|
|
||
|
|
||
| def test_metadata_priority_is_unaffected_by_artwork_overrides(): | ||
| """Artwork overrides must never leak into the metadata priority pass.""" | ||
| available = [MetadataSource.SS, MetadataSource.IGDB] | ||
| config = _fake_config(url_cover=["ss", "igdb"]) | ||
| with patch("handler.scan_handler.cm.get_config", return_value=config): | ||
| ordered = get_priority_ordered_metadata_sources(available, "metadata") | ||
|
|
||
| assert ordered == [MetadataSource.IGDB, MetadataSource.SS] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.