def test_place_orders(self):
        mock_response = create_mock_json('tests/resources/place_orders.json')
        place_orders = mock_response.json().get('result')
        resource = resources.PlaceOrders(date_time_sent=self.DATE_TIME_SENT,
                                        **place_orders)
        assert resource._datetime_sent == self.DATE_TIME_SENT
        assert resource.market_id == place_orders['marketId']
        assert resource.status == place_orders['status']
        assert resource.customer_ref == place_orders.get('customerRef')
        assert resource.error_code == place_orders.get('errorCode')
        assert len(resource.place_instruction_reports) == len(place_orders.get('instructionReports'))

        for order in place_orders.get('instructionReports'):
            assert resource.place_instruction_reports[0].size_matched == order['sizeMatched']
            assert resource.place_instruction_reports[0].status == order['status']
            assert resource.place_instruction_reports[0].bet_id == order['betId']
            assert resource.place_instruction_reports[0].average_price_matched == order['averagePriceMatched']
            assert resource.place_instruction_reports[0].placed_date == datetime.datetime.strptime(
                        order['placedDate'], "%Y-%m-%dT%H:%M:%S.%fZ")
            assert resource.place_instruction_reports[0].error_code == order.get('errorCode')

            assert resource.place_instruction_reports[0].instruction.selection_id == order['instruction']['selectionId']
            assert resource.place_instruction_reports[0].instruction.side == order['instruction']['side']
            assert resource.place_instruction_reports[0].instruction.order_type == order['instruction']['orderType']
            assert resource.place_instruction_reports[0].instruction.handicap == order['instruction']['handicap']

            assert resource.place_instruction_reports[0].instruction.order.persistence_type == order['instruction']['limitOrder']['persistenceType']
            assert resource.place_instruction_reports[0].instruction.order.price == order['instruction']['limitOrder']['price']
            assert resource.place_instruction_reports[0].instruction.order.size == order['instruction']['limitOrder']['size']
Пример #2
0
    def test_place_orders(self):
        mock_response = create_mock_json("tests/resources/place_orders.json")
        place_orders = mock_response.json().get("result")
        resource = resources.PlaceOrders(elapsed_time=self.ELAPSED_TIME,
                                         **place_orders)
        assert resource.elapsed_time == self.ELAPSED_TIME
        assert resource.market_id == place_orders["marketId"]
        assert resource.status == place_orders["status"]
        assert resource.customer_ref == place_orders.get("customerRef")
        assert resource.error_code == place_orders.get("errorCode")
        assert len(resource.place_instruction_reports) == len(
            place_orders.get("instructionReports"))

        for order in place_orders.get("instructionReports"):
            assert (resource.place_instruction_reports[0].size_matched ==
                    order["sizeMatched"])
            assert resource.place_instruction_reports[0].status == order[
                "status"]
            assert resource.place_instruction_reports[0].bet_id == order[
                "betId"]
            assert (resource.place_instruction_reports[0].average_price_matched
                    == order["averagePriceMatched"])
            assert resource.place_instruction_reports[
                0].placed_date == datetime.datetime.strptime(
                    order["placedDate"], BETFAIR_DATE_FORMAT)
            assert resource.place_instruction_reports[
                0].error_code == order.get("errorCode")

            assert (resource.place_instruction_reports[0].instruction.
                    selection_id == order["instruction"]["selectionId"])
            assert (resource.place_instruction_reports[0].instruction.side ==
                    order["instruction"]["side"])
            assert (resource.place_instruction_reports[0].instruction.
                    order_type == order["instruction"]["orderType"])
            assert (resource.place_instruction_reports[0].instruction.handicap
                    == order["instruction"]["handicap"])

            assert (resource.place_instruction_reports[0].instruction.
                    limit_order.persistence_type == order["instruction"]
                    ["limitOrder"]["persistenceType"])
            assert (
                resource.place_instruction_reports[0].instruction.limit_order.
                price == order["instruction"]["limitOrder"]["price"])
            assert (
                resource.place_instruction_reports[0].instruction.limit_order.
                size == order["instruction"]["limitOrder"]["size"])