77import pytest
88
99from project_x_py import (
10- AsyncProjectX ,
10+ ProjectX ,
1111 ProjectXConfig ,
1212 ProjectXConnectionError ,
13+ RateLimiter ,
1314)
14- from project_x_py .async_client import AsyncRateLimiter
1515
1616
1717@pytest .fixture
@@ -24,7 +24,7 @@ def mock_env_vars(monkeypatch):
2424@pytest .mark .asyncio
2525async def test_async_client_creation ():
2626 """Test async client can be created."""
27- client = AsyncProjectX (
27+ client = ProjectX (
2828 username = "test_user" ,
2929 api_key = "test_key" ,
3030 )
@@ -37,7 +37,7 @@ async def test_async_client_creation():
3737@pytest .mark .asyncio
3838async def test_async_client_from_env (mock_env_vars ):
3939 """Test creating async client from environment variables."""
40- async with AsyncProjectX .from_env () as client :
40+ async with ProjectX .from_env () as client :
4141 assert client .username == "test_username"
4242 assert client .api_key == "test_api_key"
4343 assert client ._client is not None # Client should be initialized
@@ -46,7 +46,7 @@ async def test_async_client_from_env(mock_env_vars):
4646@pytest .mark .asyncio
4747async def test_async_context_manager ():
4848 """Test async client works as context manager."""
49- client = AsyncProjectX (username = "test" , api_key = "key" )
49+ client = ProjectX (username = "test" , api_key = "key" )
5050
5151 # Client should not be initialized yet
5252 assert client ._client is None
@@ -63,7 +63,7 @@ async def test_async_context_manager():
6363@pytest .mark .asyncio
6464async def test_http2_support ():
6565 """Test that HTTP/2 is enabled."""
66- client = AsyncProjectX (username = "test" , api_key = "key" )
66+ client = ProjectX (username = "test" , api_key = "key" )
6767
6868 async with client :
6969 # Check HTTP/2 is enabled
@@ -73,7 +73,7 @@ async def test_http2_support():
7373@pytest .mark .asyncio
7474async def test_authentication_flow ():
7575 """Test authentication flow with mocked responses."""
76- client = AsyncProjectX (username = "test" , api_key = "key" )
76+ client = ProjectX (username = "test" , api_key = "key" )
7777
7878 # Mock responses
7979 mock_login_response = {
@@ -113,7 +113,7 @@ async def test_authentication_flow():
113113@pytest .mark .asyncio
114114async def test_concurrent_requests ():
115115 """Test that async client can handle concurrent requests."""
116- client = AsyncProjectX (username = "test" , api_key = "key" )
116+ client = ProjectX (username = "test" , api_key = "key" )
117117
118118 # Mock responses
119119 positions_response = [
@@ -175,7 +175,7 @@ async def mock_make_request(method, endpoint, **kwargs):
175175@pytest .mark .asyncio
176176async def test_cache_functionality ():
177177 """Test that caching works for instruments."""
178- client = AsyncProjectX (username = "test" , api_key = "key" )
178+ client = ProjectX (username = "test" , api_key = "key" )
179179
180180 instrument_response = [
181181 {
@@ -222,7 +222,7 @@ async def mock_make_request(method, endpoint, **kwargs):
222222@pytest .mark .asyncio
223223async def test_error_handling ():
224224 """Test error handling and retries."""
225- client = AsyncProjectX (username = "test" , api_key = "key" )
225+ client = ProjectX (username = "test" , api_key = "key" )
226226
227227 async with client :
228228 # Test connection error with retries
@@ -240,7 +240,7 @@ async def test_error_handling():
240240@pytest .mark .asyncio
241241async def test_health_status ():
242242 """Test health status reporting."""
243- client = AsyncProjectX (username = "test" , api_key = "key" )
243+ client = ProjectX (username = "test" , api_key = "key" )
244244 client .account_info = MagicMock ()
245245 client .account_info .name = "Test Account"
246246
@@ -269,7 +269,7 @@ async def test_health_status():
269269@pytest .mark .asyncio
270270async def test_list_accounts ():
271271 """Test listing accounts."""
272- client = AsyncProjectX (username = "test" , api_key = "key" )
272+ client = ProjectX (username = "test" , api_key = "key" )
273273
274274 mock_accounts = [
275275 {
@@ -307,7 +307,7 @@ async def test_list_accounts():
307307@pytest .mark .asyncio
308308async def test_search_instruments ():
309309 """Test searching for instruments."""
310- client = AsyncProjectX (username = "test" , api_key = "key" )
310+ client = ProjectX (username = "test" , api_key = "key" )
311311
312312 mock_instruments = [
313313 {
@@ -349,7 +349,7 @@ async def test_search_instruments():
349349@pytest .mark .asyncio
350350async def test_get_bars ():
351351 """Test getting market data bars."""
352- client = AsyncProjectX (username = "test" , api_key = "key" )
352+ client = ProjectX (username = "test" , api_key = "key" )
353353 client .account_info = MagicMock ()
354354 client .account_info .id = 123
355355
@@ -399,7 +399,7 @@ async def test_get_bars():
399399@pytest .mark .asyncio
400400async def test_search_trades ():
401401 """Test searching trade history."""
402- client = AsyncProjectX (username = "test" , api_key = "key" )
402+ client = ProjectX (username = "test" , api_key = "key" )
403403 client .account_info = MagicMock ()
404404 client .account_info .id = 123
405405
@@ -452,9 +452,10 @@ async def test_rate_limiting():
452452 """Test rate limiting functionality."""
453453 import time
454454
455- client = AsyncProjectX (username = "test" , api_key = "key" )
455+ client = ProjectX (username = "test" , api_key = "key" )
456456 # Set aggressive rate limit for testing
457- client .rate_limiter = AsyncRateLimiter (max_requests = 2 , window_seconds = 1 )
457+ rate_limiter = RateLimiter (requests_per_minute = 2 )
458+ client .rate_limiter = rate_limiter
458459
459460 async with client :
460461 with patch .object (
0 commit comments