Skip to content

Commit

Permalink
0.6.5
Browse files Browse the repository at this point in the history
timeout changed to connect_timeout and read_timeout
changed due to 12s bet delay on some markets
future will be able to have read_timeout as param for request
tests updated
  • Loading branch information
liampauling committed Oct 9, 2016
1 parent 55db18b commit 99a0cf7
Show file tree
Hide file tree
Showing 11 changed files with 22 additions and 16 deletions.
2 changes: 1 addition & 1 deletion betfairlightweight/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
from .streaming import StreamListener


__version__ = '0.6.4'
__version__ = '0.6.5'
2 changes: 1 addition & 1 deletion betfairlightweight/endpoints/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
class Account(BaseEndpoint):

URI = 'AccountAPING/v1.0/'
timeout = 6.05
connect_timeout = 6.05

def get_account_funds(self, params=None, session=None):
date_time_sent = datetime.datetime.utcnow()
Expand Down
5 changes: 3 additions & 2 deletions betfairlightweight/endpoints/baseendpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@

class BaseEndpoint:

timeout = 3.05
connect_timeout = 3.05
read_timeout = 16
_error = APIError

def __init__(self, parent):
Expand All @@ -25,7 +26,7 @@ def request(self, method, params, session):
request = self.create_req(method, params)
try:
response = session.post(self.url, data=request, headers=self.client.request_headers,
timeout=(self.timeout, 12))
timeout=(self.connect_timeout, self.read_timeout))
except ConnectionError:
raise APIError(None, method, params, 'ConnectionError')
except Exception as e:
Expand Down
2 changes: 1 addition & 1 deletion betfairlightweight/endpoints/navigation.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def request(self, method=None, params=None, session=None):
session = session or self.client.session
try:
response = session.get(self.url, headers=self.client.request_headers,
timeout=(self.timeout, 12))
timeout=(self.connect_timeout, self.read_timeout))
except ConnectionError:
raise APIError(None, method, params, 'ConnectionError')
except Exception as e:
Expand Down
3 changes: 2 additions & 1 deletion tests/test_account.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ class AccountInit(unittest.TestCase):
def test_base_endpoint_init(self):
client = APIClient('username', 'password', 'app_key')
account = Account(client)
assert account.timeout == 6.05
assert account.connect_timeout == 6.05
assert account.read_timeout == 16
assert account._error == APIError
assert account.client == client
assert account.URI == 'AccountAPING/v1.0/'
Expand Down
5 changes: 3 additions & 2 deletions tests/test_baseendpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ class BaseEndpointInit(unittest.TestCase):
def test_base_endpoint_init(self):
client = APIClient('username', 'password', 'app_key')
base_endpoint = BaseEndpoint(client)
assert base_endpoint.timeout == 3.05
assert base_endpoint.connect_timeout == 3.05
assert base_endpoint.read_timeout == 16
assert base_endpoint._error == APIError
assert base_endpoint.client == client

Expand Down Expand Up @@ -48,7 +49,7 @@ def test_request(self, mock_post, mock_request_headers, mock_cert, mock_create_r
response = self.base_endpoint.request(None, None, None)

mock_post.assert_called_once_with(url, data=mock_create_req(),
headers=mock_request_headers, timeout=(3.05, 12))
headers=mock_request_headers, timeout=(3.05, 16))
assert response == mock_response

def test_base_endpoint_error_handler(self):
Expand Down
3 changes: 2 additions & 1 deletion tests/test_betting.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ class BettingInit(unittest.TestCase):
def test_base_endpoint_init(self):
client = APIClient('username', 'password', 'app_key')
betting = Betting(client)
assert betting.timeout == 3.05
assert betting.connect_timeout == 3.05
assert betting.read_timeout == 16
assert betting._error == APIError
assert betting.client == client
now = datetime.datetime.now()
Expand Down
3 changes: 2 additions & 1 deletion tests/test_inplayservice.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ def setUp(self):
self.in_play_service = InPlayService(self.client)

def test_init(self):
assert self.in_play_service.timeout == 3.05
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

Expand Down
9 changes: 5 additions & 4 deletions tests/test_navigation.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ class NavigationInit(unittest.TestCase):
def test_base_endpoint_init(self):
client = APIClient('username', 'password', 'app_key')
navigation = Navigation(client)
assert navigation.timeout == 3.05
assert navigation.connect_timeout == 3.05
assert navigation.read_timeout == 16
assert navigation._error == APIError
assert navigation.client == client

Expand Down Expand Up @@ -48,7 +49,7 @@ def test_request(self, mock_get, mock_request_headers, mock_cert):
url = 'https://api.betfair.com/exchange/betting/rest/v1/en/navigation/menu.json'
self.navigation.request()

mock_get.assert_called_once_with(url, headers=mock_request_headers, timeout=(3.05, 12))
mock_get.assert_called_once_with(url, headers=mock_request_headers, timeout=(3.05, 16))

@mock.patch('betfairlightweight.baseclient.BaseClient.cert')
@mock.patch('betfairlightweight.baseclient.BaseClient.request_headers')
Expand All @@ -68,7 +69,7 @@ def test_request_error(self, mock_get, mock_request_headers, mock_cert):
with self.assertRaises(APIError):
self.navigation.request()

mock_get.assert_called_once_with(url, headers=mock_request_headers, timeout=(3.05, 12))
mock_get.assert_called_once_with(url, headers=mock_request_headers, timeout=(3.05, 16))

@mock.patch('betfairlightweight.baseclient.BaseClient.cert')
@mock.patch('betfairlightweight.baseclient.BaseClient.request_headers')
Expand All @@ -88,7 +89,7 @@ def test_request_random(self, mock_get, mock_request_headers, mock_cert):
with self.assertRaises(APIError):
self.navigation.request()

mock_get.assert_called_once_with(url, headers=mock_request_headers, timeout=(3.05, 12))
mock_get.assert_called_once_with(url, headers=mock_request_headers, timeout=(3.05, 16))

def test_url(self):
assert self.navigation.url == self.navigation.client.navigation_uri
2 changes: 1 addition & 1 deletion tests/test_racecard.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def setUp(self):
self.race_card = RaceCard(self.client)

def test_init(self):
assert self.race_card.timeout == 3.05
assert self.race_card.connect_timeout == 3.05
assert self.race_card._error == APIError
assert self.race_card.client == self.client
assert self.race_card.app_key is None
Expand Down
2 changes: 1 addition & 1 deletion tests/test_scores.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class ScoresInit(unittest.TestCase):
def test_base_endpoint_init(self):
client = APIClient('username', 'password', 'app_key')
scores = Scores(client)
assert scores.timeout == 3.05
assert scores.connect_timeout == 3.05
assert scores._error == APIError
assert scores.client == client
assert scores.URI == 'ScoresAPING/v1.0/'
Expand Down

0 comments on commit 99a0cf7

Please sign in to comment.