Skip to content

Commit eb4e48d

Browse files
committed
Merge branch 'master' into contributors-update
2 parents e25232d + 4af6df3 commit eb4e48d

31 files changed

+1278
-1392
lines changed

.github/workflows/build.yml

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ on:
66
branches: [ master ]
77
jobs:
88
build:
9-
runs-on: Ubuntu-18.04
9+
runs-on: ubuntu-20.04
1010
strategy:
1111
fail-fast: false
1212
matrix:
13-
python-version: [3.4, 3.5, 3.6.8]
13+
python-version: ['3.8', '3.9', '3.10']
1414
steps:
1515
- uses: actions/checkout@v2
1616
- name: Set up Python ${{ matrix.python-version }}
@@ -20,12 +20,8 @@ jobs:
2020
- name: Install dependencies
2121
run: |
2222
python -m pip install --upgrade pip
23-
python -m pip install sphinx==1.7.2
24-
pip install tox
25-
python -m pip install sphinx_rtd_theme==0.2.4
26-
pip install virtualenv==20.0.1
23+
python -m pip install --ignore-installed sphinx==3.4.1 tox==3.20.0 sphinx_rtd_theme==0.5.2 "Jinja2<3.1"
2724
- name: Test with tox
28-
if: ${{ matrix.python-version != '3.5' }}
2925
run: |
3026
tox -e py
3127
- name: Before deploy
@@ -34,5 +30,5 @@ jobs:
3430
pip install --upgrade setuptools
3531
make docs
3632
- name: Build binary wheel and a source tarball
37-
if: ${{ matrix.python-version == '3.6.8' }}
38-
run: python setup.py sdist
33+
if: ${{ matrix.python-version == '3.10' }}
34+
run: python setup.py sdist

.github/workflows/publish.yml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ on:
66
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10
77
jobs:
88
build:
9-
runs-on: Ubuntu-18.04
9+
runs-on: Ubuntu-20.04
1010
strategy:
1111
fail-fast: false
1212
matrix:
13-
python-version: [3.6.8]
13+
python-version: [3.10]
1414

1515
steps:
1616
- uses: actions/checkout@v2
@@ -21,10 +21,7 @@ jobs:
2121
- name: Install dependencies
2222
run: |
2323
python -m pip install --upgrade pip
24-
python -m pip install sphinx==1.7.2
25-
pip install tox
26-
pip install sphinx_rtd_theme==0.2.4
27-
pip install virtualenv==20.0.1
24+
python -m pip install --ignore-installed sphinx==3.4.1 tox==3.20.0 sphinx_rtd_theme==0.5.2 "Jinja2<3.1"
2825
- name: Test with tox
2926
run: |
3027
tox -e py

README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Amadeus provides a rich set of APIs for the travel industry. For more details, c
99
Installation
1010
------------
1111

12-
This SDK requires Python 3.4+ (Python 2+ is no longer supported). You can install it directly with pip:
12+
This SDK requires Python 3.8+. You can install it directly with pip:
1313

1414
.. code:: sh
1515

amadeus/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from .version import version
33

44
from .client.location import Location
5+
from .client.hotel import Hotel
56
from .client.direction import Direction
67
from .client.request import Request
78
from .client.response import Response
@@ -13,5 +14,5 @@
1314
'Client', 'Location', 'Direction', 'version', 'ResponseError',
1415
'ParserError', 'ServerError', 'AuthenticationError',
1516
'NotFoundError', 'ClientError', 'Request', 'Response',
16-
'NetworkError'
17+
'NetworkError', 'Hotel'
1718
]

amadeus/mixins/parser.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ def _detect_error(self, client):
1515
if error is not None:
1616
self.__raise_error(error, client)
1717

18-
@staticmethod # noqa: C901
19-
def error_for(status_code, parsed):
18+
@staticmethod
19+
def error_for(status_code, parsed): # noqa: C901
2020
if status_code is None:
2121
return NetworkError
2222
if status_code >= 500:

requirements.txt

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
mamba==0.9.3
2-
expects==0.8.0
3-
doublex==1.8.4
4-
doublex-expects==0.7.0rc2
5-
flake8==3.5.0
6-
flake8-quotes==0.14.0
7-
tox==2.9.1
8-
sphinx==1.7.2
9-
sphinx-rtd-theme==0.2.4
1+
flake8==3.8.0
2+
flake8-quotes==2.1.1
3+
tox==3.20.0
4+
sphinx==3.4.1
5+
sphinx-rtd-theme==0.5.2
6+
pytest==7.2.0
7+
pytest-cov==4.0.0

specs/client/access_token_spec.py

Lines changed: 0 additions & 55 deletions
This file was deleted.

specs/client/request_spec.py

Lines changed: 0 additions & 127 deletions
This file was deleted.

specs/client/response_spec.py

Lines changed: 0 additions & 13 deletions
This file was deleted.

specs/client/test_access_token.py

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
import pytest
2+
import mock
3+
from amadeus import Client
4+
from amadeus.client.access_token import AccessToken
5+
6+
7+
class TokenResponse:
8+
def __init__(self, result):
9+
self.result = result
10+
11+
12+
@pytest.fixture
13+
def self():
14+
self.request = mock.MagicMock(
15+
return_value=TokenResponse({'access_token': 'abc', 'expires_in': 1799}))
16+
self.client = mock.MagicMock(Client)
17+
self.client._unauthenticated_request = self.request
18+
self.client.client_id = '123'
19+
self.client.client_secret = '234'
20+
self.access_token = AccessToken(self.client)
21+
return self
22+
23+
24+
def test_bearer_token(self):
25+
token = self.access_token._bearer_token()
26+
assert token == 'Bearer abc'
27+
self.client._unauthenticated_request.assert_called_with(
28+
'POST', '/v1/security/oauth2/token',
29+
{
30+
'grant_type': 'client_credentials',
31+
'client_id': '123',
32+
'client_secret': '234'
33+
})
34+
35+
36+
def test_cached_token_valid(self):
37+
access_token = self.access_token
38+
token = access_token._bearer_token()
39+
assert token == 'Bearer abc'
40+
self.client._unauthenticated_request.assert_called_once()
41+
token2 = access_token._bearer_token()
42+
assert token2 == 'Bearer abc'
43+
self.client._unauthenticated_request.assert_called_once()
44+
45+
46+
def test_cached_token_expired(self):
47+
access_token = self.access_token
48+
token = access_token._bearer_token()
49+
assert token == 'Bearer abc'
50+
access_token.expires_at = 0
51+
token2 = access_token._bearer_token()
52+
assert token2 == 'Bearer abc'
53+
assert self.client._unauthenticated_request.call_count == 2

0 commit comments

Comments
 (0)