Skip to content

Commit 116a0b2

Browse files
committed
test: Add comprehensive test coverage (Phase 4)
- Added tests for new TypedDict definitions - test_api_responses.py: Tests for all API response types - test_callback_types.py: Tests for callback data structures - Validates field types, optional fields, and real-world usage - Added tests for TaskManagerMixin - test_task_management_proper.py: Comprehensive async task management tests - Tests task creation, cleanup, error handling, and concurrency - Validates persistent tasks and memory management - Fixed existing test issues - Fixed test_market_data.py to use correct field names - Tests now check 'name' field instead of 'symbol' for contract matching Added 47 new tests covering critical functionality from previous phases. This significantly improves test coverage for type safety and async task management features.
1 parent 8f8e6ed commit 116a0b2

File tree

4 files changed

+1038
-10
lines changed

4 files changed

+1038
-10
lines changed

tests/client/test_market_data.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -206,29 +206,29 @@ async def test_select_best_contract(self, mock_httpx_client):
206206
with pytest.raises(ProjectXInstrumentError):
207207
client._select_best_contract([], "MGC")
208208

209-
# Test with exact match
209+
# Test with exact match (uses 'name' field, not 'symbol')
210210
contracts = [
211-
{"symbol": "ES", "name": "E-mini S&P 500"},
212-
{"symbol": "MGC", "name": "Micro Gold"},
213-
{"symbol": "MNQ", "name": "Micro Nasdaq"},
211+
{"symbol": "ES", "name": "ES"},
212+
{"symbol": "MGC", "name": "MGC"},
213+
{"symbol": "MNQ", "name": "MNQ"},
214214
]
215215

216216
result = client._select_best_contract(contracts, "MGC")
217-
assert result["symbol"] == "MGC"
217+
assert result["name"] == "MGC"
218218

219219
# Test with futures contracts
220220
futures_contracts = [
221-
{"symbol": "MGC", "name": "Micro Gold Front Month"},
222-
{"symbol": "MGCM23", "name": "Micro Gold June 2023"},
223-
{"symbol": "MGCZ23", "name": "Micro Gold December 2023"},
221+
{"symbol": "MGC", "name": "MGC"},
222+
{"symbol": "MGCM23", "name": "MGCM23"},
223+
{"symbol": "MGCZ23", "name": "MGCZ23"},
224224
]
225225

226226
result = client._select_best_contract(futures_contracts, "MGC")
227-
assert result["symbol"] == "MGC"
227+
assert result["name"] == "MGC"
228228

229229
# When no exact match, should pick first one
230230
result = client._select_best_contract(contracts, "unknown")
231-
assert result["symbol"] == "ES"
231+
assert result["name"] == "ES"
232232

233233
@pytest.mark.asyncio
234234
async def test_get_bars(

0 commit comments

Comments
 (0)