Skip to content

Commit a4c926e

Browse files
committed
Add tests for exception message TradeStatus
1 parent 6aa7ece commit a4c926e

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
from unittest import TestCase
2+
from investing_algorithm_framework.domain import Trade, OperationalException
3+
4+
5+
class TestTradeStatus(TestCase):
6+
7+
def test_trade_status(self):
8+
9+
trade = Trade(
10+
id=1,
11+
open_price=100,
12+
opened_at=None,
13+
closed_at=None,
14+
orders=[],
15+
target_symbol="BTC",
16+
trading_symbol="EUR",
17+
amount=1,
18+
cost=100,
19+
available_amount=1,
20+
remaining=0,
21+
filled_amount=1,
22+
status="open"
23+
)
24+
self.assertEqual(trade.status, "OPEN")
25+
26+
def test_invalid_trade_status(self):
27+
28+
with self.assertRaises(OperationalException) as e:
29+
trade = Trade(
30+
id=1,
31+
open_price=100,
32+
opened_at=None,
33+
closed_at=None,
34+
orders=[],
35+
target_symbol="BTC",
36+
trading_symbol="EUR",
37+
amount=1,
38+
cost=100,
39+
available_amount=1,
40+
remaining=0,
41+
filled_amount=1,
42+
status="opened"
43+
)
44+
self.assertEqual(
45+
str(e.exception),
46+
"Could not convert value: 'opened' to TradeStatus"
47+
)

0 commit comments

Comments
 (0)