Summary
All 107 existing tests are integration tests that require a live IBM i server connection. There are zero unit tests and zero mocks. This means:
- Tests cannot run in standard CI/CD without server access
- Tests cannot run offline during local development
- Error recovery paths and edge cases are untestable
- The test suite is slow (network I/O for every test)
- 7 pool tests are commented out due to job status tracking issues that could be debugged with mocks
Current State
- 107 active tests, all integration (require
VITE_SERVER, VITE_DB_USER, VITE_DB_PASS)
- No
conftest.py — no shared fixtures
- No mocking of WebSocket connections, server responses, or authentication
- Empty test subdirectories (
tests/unit/, tests/integration/, etc.) — a planned reorg that was never completed
- 7 commented-out tests in
pooling_test.py and pep249_test.py due to job status tracking issues
- pytest-cov installed but not used — no coverage metrics collected
- Estimated coverage: ~55-65% overall, ~35% for error handling paths
Proposed Changes
1. Create shared test fixtures (tests/conftest.py)
- Mock WebSocket connection fixture that returns configurable JSON responses
- Mock
DaemonServer credentials fixture
- Factory functions for
QueryResult, ConnectionResult, and other server response types
- Fixtures that configure the mock to simulate error conditions
2. Create unit tests for core components
Priority modules to test in isolation:
| Module |
What to test |
Query / PoolQuery |
State machine transitions (NOT_YET_RUN -> RUN_MORE_DATA_AVAIL -> RUN_DONE -> ERROR) |
Pool |
Scaling logic (add/remove jobs), job selection algorithm, pool exhaustion |
DaemonServer |
Config parsing from dicts, INI files, kwargs; validation of required fields |
core/exceptions.py |
Error classification mapping (RuntimeError -> PEP 249 exceptions) |
core/cursor.py |
Cursor lifecycle, fetchone/fetchall behavior, closed cursor detection |
core/connection.py |
Connection state management, cursor creation |
base_job.py |
_parse_connection_input() for all input types |
ssl.py |
Certificate retrieval and SSL context creation |
3. Fix commented-out tests
Investigate and fix the 7 commented-out tests:
test_pop_job_with_pool_ignore — JobStatus tracking
test_pool_with_no_space_no_ready_job... — JobStatus tracking
test_pool_with_space_but_no_ready_job... — JobStatus tracking
test_freeist_job_is_returned — JobStatus tracking
test_pep249_execute_many — Duplicate of working test
test_prepare_statement_mult_params_seq_tuple — Tuple parameter support
test_prepare_statement_mult_params_seq_tuple_opts — Tuple parameter support
4. Add coverage reporting
- Configure
.coveragerc or pyproject.toml coverage settings
- Add
--cov=mapepire_python --cov-report=term-missing to default pytest invocation
- Set a coverage floor (e.g., 70%) as a CI gate
Files to Create/Modify
- New:
tests/conftest.py — Shared fixtures and mock WebSocket
- New:
tests/unit/test_query_state.py — Query state machine tests
- New:
tests/unit/test_pool_scaling.py — Pool logic tests
- New:
tests/unit/test_config_parsing.py — DaemonServer/config tests
- New:
tests/unit/test_error_classification.py — Exception mapping tests
- New:
tests/unit/test_cursor.py — Cursor lifecycle tests
- Modify:
tests/pooling_test.py — Fix commented-out tests
- Modify:
tests/pep249_test.py — Fix commented-out tests
- Modify:
pyproject.toml — Add coverage configuration
Acceptance Criteria
Summary
All 107 existing tests are integration tests that require a live IBM i server connection. There are zero unit tests and zero mocks. This means:
Current State
VITE_SERVER,VITE_DB_USER,VITE_DB_PASS)conftest.py— no shared fixturestests/unit/,tests/integration/, etc.) — a planned reorg that was never completedpooling_test.pyandpep249_test.pydue to job status tracking issuesProposed Changes
1. Create shared test fixtures (
tests/conftest.py)DaemonServercredentials fixtureQueryResult,ConnectionResult, and other server response types2. Create unit tests for core components
Priority modules to test in isolation:
Query/PoolQueryPoolDaemonServercore/exceptions.pycore/cursor.pycore/connection.pybase_job.py_parse_connection_input()for all input typesssl.py3. Fix commented-out tests
Investigate and fix the 7 commented-out tests:
test_pop_job_with_pool_ignore— JobStatus trackingtest_pool_with_no_space_no_ready_job...— JobStatus trackingtest_pool_with_space_but_no_ready_job...— JobStatus trackingtest_freeist_job_is_returned— JobStatus trackingtest_pep249_execute_many— Duplicate of working testtest_prepare_statement_mult_params_seq_tuple— Tuple parameter supporttest_prepare_statement_mult_params_seq_tuple_opts— Tuple parameter support4. Add coverage reporting
.coveragercorpyproject.tomlcoverage settings--cov=mapepire_python --cov-report=term-missingto default pytest invocationFiles to Create/Modify
tests/conftest.py— Shared fixtures and mock WebSockettests/unit/test_query_state.py— Query state machine teststests/unit/test_pool_scaling.py— Pool logic teststests/unit/test_config_parsing.py— DaemonServer/config teststests/unit/test_error_classification.py— Exception mapping teststests/unit/test_cursor.py— Cursor lifecycle teststests/pooling_test.py— Fix commented-out teststests/pep249_test.py— Fix commented-out testspyproject.toml— Add coverage configurationAcceptance Criteria
conftest.pyprovides reusable mock WebSocket fixturespytest tests/unit/)pytest --cov