feat: Add comprehensive Python testing infrastructure with Poetry #451
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.
Add Python Testing Infrastructure
Summary
This PR establishes a comprehensive testing infrastructure for the soweego Python project using modern Python testing tools and best practices. The setup provides a solid foundation for writing and maintaining tests going forward.
Changes Made
Package Management
pyproject.toml
with Poetry as the package managerTesting Framework Setup
Pytest Configuration:
Coverage Configuration:
Directory Structure
Test Fixtures (conftest.py)
Created comprehensive fixtures for common testing needs:
temp_dir
/temp_file
: Temporary file system resourcesmock_config
: Configuration dictionary for testingmock_database_session
: SQLAlchemy session mockmock_http_client
: HTTP client mock for API testingsample_entity_data
: Wikidata entity test datacli_runner
: Click CLI testing runnermock_wikidata_api
: Wikidata API mocksample_csv_data
/sample_json_data
: Test data filesisolated_filesystem
: Isolated test environmentmock_logger
: Logger mock for testing logging behaviormock_sparql_results
: SPARQL query result mocksAdditional Configuration
How to Use
Installation
Running Tests
Writing New Tests
tests/unit/
tests/integration/
conftest.py
for common test needs@pytest.mark.unit
,@pytest.mark.integration
, or@pytest.mark.slow
Validation
All infrastructure components have been validated with 18 passing tests that verify:
Notes
fail_under = 80
lines inpyproject.toml
.gitignore
to avoid dependency conflictsNext Steps