Esempio n. 1
0
 def setUp(self) -> None:
     self.mock_package_type = mock.Mock()
     self.mock_client = mock.Mock()
     self.mock_order = mock.Mock()
     self.mock_order.status = OrderStatus.PENDING
     self.order_package = BetfairOrderPackage(
         self.mock_client,
         "1.234",
         [self.mock_order],
         self.mock_package_type,
         0,
     )
Esempio n. 2
0
class BetfairOrderPackageTest(unittest.TestCase):
    def setUp(self) -> None:
        self.mock_market = mock.Mock()
        self.mock_package_type = mock.Mock()
        self.mock_client = mock.Mock()
        self.mock_order = mock.Mock()
        self.mock_order.status = OrderStatus.PENDING
        self.order_package = BetfairOrderPackage(
            self.mock_client,
            "1.234",
            [self.mock_order],
            self.mock_package_type,
            self.mock_market,
        )

    def test_init(self):
        self.assertEqual(self.order_package.EXCHANGE, ExchangeType.BETFAIR)

    def test_place_instructions(self):
        self.assertEqual(
            self.order_package.place_instructions,
            [self.mock_order.create_place_instruction()],
        )

    def test_cancel_instructions(self):
        self.assertEqual(
            self.order_package.cancel_instructions,
            [self.mock_order.create_cancel_instruction()],
        )

    def test_update_instructions(self):
        self.assertEqual(
            self.order_package.update_instructions,
            [self.mock_order.create_update_instruction()],
        )

    def test_replace_instructions(self):
        self.assertEqual(
            self.order_package.replace_instructions,
            [self.mock_order.create_replace_instruction()],
        )

    def test_order_limit(self):
        self.assertEqual(
            self.order_package.order_limit(OrderPackageType.PLACE), 200)
        self.assertEqual(
            self.order_package.order_limit(OrderPackageType.CANCEL), 60)
        self.assertEqual(
            self.order_package.order_limit(OrderPackageType.UPDATE), 60)
        self.assertEqual(
            self.order_package.order_limit(OrderPackageType.REPLACE), 60)