Skip to content

Commit 2f22d2f

Browse files
committed
Merge branch 'master' of github.com:miLibris/flask-rest-jsonapi
2 parents 20e5a56 + 9969438 commit 2f22d2f

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

flask_rest_jsonapi/api.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ def __init__(self, app=None, blueprint=None, decorators=None):
2626
self.resource_registry = []
2727
self.decorators = decorators or tuple()
2828

29+
if app is not None:
30+
self.init_app(app, blueprint)
31+
2932
def init_app(self, app=None, blueprint=None):
3033
"""Update flask application with our api
3134

flask_rest_jsonapi/pagination.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
"""Helper to create pagination links according to jsonapi specification"""
44

5+
from __future__ import division
56
from six.moves.urllib.parse import urlencode
67
from math import ceil
78
from copy import copy

tests/test_sqlalchemy_data_layer.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# -*- coding: utf-8 -*-
22

3-
from six.moves.urllib.parse import urlencode
3+
from six.moves.urllib.parse import urlencode, parse_qs
44
import pytest
55

66
from sqlalchemy import create_engine, Column, Integer, DateTime, String, ForeignKey
@@ -330,10 +330,13 @@ def __init__(self, kwargs):
330330

331331
def test_add_pagination_links(app):
332332
with app.app_context():
333-
qs = {'page[number]': '15', 'page[size]': '10'}
333+
qs = {'page[number]': '2', 'page[size]': '10'}
334334
qsm = QSManager(qs, None)
335-
add_pagination_links(dict(), 1000, qsm, str())
336-
335+
pagination_dict = dict()
336+
add_pagination_links(pagination_dict, 43, qsm, str())
337+
last_page_dict = parse_qs(pagination_dict['links']['last'][1:])
338+
assert len(last_page_dict['page[number]']) == 1
339+
assert last_page_dict['page[number]'][0] == '5'
337340

338341
def test_Node(person_model, person_schema, monkeypatch):
339342
from copy import deepcopy

0 commit comments

Comments
 (0)