Daniel Sheffield il y a 1 an
Parent
commit
c184fe810a
1 fichiers modifiés avec 8 ajouts et 20 suppressions
  1. 8 20
      test/rest/test_route_decorators.py

+ 8 - 20
test/rest/test_route_decorators.py

@@ -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
 
-# need to mock bottle request.params
-def test_normalize(counter, tracker, method):
-    decorated = normalize(method)
-    assert callable(decorated)
-    #decorated()
-    #assert counter['method'] == 1
-    #assert tracker['method'][0]['args'] == []
-    #assert tracker['method'][0]['kwargs'] == {'allow': None}
-    decorated = normalize(method, allow=PARAMS)
-    assert callable(decorated)
-    #assert counter['method'] == 2
-    #assert tracker['method'][1]['args'] == []
-    #assert tracker['method'][1]['kwargs'] == {'allow': None}
 
-def test_poison(counter, tracker, method):
-    decorated = poison(cache=None)
+# need to mock bottle request.params
+def test_cache(counter, tracker, method):
+    decorated = cache(query_cache=None, page_cache=None)
     assert callable(decorated)
     #decorated()
     #assert counter['method'] == 1
     #assert tracker['method'][0]['args'] == []
     #assert tracker['method'][0]['kwargs'] == {'allow': None}
     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)