Change test for fake extension that wont work (#1266)

This commit is contained in:
CaliBrain
2026-08-24 17:54:10 -04:00
committed by GitHub
parent 9bcf595111
commit a5595cf9f1
5 changed files with 15 additions and 15 deletions
+3 -3
View File
@@ -327,7 +327,7 @@ def _split_mam_formats(raw_title: str) -> tuple[list[str], list[str]]:
heuristics for other indexers).
Tokens after the "/" that Shelfmark does not know as a book or audiobook format
(e.g. ``[ENG / MP4]``) are returned separately so the UI can warn that the release
(e.g. ``[ENG / AVI]``) are returned separately so the UI can warn that the release
will download but cannot be processed, instead of showing a bare content-type icon
that looks like an ordinary result.
"""
@@ -572,8 +572,8 @@ def _prowlarr_result_to_release(
"info_hash": result.get("infoHash"),
"formats": formats or None,
"formats_display": formats_display,
# Format tokens the indexer declared but Shelfmark can't process (#1264-style
# "[ENG / MP4]"). Lets the UI warn instead of showing a bare content icon.
# Format tokens the indexer declared but Shelfmark can't process (e.g. a MAM
# "[ENG / AVI]"). Lets the UI warn instead of showing a bare content icon.
"unrecognized_formats": unrecognized_formats or None,
# Raw torznab attributes for rich tooltips (enriched indexers)
"torznab_attrs": result.get("torznabAttrs"),
+1 -1
View File
@@ -425,7 +425,7 @@ export const ReleaseCell = ({
const primaryFormat = formats?.[0] || null;
const additionalFormats = formats?.slice(1) || [];
// The indexer named a format Shelfmark can't process (e.g. MAM "[ENG / MP4]").
// The indexer named a format Shelfmark can't process (e.g. MAM "[ENG / AVI]").
// Downloading it would only fail post-processing, so warn instead of showing the
// bare content-type icon that makes it look like any other result.
const unrecognizedFormats = primaryFormat ? [] : getUnrecognizedReleaseFormats(release);
@@ -42,16 +42,16 @@ describe('releaseFormats.getReleaseFormats', () => {
describe('releaseFormats.getUnrecognizedReleaseFormats', () => {
it('returns normalized, deduplicated unrecognized formats from extra', () => {
const release = buildRelease({
extra: { unrecognized_formats: ['MP4', ' mp4 ', 'WEBM'] },
extra: { unrecognized_formats: ['AVI', ' avi ', 'WEBM'] },
});
expect(getUnrecognizedReleaseFormats(release)).toEqual(['mp4', 'webm']);
expect(getUnrecognizedReleaseFormats(release)).toEqual(['avi', 'webm']);
});
it('accepts a single string value', () => {
const release = buildRelease({ extra: { unrecognized_formats: 'MP4' } });
const release = buildRelease({ extra: { unrecognized_formats: 'AVI' } });
expect(getUnrecognizedReleaseFormats(release)).toEqual(['mp4']);
expect(getUnrecognizedReleaseFormats(release)).toEqual(['avi']);
});
it('returns an empty list when nothing was flagged', () => {
+1 -1
View File
@@ -36,7 +36,7 @@ export function getReleaseFormats(release: Release): string[] {
/**
* Format tokens the indexer declared but the backend could not map to a known
* book/audiobook format (e.g. MyAnonamouse "[ENG / MP4]"). Such a release will
* book/audiobook format (e.g. MyAnonamouse "[ENG / AVI]"). Such a release will
* download but fail post-processing, so the UI warns instead of showing a bare
* content-type icon.
*/
+6 -6
View File
@@ -1411,12 +1411,12 @@ class TestSplitMamFormats:
def test_unrecognized_only_is_surfaced(self):
from shelfmark.release_sources.prowlarr.source import _split_mam_formats
assert _split_mam_formats("The Martian by Andy Weir [ENG / MP4]") == ([], ["mp4"])
assert _split_mam_formats("The Martian by Andy Weir [ENG / AVI]") == ([], ["avi"])
def test_mixed_keeps_both_sides(self):
from shelfmark.release_sources.prowlarr.source import _split_mam_formats
assert _split_mam_formats("Title [ENG / M4B MP4]") == (["m4b"], ["mp4"])
assert _split_mam_formats("Title [ENG / M4B AVI]") == (["m4b"], ["avi"])
def test_no_structured_bracket(self):
from shelfmark.release_sources.prowlarr.source import _split_mam_formats
@@ -1428,7 +1428,7 @@ class TestSplitMamFormats:
from shelfmark.release_sources.prowlarr.source import _extract_mam_formats
assert _extract_mam_formats("Title [ENG / MP3]") == ["mp3"]
assert _extract_mam_formats("Title [ENG / MP4]") == []
assert _extract_mam_formats("Title [ENG / AVI]") == []
class TestUnrecognizedFormatOnRelease:
@@ -1449,13 +1449,13 @@ class TestUnrecognizedFormatOnRelease:
from shelfmark.release_sources.prowlarr.source import _prowlarr_result_to_release
release = _prowlarr_result_to_release(
self._result("The Martian by Andy Weir [ENG / MP4]"),
self._result("The Martian by Andy Weir [ENG / AVI]"),
"audiobook",
enable_format_detection=True,
)
assert release.format is None
assert release.extra["formats"] is None
assert release.extra["unrecognized_formats"] == ["mp4"]
assert release.extra["unrecognized_formats"] == ["avi"]
def test_recognized_format_leaves_unrecognized_empty(self):
from shelfmark.release_sources.prowlarr.source import _prowlarr_result_to_release
@@ -1472,6 +1472,6 @@ class TestUnrecognizedFormatOnRelease:
from shelfmark.release_sources.prowlarr.source import _prowlarr_result_to_release
release = _prowlarr_result_to_release(
self._result("The Martian by Andy Weir [ENG / MP4]"), "audiobook"
self._result("The Martian by Andy Weir [ENG / AVI]"), "audiobook"
)
assert release.extra["unrecognized_formats"] is None