Migrate to pytest and expand test coverage#20
Merged
Conversation
- Ersätt print-baserade tester med riktiga assertions - Använd parametriserade tester för bättre täckning - Mock:a alla externa API-anrop med requests-mock - Lägg till pytest-konfiguration i pyproject.toml - Skapa GitHub Actions workflow för CI/CD - Alla 40 tester passerar (100% framgång) Tester körs nu automatiskt vid push/PR och använder: - Test markers (unit, integration, api, slow) - Coverage tracking (13% för närvarande) - Mockade Riksdagen API-svar - pytest fixtures för delad testdata 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
- .coverage (coverage data file) - htmlcov/ (HTML coverage report) - .pytest_cache/ (pytest cache) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
…oming changes - Implemented comprehensive unit tests for the `load_json_file`, `has_expiring_datetime`, `find_expiring_files`, `print_results`, and `save_results_to_file` functions. - Added integration tests to validate the complete workflow of finding expiring documents. - Created unit tests for the `identify_upcoming_changes`, `save_upcoming_file`, `get_doc_ids_for_date`, `get_earliest_pending_date`, and `extract_doc_id_from_filename` functions. - Included edge case tests to ensure robustness against various scenarios, including invalid date formats and handling of special characters.
…ameterized inputs for better coverage and maintainability
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.
Sammanfattning
Migrera hela testsviten från fristående Python-skript till pytest med moderna testmetoder:
Ändringar
Nya filer
pyproject.toml- pytest-konfiguration med markers, coverage-inställningartest/conftest.py- Delade fixtures och API-mocks.github/workflows/test-workflow.yml- GitHub Actions för automatisk testningMigrerade testfiler
test_linking.py- Parametriserade tester för länkgenerering (9 tester)test_title_temporal.py- Unit-tester för temporal titellogik (7 tester)test_integrated_title_temporal.py- Integrationstester med tmp_path (5 tester)test_predocs.py- API-tester med mocking (19 tester)Testresultat
✅ Alla 40 tester passerar (100% framgång)
pytest -v # 40 passed in 1.33sTest coverage
Test markers
CI/CD
GitHub Actions workflow kör automatiskt vid:
Tester körs på Python 3.10, 3.11, 3.12 och genererar coverage-rapporter.
Förbättringar
Tidigare:
python test/test_*.pyNu:
🤖 Generated with Claude Code