test: improve test coverage to 93% (Issue #16) - #18
Merged
Conversation
- Add tests for attachment error handling (non-tuple and False results) - Add tests for dry-run archive mode - Add tests for archive error handling (ConnectionError, OSError) - Add tests for processed UID save errors after processing - Add tests for file statistics error handling - Add test for psutil memory peak update Improves email_processor.py coverage from 92% to 94% Overall project coverage: 93%
45 tasks
|
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
- Add test for mock_mode logging - Add test for cleanup unexpected error - Add tests for message_walk errors (AttributeError, TypeError) - Add test for archive IMAP error Improves email_processor.py coverage from 94% to 95% Overall project coverage: 93%
- Add test for platform.system() exception handling - Add test for Linux getuid when getuid is None (getattr returns None) - Add test for Linux getuid with UID (works on all platforms) - Add test for Linux getuid exception (works on all platforms) Improves fingerprint.py coverage from 87% to 100% Overall project coverage: 93%
…ix SMTP tests to check info() instead of print() when has_rich=False - Fix UI error tests to properly mock ConfigLoader.load() method - Fix integration tests to handle processed UID file date variations - Make download_attachments() return ProcessingResult for testability - Fix duplicate assignment in test_download_attachments_already_processed - All 707 tests now pass (705 unit + 2 integration tests fixed)
…MTP and UI tests to patch get_imap_password in smtp module instead of auth module - Fix password tests to patch sys.platform in passwords module - Fix test_smtp_send_folder_partial_failure_with_rich_console UI assertion - All 88 tests now pass (15 skipped on Windows for permission checks)
…ests - Use MockPathClass with __new__ to properly mock Path constructor - Add stat.filemode patch inside test context managers - Fix indentation issues in test_set_password_file_permission_warning - Tests should now pass on Linux CI (skipped on Windows as expected)
…ord tests - Replace MockPathClass with path_factory function for better compatibility - Add spec=Path to mock_path for better type checking - Add __str__ and __fspath__ mocks for Path compatibility - Tests should now properly trigger permission warnings on Linux CI
…ts - Ensure Path is properly mocked as callable using MagicMock(side_effect=path_factory) - Add assert_called() checks for mock_path.stat() to verify permission check runs - Tests should now properly trigger permission warnings on Linux CI
…s - Fix indentation error in test_set_password_file_permission_warning_with_rich_console - Rename mock_filemode to mock_filemode_patch in both tests to avoid PLR1704
…Rename mock_filemode to mock_filemode_patch in test_set_password_file_permission_warning - This ensures consistency and avoids PLR1704 linting errors
…s - Remove @patch('stat.filemode') decorator that was patching global stat.filemode - Use only the local patch inside the test context for email_processor.cli.commands.passwords.stat.filemode - This should fix the permission warning tests on Linux CI
…d optional ui parameter to validate_config, load_config, and ConfigLoader methods - Use ui.warn() when UI is available, fallback to print() otherwise - Update all call sites to pass UI instance when available - This ensures consistent output formatting through CLIUI
…ate test_validate_config_file_success to expect ui parameter - Update test_main_custom_config_path to check ui parameter in call args - Update test_validate_config_file_validation_error to expect ui parameter - All config and main tests now pass with new UI parameter
…tat.filemode() calls - Simplify warning message checks - Ensure tests fail with clear error messages if stat.filemode() is not called or warning is not shown
…l_stat_result.st_mode to verify condition - Add octal representation for better debugging - Verify stat.filemode() is called with correct st_mode value
… actual_stat_result.st_mode to verify condition - Add octal representation for better debugging - Verify stat.filemode() is called with correct st_mode value
… in __main__.py as 'from email_processor.cli import CLIUI' - Need to patch 'email_processor.__main__.CLIUI' to ensure mock is used - This fixes permission warning tests where ui.warn() was called but not captured
…Update test_set_password_file_permission_warning_with_rich_console to use __main__.CLIUI patch
…or if statement and return statements in path_factory - This was causing a syntax error
…date test_set_password_file_permission_warning_with_rich_console to use __main__.CLIUI patch - This ensures the mock UI is used when main() creates CLIUI instance
…py with 13 tests for CLI commands end-to-end - Add test_full_cycle_integration.py with 3 tests for full email processing cycle - Cover config init/validate, status, password set/clear, send file/folder, fetch, run commands - Cover full cycle: download attachments -> send via SMTP - Cover error handling: missing/invalid commands, config errors - All 16 integration tests passing
- Added 9 new tests to cover previously uncovered lines: - passwords.py: clear_password success, interactive input, no encryption, Unix permission check - smtp.py: rich console messages for no new files and skipped files, missing --to error - args.py: mutually exclusive verbose/quiet options - loader.py: ui.warn() when ui is provided - Updated CI to use --cov-fail-under=95 to prevent coverage regression - Coverage improved: 38 uncovered lines (down from 59) - All 750 tests passing (732 passed, 18 skipped)
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.
Description
This PR improves test coverage from 92% to 93% by adding comprehensive tests for
email_processor.py.Changes
email_processor.pycovering:Test Coverage
Related Issue
Fixes #16
Testing
All tests pass:
Checklist