File tree Expand file tree Collapse file tree 1 file changed +47
-0
lines changed
tests/domain/models/trades Expand file tree Collapse file tree 1 file changed +47
-0
lines changed Original file line number Diff line number Diff line change 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+ )
You can’t perform that action at this time.
0 commit comments