예제 #1
0
    def test_cancel_orders(self):
        mock_response = create_mock_json('tests/resources/cancel_orders.json')
        cancel_orders = mock_response.json().get('result')
        resource = resources.CancelOrders(elapsed_time=self.ELAPSED_TIME,
                                          **cancel_orders)
        assert resource.elapsed_time == self.ELAPSED_TIME
        assert resource.market_id == cancel_orders['marketId']
        assert resource.status == cancel_orders['status']
        assert resource.customer_ref == cancel_orders.get('customerRef')
        assert resource.error_code == cancel_orders.get('errorCode')
        assert len(resource.cancel_instruction_reports) == len(
            cancel_orders.get('instructionReports'))

        for order in cancel_orders.get('instructionReports'):
            assert resource.cancel_instruction_reports[
                0].size_cancelled == order['sizeCancelled']
            assert resource.cancel_instruction_reports[0].status == order[
                'status']
            assert resource.cancel_instruction_reports[
                0].cancelled_date == datetime.datetime.strptime(
                    order['cancelledDate'], "%Y-%m-%dT%H:%M:%S.%fZ")

            assert resource.cancel_instruction_reports[
                0].instruction.bet_id == order['instruction']['betId']
            assert resource.cancel_instruction_reports[
                0].instruction.size_reduction == order['instruction'].get(
                    'sizeReduction')
예제 #2
0
    def test_cancel_orders(self):
        mock_response = create_mock_json("tests/resources/cancel_orders.json")
        cancel_orders = mock_response.json().get("result")
        resource = resources.CancelOrders(elapsed_time=self.ELAPSED_TIME,
                                          **cancel_orders)
        assert resource.elapsed_time == self.ELAPSED_TIME
        assert resource.market_id == cancel_orders["marketId"]
        assert resource.status == cancel_orders["status"]
        assert resource.customer_ref == cancel_orders.get("customerRef")
        assert resource.error_code == cancel_orders.get("errorCode")
        assert len(resource.cancel_instruction_reports) == len(
            cancel_orders.get("instructionReports"))

        for order in cancel_orders.get("instructionReports"):
            assert (resource.cancel_instruction_reports[0].size_cancelled ==
                    order["sizeCancelled"])
            assert resource.cancel_instruction_reports[0].status == order[
                "status"]
            assert resource.cancel_instruction_reports[
                0].cancelled_date == datetime.datetime.strptime(
                    order["cancelledDate"], BETFAIR_DATE_FORMAT)

            assert (resource.cancel_instruction_reports[0].instruction.bet_id
                    == order["instruction"]["betId"])
            assert resource.cancel_instruction_reports[
                0].instruction.size_reduction == order["instruction"].get(
                    "sizeReduction")