Skip to content

test: improve coverage from 66% to 84%#35

Merged
jakebromberg merged 4 commits intomainfrom
test/coverage-improvement
Mar 10, 2026
Merged

test: improve coverage from 66% to 84%#35
jakebromberg merged 4 commits intomainfrom
test/coverage-improvement

Conversation

@jakebromberg
Copy link
Member

Closes #34

Summary

  • Add pure unit tests for utilities (format_bytes, format_size, is_compilation_artist) and main() functions (csv_to_tsv, fix_csv_newlines, filter_csv)
  • Add mocked unit tests for orchestration logic (wait_for_postgres, run_sql_file, report_sizes, CLI validation, MySQL query extraction)
  • Add PostgreSQL integration tests for dedup_releases, import_csv, and verify_cache coverage gaps

No production code changes. All 593 tests pass (9 skipped MySQL tests).

Test plan

  • pytest tests/unit/ -v -- 411 unit tests pass
  • DATABASE_URL_TEST=... pytest -m 'not mysql' -v -- 593 tests pass, 9 skipped
  • Coverage improved from 66% to 84%

Jake Bromberg added 4 commits March 10, 2026 00:00
Cover matching.is_compilation_artist, artist_splitting edge cases (_split_trailing_and single-component, _try_ampersand_split, numeric comma guard), csv_to_tsv.main(), fix_csv_newlines.fix_csv_dir/main(), filter_csv edge cases and main(), verify_cache.format_bytes/print_report, and export_to_sqlite.format_size/_do_export table/FTS verification.
…enrich_library_artists, and import_csv

Cover wait_for_postgres, run_sql_file, run_sql_statements_parallel error paths, report_sizes, convert_and_filter command construction, enrich_library_artists command construction, _load_or_create_state resume modes, main() input validation, parse_args validation, MySQL extraction functions (extract_alternate_names, extract_cross_referenced_artists, extract_release_cross_ref_artists), enrich main() with and without MySQL, and import_csv main() dispatch to _import_tables vs _import_tables_parallel.
…cache coverage gaps

Add integration tests exercising previously uncovered code paths against a real PostgreSQL database:

dedup_releases.py (63% -> 73%): TestEnsureDedupIdsAlreadyExists verifies the early-return path when dedup_delete_ids table already exists. TestAddTrackConstraintsAndIndexes verifies FK constraints and GIN trigram indexes on track tables. TestAddConstraintsAndIndexes verifies the wrapper function creates both base and track constraints.

import_csv.py (86% -> 97%): TestPopulateCacheMetadata verifies COPY-based bulk insert of cache_metadata rows. TestImportArtwork verifies primary/fallback image selection, invalid release_id skipping, and empty URI handling. TestImportArtworkMissing and TestCreateTrackCountTableMissing verify the missing-file warning paths. TestImportTables verifies sequential import of table configs including missing CSV handling.

verify_cache.py (83% -> 86%): TestGetTableSizes verifies asyncpg-based row count and size queries across all release tables. TestCountRowsToDelete verifies row counting for single, multiple, empty, and nonexistent release ID sets. TestPruneReleases verifies CASCADE deletion of releases and child rows.
@jakebromberg jakebromberg merged commit c8e6076 into main Mar 10, 2026
3 checks passed
@jakebromberg jakebromberg deleted the test/coverage-improvement branch March 10, 2026 07:22
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.

Improve test coverage from 66% to 84%

1 participant