11"""Tests for Bitget account container."""
22
3- import pytest
43
54from bt_api_py .containers .accounts .bitget_account import (
65 BitgetAccountData ,
@@ -34,7 +33,9 @@ def test_init_data(self):
3433 "marginAvailable" : 8000.0 ,
3534 "marginForced" : 0.0 ,
3635 }
37- account = BitgetAccountData (data , symbol_name = "BTCUSDT" , asset_type = "SPOT" , has_been_json_encoded = True )
36+ account = BitgetAccountData (
37+ data , symbol_name = "BTCUSDT" , asset_type = "SPOT" , has_been_json_encoded = True
38+ )
3839 account .init_data ()
3940
4041 assert account .uid == "12345"
@@ -50,7 +51,9 @@ def test_init_data(self):
5051 def test_init_data_idempotent (self ):
5152 """Test init_data is idempotent."""
5253 data = {"uid" : "12345" }
53- account = BitgetAccountData (data , symbol_name = "BTCUSDT" , asset_type = "SPOT" , has_been_json_encoded = True )
54+ account = BitgetAccountData (
55+ data , symbol_name = "BTCUSDT" , asset_type = "SPOT" , has_been_json_encoded = True
56+ )
5457 account .init_data ()
5558 first_uid = account .uid
5659
@@ -59,63 +62,81 @@ def test_init_data_idempotent(self):
5962
6063 def test_get_exchange_name (self ):
6164 """Test get_exchange_name."""
62- account = BitgetAccountData ({}, symbol_name = "BTCUSDT" , asset_type = "SPOT" , has_been_json_encoded = True )
65+ account = BitgetAccountData (
66+ {}, symbol_name = "BTCUSDT" , asset_type = "SPOT" , has_been_json_encoded = True
67+ )
6368 assert account .get_exchange_name () == "BITGET"
6469
6570 def test_get_symbol_name (self ):
6671 """Test get_symbol_name."""
67- account = BitgetAccountData ({}, symbol_name = "BTCUSDT" , asset_type = "SPOT" , has_been_json_encoded = True )
72+ account = BitgetAccountData (
73+ {}, symbol_name = "BTCUSDT" , asset_type = "SPOT" , has_been_json_encoded = True
74+ )
6875 assert account .get_symbol_name () == "BTCUSDT"
6976
7077 def test_get_asset_type (self ):
7178 """Test get_asset_type."""
72- account = BitgetAccountData ({}, symbol_name = "BTCUSDT" , asset_type = "SPOT" , has_been_json_encoded = True )
79+ account = BitgetAccountData (
80+ {}, symbol_name = "BTCUSDT" , asset_type = "SPOT" , has_been_json_encoded = True
81+ )
7382 assert account .get_asset_type () == "SPOT"
7483
7584 def test_get_uid (self ):
7685 """Test get_uid."""
7786 data = {"uid" : "12345" }
78- account = BitgetAccountData (data , symbol_name = "BTCUSDT" , asset_type = "SPOT" , has_been_json_encoded = True )
87+ account = BitgetAccountData (
88+ data , symbol_name = "BTCUSDT" , asset_type = "SPOT" , has_been_json_encoded = True
89+ )
7990 account .init_data ()
8091
8192 assert account .get_uid () == "12345"
8293
8394 def test_get_account_type (self ):
8495 """Test get_account_type."""
8596 data = {"accountType" : "spot" }
86- account = BitgetAccountData (data , symbol_name = "BTCUSDT" , asset_type = "SPOT" , has_been_json_encoded = True )
97+ account = BitgetAccountData (
98+ data , symbol_name = "BTCUSDT" , asset_type = "SPOT" , has_been_json_encoded = True
99+ )
87100 account .init_data ()
88101
89102 assert account .get_account_type () == "spot"
90103
91104 def test_get_equity (self ):
92105 """Test get_equity."""
93106 data = {"equity" : 10000.0 }
94- account = BitgetAccountData (data , symbol_name = "BTCUSDT" , asset_type = "SPOT" , has_been_json_encoded = True )
107+ account = BitgetAccountData (
108+ data , symbol_name = "BTCUSDT" , asset_type = "SPOT" , has_been_json_encoded = True
109+ )
95110 account .init_data ()
96111
97112 assert account .get_equity () == 10000.0
98113
99114 def test_get_unrealized_pnl (self ):
100115 """Test get_unrealized_pnl."""
101116 data = {"unrealizedPnl" : 500.0 }
102- account = BitgetAccountData (data , symbol_name = "BTCUSDT" , asset_type = "SPOT" , has_been_json_encoded = True )
117+ account = BitgetAccountData (
118+ data , symbol_name = "BTCUSDT" , asset_type = "SPOT" , has_been_json_encoded = True
119+ )
103120 account .init_data ()
104121
105122 assert account .get_unrealized_pnl () == 500.0
106123
107124 def test_get_realized_pnl (self ):
108125 """Test get_realized_pnl."""
109126 data = {"realizedPnl" : 1000.0 }
110- account = BitgetAccountData (data , symbol_name = "BTCUSDT" , asset_type = "SPOT" , has_been_json_encoded = True )
127+ account = BitgetAccountData (
128+ data , symbol_name = "BTCUSDT" , asset_type = "SPOT" , has_been_json_encoded = True
129+ )
111130 account .init_data ()
112131
113132 assert account .get_realized_pnl () == 1000.0
114133
115134 def test_get_margin_available (self ):
116135 """Test get_margin_available."""
117136 data = {"marginAvailable" : 8000.0 }
118- account = BitgetAccountData (data , symbol_name = "BTCUSDT" , asset_type = "SPOT" , has_been_json_encoded = True )
137+ account = BitgetAccountData (
138+ data , symbol_name = "BTCUSDT" , asset_type = "SPOT" , has_been_json_encoded = True
139+ )
119140 account .init_data ()
120141
121142 assert account .get_margin_available () == 8000.0
@@ -126,7 +147,9 @@ def test_get_all_data(self):
126147 "uid" : "12345" ,
127148 "equity" : 10000.0 ,
128149 }
129- account = BitgetAccountData (data , symbol_name = "BTCUSDT" , asset_type = "SPOT" , has_been_json_encoded = True )
150+ account = BitgetAccountData (
151+ data , symbol_name = "BTCUSDT" , asset_type = "SPOT" , has_been_json_encoded = True
152+ )
130153 result = account .get_all_data ()
131154
132155 assert result ["exchange_name" ] == "BITGET"
@@ -136,7 +159,9 @@ def test_get_all_data(self):
136159 def test_str_representation (self ):
137160 """Test __str__ method."""
138161 data = {"uid" : "12345" }
139- account = BitgetAccountData (data , symbol_name = "BTCUSDT" , asset_type = "SPOT" , has_been_json_encoded = True )
162+ account = BitgetAccountData (
163+ data , symbol_name = "BTCUSDT" , asset_type = "SPOT" , has_been_json_encoded = True
164+ )
140165 result = str (account )
141166
142167 assert "BITGET" in result
@@ -172,7 +197,9 @@ def test_init_data(self):
172197 ]
173198 }
174199 }
175- account = BitgetSpotWssAccountData (data , symbol_name = "BTCUSDT" , asset_type = "SPOT" , has_been_json_encoded = True )
200+ account = BitgetSpotWssAccountData (
201+ data , symbol_name = "BTCUSDT" , asset_type = "SPOT" , has_been_json_encoded = True
202+ )
176203 # Work around bug by setting the attribute manually
177204 account .has_been_json_encoded = True
178205 account .init_data ()
@@ -188,7 +215,9 @@ def test_get_balances(self):
188215 ]
189216 }
190217 }
191- account = BitgetSpotWssAccountData (data , symbol_name = "BTCUSDT" , asset_type = "SPOT" , has_been_json_encoded = True )
218+ account = BitgetSpotWssAccountData (
219+ data , symbol_name = "BTCUSDT" , asset_type = "SPOT" , has_been_json_encoded = True
220+ )
192221 account .has_been_json_encoded = True
193222 balances = account .get_balances ()
194223
@@ -204,7 +233,9 @@ def test_get_balance(self):
204233 ]
205234 }
206235 }
207- account = BitgetSpotWssAccountData (data , symbol_name = "BTCUSDT" , asset_type = "SPOT" , has_been_json_encoded = True )
236+ account = BitgetSpotWssAccountData (
237+ data , symbol_name = "BTCUSDT" , asset_type = "SPOT" , has_been_json_encoded = True
238+ )
208239 account .has_been_json_encoded = True
209240 balance = account .get_balance ("USDT" )
210241
@@ -219,7 +250,9 @@ def test_get_balance_not_found(self):
219250 ]
220251 }
221252 }
222- account = BitgetSpotWssAccountData (data , symbol_name = "BTCUSDT" , asset_type = "SPOT" , has_been_json_encoded = True )
253+ account = BitgetSpotWssAccountData (
254+ data , symbol_name = "BTCUSDT" , asset_type = "SPOT" , has_been_json_encoded = True
255+ )
223256 account .has_been_json_encoded = True
224257 balance = account .get_balance ("ETH" )
225258
@@ -238,7 +271,9 @@ def test_get_total_equity(self):
238271 ]
239272 }
240273 }
241- account = BitgetSpotWssAccountData (data , symbol_name = "BTCUSDT" , asset_type = "SPOT" , has_been_json_encoded = True )
274+ account = BitgetSpotWssAccountData (
275+ data , symbol_name = "BTCUSDT" , asset_type = "SPOT" , has_been_json_encoded = True
276+ )
242277 account .has_been_json_encoded = True
243278 account .init_data ()
244279 total = account .get_total_equity ()
0 commit comments