|
@@ -8,10 +8,9 @@ from bottle import FormsDict
|
|
|
from pytest import fixture, mark, raises
|
|
|
from app.rest import PARAMS
|
|
|
from app.rest.route_decorators import (
|
|
|
- normalize,
|
|
|
+ cache,
|
|
|
cursor,
|
|
|
normalize_query,
|
|
|
- poison,
|
|
|
)
|
|
|
|
|
|
def incr(_dict, key):
|
|
@@ -37,12 +36,12 @@ def method(counter, tracker):
|
|
|
('product', 'kiwi'),
|
|
|
('product', 'apple'),
|
|
|
('organic', ''),
|
|
|
- ], 'category=&group=&organic=0.5&product=apple%7Ckiwi&tag=&unit='),
|
|
|
+ ], ('category=&group=&organic=0.5&product=apple%7Ckiwi&tag=&unit=', None)),
|
|
|
([
|
|
|
('product', 'kiwi'),
|
|
|
('category', '!baking'),
|
|
|
('organic', '1'),
|
|
|
- ], 'category=%21baking&group=&organic=1&product=kiwi&tag=&unit='),
|
|
|
+ ], ('category=%21baking&group=&organic=1&product=kiwi&tag=&unit=', None)),
|
|
|
])
|
|
|
def test_normalise_query(form_data, expected):
|
|
|
form = FormsDict()
|
|
@@ -51,31 +50,20 @@ def test_normalise_query(form_data, expected):
|
|
|
|
|
|
assert normalize_query(form, allow=PARAMS) == expected
|
|
|
|
|
|
-
|
|
|
-def test_normalize(counter, tracker, method):
|
|
|
- decorated = normalize(method)
|
|
|
- assert callable(decorated)
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- decorated = normalize(method, allow=PARAMS)
|
|
|
- assert callable(decorated)
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
|
|
|
-def test_poison(counter, tracker, method):
|
|
|
- decorated = poison(cache=None)
|
|
|
+
|
|
|
+def test_cache(counter, tracker, method):
|
|
|
+ decorated = cache(query_cache=None, page_cache=None)
|
|
|
assert callable(decorated)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
with raises(Exception) as ex:
|
|
|
- poison(method)
|
|
|
+ cursor(method)
|
|
|
assert ex.value.args[0] == "decorator argument required"
|
|
|
|
|
|
+
|
|
|
def test_cursor(counter, tracker, method):
|
|
|
decorated = cursor(cache=None)
|
|
|
assert callable(decorated)
|