- def test_create_order(self):
- with mock.patch.object(self.s, "create_exchange_order") as exchange,\
- mock.patch.object(self.s, "create_margin_order") as margin:
- with self.subTest(account="unspecified"):
- self.s.create_order("symbol", "type", "side", "amount", price="price", lending_rate="lending_rate", params="params")
- exchange.assert_called_once_with("symbol", "type", "side", "amount", price="price", params="params")
- margin.assert_not_called()
- exchange.reset_mock()
- margin.reset_mock()
-
- with self.subTest(account="exchange"):
- self.s.create_order("symbol", "type", "side", "amount", account="exchange", price="price", lending_rate="lending_rate", params="params")
- exchange.assert_called_once_with("symbol", "type", "side", "amount", price="price", params="params")
- margin.assert_not_called()
- exchange.reset_mock()
- margin.reset_mock()
-
- with self.subTest(account="margin"):
- self.s.create_order("symbol", "type", "side", "amount", account="margin", price="price", lending_rate="lending_rate", params="params")
- margin.assert_called_once_with("symbol", "type", "side", "amount", lending_rate="lending_rate", price="price", params="params")
- exchange.assert_not_called()
- exchange.reset_mock()
- margin.reset_mock()
-
- with self.subTest(account="unknown"), self.assertRaises(NotImplementedError):
- self.s.create_order("symbol", "type", "side", "amount", account="unknown")
-