Expand test matrix: +143 tests across 4 new test files#1330
Merged
Conversation
Closes the zero-coverage gap on every module and blueprint added in the
quickstart.py refactor sprint, and adds HTTP-level tests for the most
critical untested routes.
New files
---------
tests/test_bundle_artifacts.py (+75 tests)
Pure-function tests for all 25 helpers in modules/bundle_artifacts.py:
yaml_path_suffix, normalize_bundle_member_name, is_allowed_bundle_member
(including path-traversal rejection), normalize_config_name,
safe_bundle_name, safe_overlay_bundle_slug, is_overlay_source_override_file_key,
parse_managed_overlay_image_relative_path (both layouts),
normalized_managed_overlay_image_relative_path, display_managed_overlay_image_location,
dump_yaml_text, build_config_bundle (empty/fonts/artifacts/redacted/empty-text
cases), get_custom_font_files (empty dir, font discovery, deduplication),
iter_bundle_artifacts (smoke), iter_overlay_source_bundle_artifacts (smoke),
bundle_write_artifact (single file, directory recursion, missing source,
redacted YAML content).
No Flask client needed -- purely isolated unit tests.
tests/test_tmdb_lookup.py (+35 tests)
Tests for all 6 helpers in modules/tmdb_lookup.py.
normalize_tmdb_library_media_type: movie/show variant normalization,
unknown passthrough.
build_tmdb_library_type_warning: matching types (empty), mismatch in both
directions, unknown result_type, custom value_label.
get_active_tmdb_api_key: no session, DB-stored apikey, alternate key names.
lookup_tmdb_by_imdb_id: movie hit, show hit, media_type hint ordering (both
directions), 404, 401, no-key, network error, empty results.
lookup_tmdb_numeric_id: movie hit, TVDb ID inclusion, exhausted endpoints,
401 short-circuit, no-key.
lookup_tmdb_external_ids: payload, bad endpoint, HTTP error, missing args.
All HTTP calls mocked via unittest.mock.patch on modules.tmdb_lookup.requests.
tests/test_validate_service_routes.py (+21 tests)
HTTP-level tests for all 14 previously-untested validate_* routes in
blueprints/validation_routes.py.
Parametrized success/failure for tautulli, trakt, mal, webhook (passthrough
routes), radarr/sonarr (tuple-unpack routes), and omdb/github/tmdb/mdblist/
notifiarr (direct-get_json routes).
URL-validation gate tests for gotify and ntfy (bad URL → 400 before
the validator even runs, missing URL → 400).
validate_trakt_token: missing access+client_id → 400, valid token → 200,
401 without refresh_token → 400, network error → 400.
validate_mal_token: missing token → 400, valid token → 200, 401 → 400.
validate_library_service_overrides: endpoint responds (200 or 400).
tests/test_config_and_library_routes.py (+32 tests)
HTTP-level tests for config lifecycle and library autosave.
/activate-config: create new, re-activate existing (created=False),
empty name → 400, missing name → 400, name sanitization.
/clear_session: returns success with and without explicit name.
/clear_data/<name> and /clear_data/<name>/<section>: redirect, DB cleanup.
/autosave_library/<library_id>: success (empty payload), 400 on collection
errors, 400 on overlay errors, 400 on normalization errors, normalized
flag propagation.
/autosave-imagemaid: success, validated=False when config changed while
previously-validated.
/validate-imagemaid: 200 when valid (command_preview present), 400 when
invalid.
/lookup_template_string_value: missing preset/value → 400, unknown preset
→ 400, numeric_id hit, numeric_id type-mismatch warning, imdb_id_tmdb
hit, imdb_id_plex missing library_name, tmdb_collection_id hit,
tmdb_collection_id no key.
Summary
-------
Before: 801 tests, 37/120 routes exercised (31%)
After: 944 tests, ~60/120 routes exercised (~50%)
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Closes the zero-coverage gap on every module and blueprint added in the quickstart.py refactor sprint, and adds HTTP-level tests for the most critical untested routes.
Before: 801 tests, 37/120 routes exercised (31%)
After: 944 tests, ~60/120 routes exercised (~50%)
New files
tests/test_bundle_artifacts.py(+75 tests)Pure-function tests for all 25 helpers in
modules/bundle_artifacts.py-- no Flask client or monkeypatching needed.What's tested:
yaml_path_suffixnormalize_bundle_member_nameis_allowed_bundle_member../../etc/passwd)normalize_config_namesafe_bundle_namesafe_overlay_bundle_slugis_overlay_source_override_file_keyfile,file_N, unrelated keysparse_managed_overlay_image_relative_pathnormalized_managed_overlay_image_relative_pathdisplay_managed_overlay_image_locationdump_yaml_textbuild_config_bundleget_custom_font_filesiter_bundle_artifactsiter_overlay_source_bundle_artifactsbundle_write_artifacttests/test_tmdb_lookup.py(+35 tests)All 6 helpers in
modules/tmdb_lookup.py. All HTTP calls mocked viaunittest.mock.patchonmodules.tmdb_lookup.requests-- no live network.normalize_tmdb_library_media_typebuild_tmdb_library_type_warningvalue_labelget_active_tmdb_api_keyapikey, alternate key name (api_key)lookup_tmdb_by_imdb_idlookup_tmdb_numeric_idlookup_tmdb_external_idstests/test_validate_service_routes.py(+21 tests)HTTP-level coverage for all 14 previously-untested
validate_*routes inblueprints/validation_routes.py.(response, 400)tuple on failurevalidate_trakt_token: missing access+client_id → 400, valid token → 200, 401 without refresh → 400, network error → 400validate_mal_token: missing token → 400, valid token → 200, 401 → 400validate_library_service_overrides: endpoint responds (200 or 400)Key pattern documented in tests: radarr/sonarr unpack
(response, status_code)tuples while omdb/github/tmdb/mdblist/notifiarr callresult.get_json()directly. The parametrize is split to reflect this.tests/test_config_and_library_routes.py(+32 tests)HTTP-level tests for config lifecycle + library autosave routes.
POST /activate-configPOST /clear_sessionGET /clear_data/<name>GET /clear_data/<name>/<section>POST /autosave_library/<id>normalized=Trueflag propagationPOST /autosave-imagemaidvalidated=Falsewhen config changed while previously validatedPOST /validate-imagemaidcommand_previewwhen valid, 400 when invalidPOST /lookup_template_string_valuenumeric_idhit,numeric_idtype-mismatch warning (level=warning),imdb_id_tmdbhit,imdb_id_plexmissing library_name,tmdb_collection_idhit,tmdb_collection_idno keyGotcha documented:
database.reset_data()does not callCREATE TABLE IF NOT EXISTSbefore the DELETE, unlike every other DB helper. Tests that exercise/clear_sessionor/clear_datacalldatabase.get_unique_config_names()first to ensure the table exists.Test count by file
test_bundle_artifacts.pytest_tmdb_lookup.pytest_config_and_library_routes.pytest_validate_service_routes.pyCI
ruff checkclean on all 4 new files