Skip to content

871 increase test coverage for holdings_csv_transformer#936

Open
mtrineyev wants to merge 6 commits intomainfrom
871-increace-test-coverage-for-holdings_csv_transformer
Open

871 increase test coverage for holdings_csv_transformer#936
mtrineyev wants to merge 6 commits intomainfrom
871-increace-test-coverage-for-holdings_csv_transformer

Conversation

@mtrineyev
Copy link
Collaborator

@mtrineyev mtrineyev commented Jul 8, 2025

Purpose

Fixes #871

Changes Made in this PR

  • refactored typos, long lines and some variables defenition

Code Review Specifics

  • Read the code, make suggestions
  • Increase test coverage for HoldingsCsvTransformer file not found scenarios

Task Checklist

  • Ran nox -rs safety.
  • Ran pre-commit run --all-files
  • Tests cover new or modified code.
  • Ran test suite: nox -rs tests
  • Code runs and outputs default usage info: python -m folio_migration_tools -h
  • Documentation updated

How to Verify

python -m pytest -v ./tests/test_holdings_csv_transformer.py

@mtrineyev mtrineyev self-assigned this Jul 8, 2025
@bltravis
Copy link
Collaborator

@mtrineyev Should this one still be considered "in-progress"?

@mtrineyev mtrineyev changed the title 871 increace test coverage for holdings_csv_transformer 871 increase test coverage for holdings_csv_transformer Jul 17, 2025
@mtrineyev mtrineyev marked this pull request as draft July 30, 2025 09:16
@codecov
Copy link

codecov bot commented Jul 30, 2025

Codecov Report

❌ Patch coverage is 76.27119% with 14 lines in your changes missing coverage. Please review.
✅ Project coverage is 74.92%. Comparing base (a79e9c3) to head (3989a8c).
⚠️ Report is 16 commits behind head on main.

Files with missing lines Patch % Lines
..._tools/migration_tasks/holdings_csv_transformer.py 51.72% 14 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #936      +/-   ##
==========================================
+ Coverage   74.83%   74.92%   +0.08%     
==========================================
  Files         106      106              
  Lines       12841    12883      +42     
  Branches     1677     1680       +3     
==========================================
+ Hits         9610     9652      +42     
  Misses       2900     2900              
  Partials      331      331              
Flag Coverage Δ
unittests 74.92% <76.27%> (+0.08%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@mtrineyev mtrineyev requested a review from bltravis July 30, 2025 09:29
@btravisebsco btravisebsco marked this pull request as ready for review July 31, 2025 02:22
Copy link
Collaborator

@bltravis bltravis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See inline comments.

)
else:
# Regular holding. Merge according to criteria
# Regular holding. Merge, according to criteria
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No comma here

call_number_type_map_f, "Found %s rows in call number type map"
)
except FileNotFoundError:
logging.critical(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mtrineyev The entry point function in main.py catches file not found errors. We should re-raise and let let the exception propagate, rather than calling sys.exit here, directly.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, done

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just raise should be sufficient. We want to preserve the original exception context.

f"Location map file {self.task_configuration.location_map_file_name} "
"not found. Halting..."
)
sys.exit(1)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See above

"not found. Halting..."
)
return mapped_fields, holdings_map
sys.exit(1)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See above

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You'll need to adjust the tests to account for allowing the exception to propagate.

@sonarqubecloud
Copy link

)
from folio_migration_tools.migration_report import MigrationReport
from folio_migration_tools.migration_tasks.holdings_csv_transformer import (
from src.folio_migration_tools.migration_tasks.holdings_csv_transformer import (
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure why you've added src to the beginning of the import statement(s) here. The test should be run after the project is "installed" in the environment, so the regular imports should work. Or am I misunderstanding something?

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.

Create fixtures, compile test datasets, and mock mapper classes for holdings_csv_transformer.py

2 participants