Skip to content

Commit

Permalink
Add a test for filtered params.
Browse files Browse the repository at this point in the history
  • Loading branch information
pydanny committed Mar 13, 2012
1 parent fb331fc commit 6c0c791
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
1 change: 1 addition & 0 deletions oauthlib/oauth.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
SIGNATURE_TYPE_AUTH_HEADER = u'AUTH_HEADER'
SIGNATURE_TYPE_QUERY = u'QUERY'


class OAuthClient(object):
"""An OAuth client used to sign OAuth requests"""
def __init__(self, client_key, client_secret,
Expand Down
34 changes: 34 additions & 0 deletions tests/test_utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
from __future__ import absolute_import

from .unittest import TestCase

from oauthlib.utils import *


class UtilsTests(TestCase):

def test_filter_params(self):

@filter_params
def special_test_function(params, realm=None):
""" I am a special test function """
return 'OAuth ' + ','.join(['='.join([k, v]) for k, v in params])

# check that the docstring got through
self.assertEqual(special_test_function.__doc__, " I am a special test function ")

sample_params = [
("notoauth", "shouldnotbehere"),
("oauth_consumer_key", "9djdj82h48djs9d2"),
("oauth_token", "kkk9d7dh3k39sjv7"),
("notoautheither", "shouldnotbehere")
]

# Check that the filtering works as per design.
# Any param that does not start with 'oauth'
# should not be present in the filtered params
filtered_params = special_test_function(sample_params)
self.assertFalse("notoauth" in filtered_params)
self.assertTrue("oauth_consumer_key" in filtered_params)
self.assertTrue("oauth_token" in filtered_params)
self.assertFalse("notoautheither" in filtered_params)

0 comments on commit 6c0c791

Please sign in to comment.