def test_sign(self): # this example is taken from # https://dev.twitter.com/docs/auth/creating-signature method = 'post' url = 'https://api.twitter.com/1/statuses/update.json' params = ( ('status', quote('Hello Ladies + Gentlemen, a signed OAuth request!')), ('include_entities', quote('true')), ('oauth_consumer_key', quote('xvz1evFS4wEEPTGEFPHBog')), ('oauth_nonce', quote('kYjzVBB8Y0ZFabxSWbWovY3uYSQ2pTgmZeNu2VS4cg')), ('oauth_signature_method', quote('HMAC-SHA1')), ('oauth_timestamp', quote('1318622958')), ('oauth_token', quote('370773112-GmHxMAgYyLbNEtIKZeRNFsMKPR9EyMZeS9weJAEb')), ('oauth_version', quote('1.0')), ) consumer_secret = 'kAcSOqF21Fu85e7zjz7ZN2U4ZRhfV3WpwPAoE3Z7kBw' oauth_token = 'LswwdoUaIvS8ltyTt5jkRh4J50vUPVVHtR2YPi5kE' self.assertEqual(sign(method, url, params, consumer_secret, oauth_token), quote('tnnArxj06cWHq44gCs1OSKk/jLY='))
def test_quote(self): self.assertEqual(quote('a test'), 'a%20test') self.assertEqual(quote('a/test'), 'a%2Ftest')