1
+ from __future__ import absolute_import
2
+
3
+ from .unittest import TestCase
4
+
5
+ from oauthlib .utils import *
6
+
7
+
8
+ class UtilsTests (TestCase ):
9
+
10
+ def test_filter_params (self ):
11
+
12
+ @filter_params
13
+ def special_test_function (params , realm = None ):
14
+ """ I am a special test function """
15
+ return 'OAuth ' + ',' .join (['=' .join ([k , v ]) for k , v in params ])
16
+
17
+ # check that the docstring got through
18
+ self .assertEqual (special_test_function .__doc__ , " I am a special test function " )
19
+
20
+ sample_params = [
21
+ ("notoauth" , "shouldnotbehere" ),
22
+ ("oauth_consumer_key" , "9djdj82h48djs9d2" ),
23
+ ("oauth_token" , "kkk9d7dh3k39sjv7" ),
24
+ ("notoautheither" , "shouldnotbehere" )
25
+ ]
26
+
27
+ # Check that the filtering works as per design.
28
+ # Any param that does not start with 'oauth'
29
+ # should not be present in the filtered params
30
+ filtered_params = special_test_function (sample_params )
31
+ self .assertFalse ("notoauth" in filtered_params )
32
+ self .assertTrue ("oauth_consumer_key" in filtered_params )
33
+ self .assertTrue ("oauth_token" in filtered_params )
34
+ self .assertFalse ("notoautheither" in filtered_params )
0 commit comments