8000 Added consumer tests · ptarjan/python-oauth@60f0225 · GitHub
[go: up one dir, main page]

Skip to content

Commit 60f0225

Browse files
committed
Added consumer tests
1 parent 59f582d commit 60f0225

File tree

3 files changed

+76
-0
lines changed

3 files changed

+76
-0
lines changed

tests/config.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
"""
2+
These are my testing keys for all the services. Don't use them, or they will get disabled and then nobody can use them.
3+
"""
4+
class yahoo3leg:
5+
CONSUMER_KEY = 'dj0yJmk9ZkluWDJlbjJQbVE2JmQ9WVdrOWNXWTRURXBwTm0wbWNHbzlNQS0tJnM9Y29uc3VtZXJzZWNyZXQmeD1jNA--'
6+
CONSUMER_SECRET = '72790e933316c39c29c81438d78575b50d61a4c4'
7+
8+
class yahoo2leg:
9+
CONSUMER_KEY = 'dj0yJmk9aE9INGFvY3N6SXpYJmQ9WVdrOU9VMUhZVEZUTlRBbWNHbzlNQS0tJnM9Y29uc3VtZXJzZWNyZXQmeD1iNw--'
10+
CONSUMER_SECRET = 'b0452b9380d48d10a2cbcb741344cea9c5f49408'
11+
12+
class twitter:
13+
CONSUMER_KEY = 'pawFyzXYRtrkLbW3CoYA'
14+
CONSUMER_SECRET = 'krgRy8oRg2p9zEk4015oYsegy43fNpEDqM7bSXRAeM'
15+
16+
class myspace:
17+
CONSUMER_KEY = 'b6d075aae92f4f6daf029bbf9656c18a'
18+
CONSUMER_SECRET = '1a87dc704ebc40c2a3225f2c3fbd015b4931a6415cb449daacc97ceab7bf9493'
19+
20+
class google:
21+
CONSUMER_KEY = 'python-oauth.paulisageek.com'
22+
CONSUMER_SECRET = 'cp0nRYvzDEpmtWpSGacS8qwf'

tests/consumers.py

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
import sys
2+
import unittest
3+
import oauth.consumer
4+
import config
5+
6+
class TestClient(unittest.TestCase):
7+
pass
8+
9+
10+
class TestClient(unittest.TestCase):
11+
12+
def oauth(self, consumer, keys, threeleg, test_url, **kwargs):
13+
self.client = consumer(keys.CONSUMER_KEY, keys.CONSUMER_SECRET, callback_url='oob', **kwargs)
14+
user, url = self.client.start()
15+
if threeleg:
16+
print "Get the token from this url:\n%s\nToken: " % url
17+
verify = sys.stdin.readline().strip()
18+
else:
19+
verify = None
20+
token = user.get_request_token()
21+
self.client.verify(user, token.key, verify)
22+
if test_url:
23+
print user.get_access_token(), verify
24+
respons 8000 e = self.client.fetch(test_url, user)
25+
print response.read()
26+
27+
class Yahoo(TestClient):
28+
29+
def test_2leg(self):
30+
self.oauth(oauth.consumer.Yahoo, config.yahoo2leg, False, "http://query.yahooapis.com/v1/yql?q=select%20*%20from%20xml%20where%20url%3D'http%3A%2F%2Frss.news.yahoo.com%2Frss%2Ftopstories'&format=json")
31+
32+
def test_3leg(self):
33+
self.oauth(oauth.consumer.Yahoo, config.yahoo3leg, True, "http://social.yahooapis.com/v1/me/guid?format=json")
34+
35+
36+
class Twitter(TestClient):
37+
38+
def test_oauth(self):
39+
self.oauth(oauth.consumer.Twitter, config.twitter, True, "http://twitter.com/account/verify_credentials.json")
40+
41+
class Google(TestClient):
42+
43+
def test_oauth(self):
44+
self.oauth(oauth.consumer.Google, config.google, True, "http://www.blogger.com/feeds/default/blogs", scope="http://www.blogger.com/feeds/")
45+
46+
# myspace doesn't support oob auth
47+
#class Myspace(TestClient):
48+
# def test_oauth(self):
49+
# self.oauth(oauth.consumer.Myspace, config.myspace, True, "")
50+
51+
52+
if __name__ == '__main__':
53+
unittest.main()

tests/oauth

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../oauth

0 commit comments

Comments
 (0)
0