Skip to content

Commit d6c165f

Browse files
committed
test: added comments to test_ibkr_client_u.py
1 parent d1ca88f commit d6c165f

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

test/unit/client/test_ibkr_client_u.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,33 +15,47 @@ def client():
1515
c.oauth_config.shutdown_oauth = False
1616
return c
1717

18-
# --- caplog-based tests ---
1918
def test_handle_health_status_healthy(client, caplog):
19+
## Arrange
2020
client.check_health.return_value = True
21+
22+
## Act
2123
with caplog.at_level("WARNING", logger="ibind.client.ibkr_client"):
2224
assert client.handle_health_status() is True
25+
26+
## Assert
2327
# No warning should be logged
2428
assert not any("IBKR connection is not healthy" in r.message for r in caplog.records)
2529
client.check_health.assert_called_once()
2630
client.stop_tickler.assert_not_called()
2731
client.oauth_init.assert_not_called()
2832

2933
def test_handle_health_status_not_healthy_no_oauth(client, caplog):
34+
## Arrange
3035
client.check_health.return_value = False
3136
client._use_oauth = False
37+
38+
## Act
3239
with caplog.at_level("WARNING", logger="ibind.client.ibkr_client"):
3340
assert client.handle_health_status() is False
41+
42+
## Assert
3443
assert any("IBKR connection is not healthy. Ensure authentication with the Gateway is re-established." in r.message for r in caplog.records)
3544
client.stop_tickler.assert_not_called()
3645
client.oauth_init.assert_not_called()
3746

3847
def test_handle_health_status_not_healthy_oauth_success(client, caplog):
48+
## Arrange
3949
client.check_health.return_value = False
4050
client._use_oauth = True
4151
client.stop_tickler.side_effect = None
4252
client.oauth_init.side_effect = None
53+
54+
## Act
4355
with caplog.at_level("WARNING", logger="ibind.client.ibkr_client"):
4456
assert client.handle_health_status() is False
57+
58+
## Assert
4559
assert any("IBKR connection is not healthy. Attempting to re-establish OAuth authentication." in r.message for r in caplog.records)
4660
client.stop_tickler.assert_called_once_with(15)
4761
client.oauth_init.assert_called_once_with(maintain_oauth=True, init_brokerage_session=True)

0 commit comments

Comments
 (0)