Skip to content

Commit

Permalink
Merge 11938da into 764aad6
Browse files Browse the repository at this point in the history
  • Loading branch information
liampauling committed Nov 23, 2018
2 parents 764aad6 + 11938da commit 9bd89e6
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 4 deletions.
9 changes: 9 additions & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,15 @@
Release History
---------------

1.8.2 (2018-11-23)
+++++++++++++++++++

**Improvements**

- Certificate url for login updated.
- publish_time_epoch added to MarketBook.
- marketDefinition added to serialise so that lightweight has it returned.

1.8.1 (2018-10-12)
+++++++++++++++++++

Expand Down
2 changes: 1 addition & 1 deletion betfairlightweight/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from . import filters

__title__ = 'betfairlightweight'
__version__ = '1.8.1'
__version__ = '1.8.2'
__author__ = 'Liam Pauling'

# Set default logging handler to avoid "No handler found" warnings.
Expand Down
10 changes: 10 additions & 0 deletions betfairlightweight/baseclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,15 @@ class BaseClient(object):
europe='https://identitysso.betfaironline.eu',
)

IDENTITY_CERT_URLS = collections.defaultdict(
lambda: 'https://identitysso-cert.betfair.com/api/',
spain='https://identitysso-cert.betfair.es/api/',
italy='https://identitysso-cert.betfair.it/api/',
romania='https://identitysso-cert.betfair.ro/api/',
# w_con='https://identitysso.w-con.betfair.com',
# europe='https://identitysso.betfaironline.eu',
)

API_URLS = collections.defaultdict(
lambda: 'https://api.betfair.com/exchange/'
)
Expand Down Expand Up @@ -60,6 +69,7 @@ def __init__(self, username, password=None, app_key=None, certs=None, locale=Non
self._login_time = None
self.session_token = None
self.identity_uri = self.IDENTITY_URLS[locale]
self.identity_cert_uri = self.IDENTITY_CERT_URLS[locale]
self.api_uri = self.API_URLS[locale]
self.navigation_uri = self.NAVIGATION_URLS[locale]

Expand Down
2 changes: 1 addition & 1 deletion betfairlightweight/endpoints/login.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def _error_handler(self, response, method=None, params=None):

@property
def url(self):
return '%s%s' % (self.client.identity_uri, 'certlogin')
return '%s%s' % (self.client.identity_cert_uri, 'certlogin')

@property
def data(self):
Expand Down
1 change: 1 addition & 0 deletions betfairlightweight/resources/bettingresources.py
Original file line number Diff line number Diff line change
Expand Up @@ -495,6 +495,7 @@ def __init__(self, **kwargs):
self.version = kwargs.get('version')
self.runners = [RunnerBook(**i) for i in kwargs.get('runners')]
self.publish_time = self.strip_datetime(kwargs.get('publishTime'))
self.publish_time_epoch = kwargs.get('publishTime')
self.key_line_description = KeyLine(**kwargs.get('keyLineDescription')
) if kwargs.get('keyLineDescription') else None
self.price_ladder_definition = PriceLadderDescription(**kwargs.get('priceLadderDefinition')
Expand Down
1 change: 1 addition & 0 deletions betfairlightweight/streaming/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,7 @@ def serialise(self):
'publishTime': self.publish_time,
'priceLadderDefinition': self.market_definition.get('priceLadderDefinition'),
'keyLineDescription': self.market_definition.get('keyLineDefinition'),
'marketDefinition': self.market_definition, # used in lightweight
}


Expand Down
7 changes: 7 additions & 0 deletions tests/unit/test_baseclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,42 +28,49 @@ def test_uri(self):
assert client.identity_uri == 'https://identitysso.betfair.com/api/'
assert client.api_uri == 'https://api.betfair.com/exchange/'
assert client.navigation_uri == 'https://api.betfair.com/exchange/betting/rest/v1/en/navigation/menu.json'
assert client.identity_cert_uri == 'https://identitysso-cert.betfair.com/api/'

client = APIClient('bf_username', 'password', 'app_key', locale='australia')
assert client.locale == 'australia'
assert client.identity_uri == 'https://identitysso.betfair.com/api/'
assert client.api_uri == 'https://api.betfair.com/exchange/'
assert client.navigation_uri == 'https://api.betfair.com/exchange/betting/rest/v1/en/navigation/menu.json'
assert client.identity_cert_uri == 'https://identitysso-cert.betfair.com/api/'

client = APIClient('bf_username', 'password', 'app_key', locale='spain')
assert client.locale == 'spain'
assert client.identity_uri == 'https://identitysso.betfair.es/api/'
assert client.api_uri == 'https://api.betfair.com/exchange/'
assert client.navigation_uri == 'https://api.betfair.es/exchange/betting/rest/v1/en/navigation/menu.json'
assert client.identity_cert_uri == 'https://identitysso-cert.betfair.es/api/'

client = APIClient('bf_username', 'password', 'app_key', locale='italy')
assert client.locale == 'italy'
assert client.identity_uri == 'https://identitysso.betfair.it/api/'
assert client.api_uri == 'https://api.betfair.com/exchange/'
assert client.navigation_uri == 'https://api.betfair.it/exchange/betting/rest/v1/en/navigation/menu.json'
assert client.identity_cert_uri == 'https://identitysso-cert.betfair.it/api/'

client = APIClient('bf_username', 'password', 'app_key', locale='romania')
assert client.locale == 'romania'
assert client.identity_uri == 'https://idenititysso.betfair.ro'
assert client.api_uri == 'https://api.betfair.com/exchange/'
assert client.navigation_uri == 'https://api.betfair.com/exchange/betting/rest/v1/en/navigation/menu.json'
assert client.identity_cert_uri == 'https://identitysso-cert.betfair.ro/api/'

client = APIClient('bf_username', 'password', 'app_key', locale='w_con')
assert client.locale == 'w_con'
assert client.identity_uri == 'https://identitysso.w-con.betfair.com'
assert client.api_uri == 'https://api.betfair.com/exchange/'
assert client.navigation_uri == 'https://api.betfair.com/exchange/betting/rest/v1/en/navigation/menu.json'
# assert client.identity_cert_uri == 'https://identitysso-cert.betfair.com/api/'

client = APIClient('bf_username', 'password', 'app_key', locale='europe')
assert client.locale == 'europe'
assert client.identity_uri == 'https://identitysso.betfaironline.eu'
assert client.api_uri == 'https://api.betfair.com/exchange/'
assert client.navigation_uri == 'https://api.betfair.com/exchange/betting/rest/v1/en/navigation/menu.json'
# assert client.identity_cert_uri == 'https://identitysso-cert.betfair.com/api/'


class BaseClientTest(unittest.TestCase):
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/test_login.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def test_request(self, mock_post, mock_login_headers, mock_cert):
mock_response = create_mock_json('tests/resources/login_success.json')
mock_post.return_value = mock_response

url = 'https://identitysso.betfair.com/api/certlogin'
url = 'https://identitysso-cert.betfair.com/api/certlogin'
response = self.login.request()

mock_post.assert_called_once_with(url, data={'username': 'username', 'password': 'password'},
Expand Down Expand Up @@ -73,7 +73,7 @@ def test_login_error_handler(self):
self.login._error_handler(mock_response.json())

def test_url(self):
assert self.login.url == 'https://identitysso.betfair.com/api/certlogin'
assert self.login.url == 'https://identitysso-cert.betfair.com/api/certlogin'

def test_data(self):
assert self.login.data == {'username': 'username', 'password': 'password'}

0 comments on commit 9bd89e6

Please sign in to comment.