Skip to content

Commit eb417bd

Browse files
authored
Merge pull request #169 from gustavo-bertoldi/master
Fix pagination
2 parents 899eb28 + ddc2deb commit eb417bd

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

amadeus/mixins/pagination.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ def __page(self, name, response):
3535

3636
def __page_number_for(self, name, response):
3737
try:
38-
return response.result['meta']['links'][name].split('=')[-1]
38+
url = response.result['meta']['links'][name]
39+
return url.split('page%5Boffset%5D=')[1].split('&')[0]
3940
except Exception:
4041
return None

specs/mixins/pagination_spec.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
with context('Client.previous'):
2727
with it('should create a new request with the page and call it'):
2828
self.response.result = {
29-
'meta': {'links': {'previous': 'http://f.co?page=1'}}
29+
'meta': {'links': {'previous': 'http://f.co?page%5Boffset%5D=1'}}
3030
}
3131

3232
next_response = self.pagination.previous(self.response)
@@ -44,7 +44,7 @@
4444
with context('Client.next'):
4545
with it('should create a new request with the page and call it'):
4646
self.response.result = {
47-
'meta': {'links': {'next': 'http://f.co?page=1'}}
47+
'meta': {'links': {'next': 'http://f.co?page%5Boffset%5D=1'}}
4848
}
4949

5050
next_response = self.pagination.next(self.response)
@@ -62,7 +62,7 @@
6262
with context('Client.first'):
6363
with it('should create a new request with the page and call it'):
6464
self.response.result = {
65-
'meta': {'links': {'first': 'http://f.co?page=1'}}
65+
'meta': {'links': {'first': 'http://f.co?page%5Boffset%5D=1'}}
6666
}
6767

6868
next_response = self.pagination.first(self.response)
@@ -81,7 +81,7 @@
8181
with it('should create a new request with the page and call it'):
8282
self.response.request.params = {'page': {'offset': '0'}}
8383
self.response.result = {
84-
'meta': {'links': {'last': 'http://f.co?page=1'}}
84+
'meta': {'links': {'last': 'http://f.co?page%5Boffset%5D=1'}}
8585
}
8686

8787
next_response = self.pagination.last(self.response)

0 commit comments

Comments
 (0)