Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions tests/integration/test_basic_workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class TestBasicWorkflow:
@pytest.fixture
def mock_tv(self):
"""Create a mocked TvDatafeed instance"""
with patch('tvDatafeed.main.ws.create_connection') as mock_ws:
with patch('tvDatafeed.main.create_connection') as mock_ws:
# Mock WebSocket connection
mock_connection = MagicMock()
mock_ws.return_value = mock_connection
Expand Down Expand Up @@ -94,7 +94,7 @@ class TestDataValidation:
@pytest.fixture
def mock_tv_with_data(self):
"""Create a mocked TvDatafeed that returns valid data"""
with patch('tvDatafeed.main.ws.create_connection') as mock_ws:
with patch('tvDatafeed.main.create_connection') as mock_ws:
mock_connection = MagicMock()
mock_ws.return_value = mock_connection

Expand Down Expand Up @@ -158,7 +158,7 @@ class TestErrorHandling:

def test_invalid_symbol_handling(self):
"""Test handling of invalid symbol"""
with patch('tvDatafeed.main.ws.create_connection') as mock_ws:
with patch('tvDatafeed.main.create_connection') as mock_ws:
mock_connection = MagicMock()
mock_ws.return_value = mock_connection
mock_connection.recv.return_value = '~m~52~m~{"m":"qsd","p":["qs_test123",{"n":"symbol_1","s":"error"}]}'
Expand All @@ -178,7 +178,7 @@ def test_invalid_symbol_handling(self):

def test_connection_timeout_handling(self):
"""Test handling of connection timeout"""
with patch('tvDatafeed.main.ws.create_connection') as mock_ws:
with patch('tvDatafeed.main.create_connection') as mock_ws:
# Simulate timeout
mock_ws.side_effect = TimeoutError("Connection timeout")

Expand All @@ -192,7 +192,7 @@ def test_connection_timeout_handling(self):

def test_websocket_disconnection_handling(self):
"""Test handling of WebSocket disconnection"""
with patch('tvDatafeed.main.ws.create_connection') as mock_ws:
with patch('tvDatafeed.main.create_connection') as mock_ws:
mock_connection = MagicMock()
mock_ws.return_value = mock_connection

Expand Down Expand Up @@ -224,7 +224,7 @@ class TestLargeDatasets:
@pytest.fixture
def mock_tv_large_data(self):
"""Create a mocked TvDatafeed with large dataset"""
with patch('tvDatafeed.main.ws.create_connection') as mock_ws:
with patch('tvDatafeed.main.create_connection') as mock_ws:
mock_connection = MagicMock()
mock_ws.return_value = mock_connection

Expand Down Expand Up @@ -284,7 +284,7 @@ class TestSymbolSearch:
@pytest.fixture
def mock_tv_search(self):
"""Create a mocked TvDatafeed for search testing"""
with patch('tvDatafeed.main.ws.create_connection') as mock_ws, \
with patch('tvDatafeed.main.create_connection') as mock_ws, \
patch('tvDatafeed.main.requests.get') as mock_get:

mock_connection = MagicMock()
Expand Down
26 changes: 13 additions & 13 deletions tests/integration/test_error_scenarios.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class TestAuthenticationErrors:

def test_invalid_credentials(self):
"""Test handling of invalid credentials"""
with patch('tvDatafeed.main.ws.create_connection') as mock_ws, \
with patch('tvDatafeed.main.create_connection') as mock_ws, \
patch('tvDatafeed.main.requests.post') as mock_post:

# Mock authentication failure
Expand All @@ -48,7 +48,7 @@ def test_empty_credentials(self):

def test_partial_credentials(self):
"""Test handling of partial credentials"""
with patch('tvDatafeed.main.ws.create_connection'):
with patch('tvDatafeed.main.create_connection'):
# Username without password should fail validation
with pytest.raises((ValueError, AuthenticationError)):
TvDatafeed(username='user', password=None)
Expand All @@ -60,7 +60,7 @@ class TestWebSocketErrors:

def test_connection_refused(self):
"""Test handling of connection refused"""
with patch('tvDatafeed.main.ws.create_connection') as mock_ws:
with patch('tvDatafeed.main.create_connection') as mock_ws:
mock_ws.side_effect = ConnectionRefusedError("Connection refused")

# Should handle connection error gracefully
Expand All @@ -69,7 +69,7 @@ def test_connection_refused(self):

def test_connection_timeout(self):
"""Test handling of connection timeout"""
with patch('tvDatafeed.main.ws.create_connection') as mock_ws:
with patch('tvDatafeed.main.create_connection') as mock_ws:
mock_ws.side_effect = TimeoutError("Connection timeout")

# Should handle timeout gracefully
Expand All @@ -78,7 +78,7 @@ def test_connection_timeout(self):

def test_websocket_closed_unexpectedly(self):
"""Test handling of unexpected WebSocket closure"""
with patch('tvDatafeed.main.ws.create_connection') as mock_ws:
with patch('tvDatafeed.main.create_connection') as mock_ws:
mock_connection = MagicMock()
mock_ws.return_value = mock_connection

Expand Down Expand Up @@ -108,7 +108,7 @@ class TestDataErrors:

def test_invalid_symbol(self):
"""Test handling of invalid symbol"""
with patch('tvDatafeed.main.ws.create_connection') as mock_ws:
with patch('tvDatafeed.main.create_connection') as mock_ws:
mock_connection = MagicMock()
mock_ws.return_value = mock_connection
mock_connection.recv.side_effect = [
Expand All @@ -129,7 +129,7 @@ def test_invalid_symbol(self):

def test_no_data_available(self):
"""Test handling when no data is available"""
with patch('tvDatafeed.main.ws.create_connection') as mock_ws:
with patch('tvDatafeed.main.create_connection') as mock_ws:
mock_connection = MagicMock()
mock_ws.return_value = mock_connection
mock_connection.recv.side_effect = [
Expand All @@ -151,7 +151,7 @@ def test_no_data_available(self):

def test_malformed_data(self):
"""Test handling of malformed data"""
with patch('tvDatafeed.main.ws.create_connection') as mock_ws:
with patch('tvDatafeed.main.create_connection') as mock_ws:
mock_connection = MagicMock()
mock_ws.return_value = mock_connection
mock_connection.recv.side_effect = [
Expand Down Expand Up @@ -183,7 +183,7 @@ class TestInputValidation:
@pytest.fixture
def mock_tv(self):
"""Create a mocked TvDatafeed for validation testing"""
with patch('tvDatafeed.main.ws.create_connection') as mock_ws:
with patch('tvDatafeed.main.create_connection') as mock_ws:
mock_connection = MagicMock()
mock_ws.return_value = mock_connection
mock_connection.recv.return_value = '~m~52~m~{"m":"qsd","p":["qs_test123",{"n":"symbol_1","s":"ok"}]}'
Expand Down Expand Up @@ -259,7 +259,7 @@ class TestLiveFeedErrors:

def test_callback_not_callable(self):
"""Test validation of callback parameter"""
with patch('tvDatafeed.main.ws.create_connection') as mock_ws:
with patch('tvDatafeed.main.create_connection') as mock_ws:
mock_connection = MagicMock()
mock_ws.return_value = mock_connection
mock_connection.recv.return_value = '~m~52~m~{"m":"qsd","p":["qs_test123",{"n":"symbol_1","s":"ok"}]}'
Expand All @@ -279,7 +279,7 @@ def test_callback_not_callable(self):

def test_stop_before_start(self):
"""Test stopping feed before starting"""
with patch('tvDatafeed.main.ws.create_connection') as mock_ws:
with patch('tvDatafeed.main.create_connection') as mock_ws:
mock_connection = MagicMock()
mock_ws.return_value = mock_connection
mock_connection.recv.return_value = '~m~52~m~{"m":"qsd","p":["qs_test123",{"n":"symbol_1","s":"ok"}]}'
Expand All @@ -297,7 +297,7 @@ class TestEdgeCases:
@pytest.fixture
def mock_tv_edge(self):
"""Create a mocked TvDatafeed for edge case testing"""
with patch('tvDatafeed.main.ws.create_connection') as mock_ws:
with patch('tvDatafeed.main.create_connection') as mock_ws:
mock_connection = MagicMock()
mock_ws.return_value = mock_connection
mock_connection.recv.return_value = '~m~52~m~{"m":"qsd","p":["qs_test123",{"n":"symbol_1","s":"ok"}]}'
Expand Down Expand Up @@ -373,7 +373,7 @@ class TestRateLimiting:
@pytest.fixture
def mock_tv_rate(self):
"""Create a mocked TvDatafeed for rate limiting testing"""
with patch('tvDatafeed.main.ws.create_connection') as mock_ws:
with patch('tvDatafeed.main.create_connection') as mock_ws:
mock_connection = MagicMock()
mock_ws.return_value = mock_connection
mock_connection.recv.return_value = '~m~52~m~{"m":"qsd","p":["qs_test123",{"n":"symbol_1","s":"ok"}]}'
Expand Down
12 changes: 6 additions & 6 deletions tests/integration/test_live_feed_workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class TestLiveFeedBasics:
@pytest.fixture
def mock_live_tv(self):
"""Create a mocked TvDatafeedLive instance"""
with patch('tvDatafeed.main.ws.create_connection') as mock_ws:
with patch('tvDatafeed.main.create_connection') as mock_ws:
mock_connection = MagicMock()
mock_ws.return_value = mock_connection
mock_connection.recv.side_effect = [
Expand Down Expand Up @@ -99,7 +99,7 @@ class TestMultipleSymbols:
@pytest.fixture
def mock_live_tv_multi(self):
"""Create a mocked TvDatafeedLive for multiple symbols"""
with patch('tvDatafeed.main.ws.create_connection') as mock_ws:
with patch('tvDatafeed.main.create_connection') as mock_ws:
mock_connection = MagicMock()
mock_ws.return_value = mock_connection

Expand Down Expand Up @@ -193,7 +193,7 @@ class TestCallbackExecution:
@pytest.fixture
def mock_live_tv_callback(self):
"""Create a mocked TvDatafeedLive for callback testing"""
with patch('tvDatafeed.main.ws.create_connection') as mock_ws:
with patch('tvDatafeed.main.create_connection') as mock_ws:
mock_connection = MagicMock()
mock_ws.return_value = mock_connection
mock_connection.recv.side_effect = [
Expand Down Expand Up @@ -267,7 +267,7 @@ class TestThreadSafety:
@pytest.fixture
def mock_live_tv_threads(self):
"""Create a mocked TvDatafeedLive for thread safety testing"""
with patch('tvDatafeed.main.ws.create_connection') as mock_ws:
with patch('tvDatafeed.main.create_connection') as mock_ws:
mock_connection = MagicMock()
mock_ws.return_value = mock_connection
mock_connection.recv.side_effect = [
Expand Down Expand Up @@ -352,7 +352,7 @@ class TestLiveFeedResilience:

def test_websocket_reconnection(self):
"""Test handling of WebSocket disconnection and reconnection"""
with patch('tvDatafeed.main.ws.create_connection') as mock_ws:
with patch('tvDatafeed.main.create_connection') as mock_ws:
mock_connection = MagicMock()
call_count = [0]

Expand Down Expand Up @@ -387,7 +387,7 @@ def dummy_callback(symbol, exchange, interval, dataframe):

def test_data_parsing_errors(self):
"""Test handling of malformed data"""
with patch('tvDatafeed.main.ws.create_connection') as mock_ws:
with patch('tvDatafeed.main.create_connection') as mock_ws:
mock_connection = MagicMock()
mock_ws.return_value = mock_connection

Expand Down
Loading