diff --git a/tests/integration/test_errors.py b/tests/integration/test_errors.py index a3317e49..fec109e7 100644 --- a/tests/integration/test_errors.py +++ b/tests/integration/test_errors.py @@ -40,10 +40,14 @@ def test_invalid_ticker_returns_not_found( def test_malformed_params_returns_validation_error( self, sync_client: KalshiClient ) -> None: - """Malformed request params should raise KalshiValidationError (400).""" - # Use an obviously invalid limit value + """Malformed request params should raise KalshiValidationError (400). + + Uses a malformed cursor — the SDK passes it verbatim to the server, + which rejects it with a 400. (Numeric range checks like negative + limit are now enforced client-side via ValueError per #214.) + """ with pytest.raises(KalshiValidationError) as exc_info: - sync_client.markets.list(limit=-1) + sync_client.markets.list(cursor="!!!not-a-valid-cursor!!!") exc = exc_info.value assert exc.status_code == 400 @@ -98,7 +102,7 @@ def test_validation_error_details_attribute( ) -> None: """KalshiValidationError should have a details attribute (may be None or dict).""" with pytest.raises(KalshiValidationError) as exc_info: - sync_client.markets.list(limit=-1) + sync_client.markets.list(cursor="!!!not-a-valid-cursor!!!") exc = exc_info.value assert hasattr(exc, "details") diff --git a/tests/integration/test_orders.py b/tests/integration/test_orders.py index f9e176f2..d27dafcf 100644 --- a/tests/integration/test_orders.py +++ b/tests/integration/test_orders.py @@ -193,14 +193,15 @@ def test_batch_create_cancel( for i in range(2) ] - orders = sync_client.orders.batch_create(requests) - assert isinstance(orders, list) - assert len(orders) > 0 - for o in orders: + response = sync_client.orders.batch_create(requests) + assert len(response.orders) > 0 + successful = [e.order for e in response.orders if e.order is not None] + assert successful, f"All legs failed: {response.orders}" + for o in successful: assert isinstance(o, Order) assert_model_fields(o) - order_ids = [o.order_id for o in orders] + order_ids = [o.order_id for o in successful] try: sync_client.orders.batch_cancel(order_ids) except Exception: @@ -306,14 +307,15 @@ async def test_batch_create_cancel( for i in range(2) ] - orders = await async_client.orders.batch_create(requests) - assert isinstance(orders, list) - assert len(orders) > 0 - for o in orders: + response = await async_client.orders.batch_create(requests) + assert len(response.orders) > 0 + successful = [e.order for e in response.orders if e.order is not None] + assert successful, f"All legs failed: {response.orders}" + for o in successful: assert isinstance(o, Order) assert_model_fields(o) - order_ids = [o.order_id for o in orders] + order_ids = [o.order_id for o in successful] try: await async_client.orders.batch_cancel(order_ids) except Exception: