How to use betfairlightweight - 10 common examples

To help you get started, we’ve selected a few betfairlightweight examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github liampauling / betfair / tests / unit / test_inplayservice.py View on Github external
def test_init(self):
        assert self.in_play_service.connect_timeout == 3.05
        assert self.in_play_service.read_timeout == 16
        assert self.in_play_service._error == APIError
        assert self.in_play_service.client == self.client
github liampauling / betfair / tests / unit / test_cache.py View on Github external
def test_init(self):
        assert self.unmatched_order.bet_id == 1
        assert self.unmatched_order.price == 2
        assert self.unmatched_order.size == 3
        assert self.unmatched_order.side == 'L'
        assert self.unmatched_order.status == 'E'
        assert self.unmatched_order.persistence_type == 'L'
        assert self.unmatched_order.order_type == 'L'
        assert self.unmatched_order.placed_date == BaseResource.strip_datetime(8)
        assert self.unmatched_order.size_matched == 9
        assert self.unmatched_order.size_remaining == 10
        assert self.unmatched_order.size_lapsed == 11
        assert self.unmatched_order.size_cancelled == 12
        assert self.unmatched_order.size_voided == 13
        assert self.unmatched_order.reference_order == 14
        assert self.unmatched_order.reference_strategy == 15
        assert self.unmatched_order.lapsed_date == 16
        assert self.unmatched_order.lapse_status_reason_code == 17
github liampauling / betfair / tests / unit / test_baseendpoint.py View on Github external
def test_base_endpoint_init(self):
        client = APIClient('username', 'password', 'app_key')
        base_endpoint = BaseEndpoint(client)
        assert base_endpoint.connect_timeout == 3.05
        assert base_endpoint.read_timeout == 16
        assert base_endpoint._error == APIError
        assert base_endpoint.client == client
github liampauling / betfair / tests / unit / test_historical.py View on Github external
def test_request_error(self, mock_post, mock_headers):
        params = {'test': 'me'}
        method = 'test'
        url = 'https://historicdata.betfair.com/api/test'
        mock_post.side_effect = ConnectionError()
        with self.assertRaises(APIError):
            self.historic.request(params=params, method=method, session=None)

        mock_post.side_effect = ValueError()
        with self.assertRaises(APIError):
            self.historic.request(params=params, method=method, session=None)
github liampauling / betfair / tests / unit / test_historical.py View on Github external
def test_request_error(self, mock_post, mock_headers):
        params = {'test': 'me'}
        method = 'test'
        url = 'https://historicdata.betfair.com/api/test'
        mock_post.side_effect = ConnectionError()
        with self.assertRaises(APIError):
            self.historic.request(params=params, method=method, session=None)

        mock_post.side_effect = ValueError()
        with self.assertRaises(APIError):
            self.historic.request(params=params, method=method, session=None)
github liampauling / betfair / tests / fixtures.py View on Github external
def client_aus():
    return APIClient('username', 'password', 'app_key', 'AUS')
github liampauling / betfair / tests / unit / test_keepalive.py View on Github external
def setUp(self):
        client = APIClient('username', 'password', 'app_key', 'UK')
        self.keep_alive = KeepAlive(client)
github liampauling / betfair / tests / unit / test_baseendpoint.py View on Github external
response_result_list = {'result': [{}, {}]}
        response = self.base_endpoint.process_response(response_result_list, mock_resource, None, False)
        assert type(response) == list
        assert response[0] == mock_resource()

        response_result = {'result': {}}
        response = self.base_endpoint.process_response(response_result, mock_resource, None, False)
        assert response == mock_resource()

        # lightweight tests
        response_list = [{}, {}]
        response = self.base_endpoint.process_response(response_list, mock_resource, None, True)
        assert response == response_list

        client = APIClient('username', 'password', 'app_key', lightweight=True)
        base_endpoint = BaseEndpoint(client)
        response_list = [{}, {}]
        response = base_endpoint.process_response(response_list, mock_resource, None, False)
        assert type(response) == list
        assert response[0] == mock_resource()
github liampauling / betfair / tests / unit / test_baseclient.py View on Github external
def setUp(self):
        self.client = APIClient('bf_username', 'password', 'app_key', os.path.normpath('fail/'))
github liampauling / betfair / tests / unit / test_racecard.py View on Github external
def setUp(self):
        self.client = APIClient("username", "password", "app_key", "UK")
        self.race_card = RaceCard(self.client)