def test_market_book(self):
        mock_response = create_mock_json('tests/resources/list_market_book.json')
        market_books = mock_response.json().get('result')

        for market_book in market_books:
            resource = resources.MarketBook(date_time_sent=self.DATE_TIME_SENT,
                                            **market_book)
            assert resource._datetime_sent == self.DATE_TIME_SENT
            assert resource.market_id == market_book['marketId']
            assert resource.bet_delay == market_book['betDelay']
            assert resource.bsp_reconciled == market_book['bspReconciled']
            assert resource.complete == market_book['complete']
            assert resource.cross_matching == market_book['crossMatching']
            assert resource.inplay == market_book['inplay']
            assert resource.is_market_data_delayed == market_book['isMarketDataDelayed']
            assert resource.last_match_time == datetime.datetime.strptime(
                    market_book['lastMatchTime'], "%Y-%m-%dT%H:%M:%S.%fZ")
            assert resource.number_of_active_runners == market_book['numberOfActiveRunners']
            assert resource.number_of_runners == market_book['numberOfRunners']
            assert resource.number_of_winners == market_book['numberOfWinners']
            assert resource.runners_voidable == market_book['runnersVoidable']
            assert resource.status == market_book['status']
            assert resource.total_available == market_book['totalAvailable']
            assert resource.total_matched == market_book['totalMatched']
            assert resource.version == market_book['version']

            assert len(resource.runners) == len(market_book['runners'])

            for runner in market_book['runners']:
                pass
Пример #2
0
    def test_market_book(self):
        mock_response = create_mock_json(
            'tests/resources/list_market_book.json')
        market_books = mock_response.json().get('result')

        for market_book in market_books:
            resource = resources.MarketBook(elapsed_time=self.ELAPSED_TIME,
                                            **market_book)
            assert resource.elapsed_time == self.ELAPSED_TIME
            assert resource.market_id == market_book['marketId']
            assert resource.bet_delay == market_book['betDelay']
            assert resource.bsp_reconciled == market_book['bspReconciled']
            assert resource.complete == market_book['complete']
            assert resource.cross_matching == market_book['crossMatching']
            assert resource.inplay == market_book['inplay']
            assert resource.is_market_data_delayed == market_book[
                'isMarketDataDelayed']
            assert resource.last_match_time == datetime.datetime.strptime(
                market_book['lastMatchTime'], "%Y-%m-%dT%H:%M:%S.%fZ")
            assert resource.number_of_active_runners == market_book[
                'numberOfActiveRunners']
            assert resource.number_of_runners == market_book['numberOfRunners']
            assert resource.number_of_winners == market_book['numberOfWinners']
            assert resource.runners_voidable == market_book['runnersVoidable']
            assert resource.status == market_book['status']
            assert resource.total_available == market_book['totalAvailable']
            assert resource.total_matched == market_book['totalMatched']
            assert resource.version == market_book['version']

            assert len(resource.runners) == len(market_book['runners'])

            for i, key_line in enumerate(market_book['keyLineDescription'].get(
                    'keyLine', [])):
                assert key_line[
                    'handicap'] == resource.key_line_description.key_line[
                        i].handicap
                assert key_line[
                    'selectionId'] == resource.key_line_description.key_line[
                        i].selection_id

            for i, runner in enumerate(market_book['runners']):
                resource_runner = resource.runners[i]
                assert resource_runner.selection_id == runner['selectionId']
                assert resource_runner.status == runner['status']
                assert resource_runner.total_matched == runner.get(
                    'totalMatched')
                assert resource_runner.adjustment_factor == runner.get(
                    'adjustmentFactor')
                assert resource_runner.handicap == runner['handicap']
                assert resource_runner.last_price_traded == runner.get(
                    'lastPriceTraded')

                if runner.get('removalDate'):
                    assert resource_runner.removal_date == datetime.datetime.strptime(
                        runner['removalDate'], "%Y-%m-%dT%H:%M:%S.%fZ")
Пример #3
0
    def test_market_book(self):
        mock_response = create_mock_json(
            "tests/resources/list_market_book.json")
        market_books = mock_response.json().get("result")

        for market_book in market_books:
            resource = resources.MarketBook(elapsed_time=self.ELAPSED_TIME,
                                            **market_book)
            assert resource.elapsed_time == self.ELAPSED_TIME
            assert resource.market_id == market_book["marketId"]
            assert resource.bet_delay == market_book["betDelay"]
            assert resource.bsp_reconciled == market_book["bspReconciled"]
            assert resource.complete == market_book["complete"]
            assert resource.cross_matching == market_book["crossMatching"]
            assert resource.inplay == market_book["inplay"]
            assert resource.is_market_data_delayed == market_book[
                "isMarketDataDelayed"]
            assert resource.last_match_time == datetime.datetime.strptime(
                market_book["lastMatchTime"], BETFAIR_DATE_FORMAT)
            assert (resource.number_of_active_runners ==
                    market_book["numberOfActiveRunners"])
            assert resource.number_of_runners == market_book["numberOfRunners"]
            assert resource.number_of_winners == market_book["numberOfWinners"]
            assert resource.runners_voidable == market_book["runnersVoidable"]
            assert resource.status == market_book["status"]
            assert resource.total_available == market_book["totalAvailable"]
            assert resource.total_matched == market_book["totalMatched"]
            assert resource.version == market_book["version"]

            assert len(resource.runners) == len(market_book["runners"])

            for i, key_line in enumerate(market_book["keyLineDescription"].get(
                    "keyLine", [])):
                assert (key_line["handicap"] ==
                        resource.key_line_description.key_line[i].handicap)
                assert (key_line["selectionId"] ==
                        resource.key_line_description.key_line[i].selection_id)

            for i, runner in enumerate(market_book["runners"]):
                resource_runner = resource.runners[i]
                assert resource_runner.selection_id == runner["selectionId"]
                assert resource_runner.status == runner["status"]
                assert resource_runner.total_matched == runner.get(
                    "totalMatched")
                assert resource_runner.adjustment_factor == runner.get(
                    "adjustmentFactor")
                assert resource_runner.handicap == runner["handicap"]
                assert resource_runner.last_price_traded == runner.get(
                    "lastPriceTraded")

                if runner.get("removalDate"):
                    assert resource_runner.removal_date == datetime.datetime.strptime(
                        runner["removalDate"], BETFAIR_DATE_FORMAT)