1
+ import sys
1
2
import time
2
3
import getpass
3
4
import unittest
4
5
from instagram import *
5
6
6
- client_id = "124a2ff750454d2ba4f70ddc0fc691d2"
7
- client_secret = "22d0c7184ece41bebd0de13788a31a31"
8
- access_token = "124a2ff.fb8bfc19ff7a47008d55e0edc74ad7aa"
9
- redirect_uri = "http://mikeyktest.com"
7
+ try :
8
+ from test_settings import *
9
+ except Exception :
10
+ print "Must have a test_settings.py file with settings defined"
11
+ sys .exit (1 )
12
+
13
+
14
+ class TestInstagramAPI (InstagramAPI ):
15
+ host = test_host
16
+ base_path = test_base_path
17
+ access_token_field = "access_token"
18
+ authorize_url = test_authorize_url
19
+ access_token_url = test_access_token_url
20
+ protocol = test_protocol
21
+
10
22
11
23
class InstagramAuthTests (unittest .TestCase ):
12
24
def setUp (self ):
13
- self .unauthenticated_api = InstagramAPI (client_id = client_id , redirect_uri = redirect_uri , client_secret = client_secret )
25
+ self .unauthenticated_api = TestInstagramAPI (client_id = client_id , redirect_uri = redirect_uri , client_secret = client_secret )
14
26
15
27
def test_authorize_login_url (self ):
16
28
redirect_uri = self .unauthenticated_api .get_authorize_login_url ()
@@ -31,15 +43,14 @@ def test_xauth_exchange(self):
31
43
return
32
44
password = getpass .getpass ("Enter password for XAuth (blank to skip): " ).strip ()
33
45
access_token = self .unauthenticated_api .exchange_xauth_login_for_access_token (username , password )
34
- print 'authorized with access token ' , access_token
35
46
assert access_token
36
47
37
48
38
49
class InstagramAPITests (unittest .TestCase ):
39
50
40
51
def setUp (self ):
41
- self .client_only_api = InstagramAPI (client_id = client_id )
42
- self .api = InstagramAPI (access_token = access_token )
52
+ self .client_only_api = TestInstagramAPI (client_id = client_id )
53
+ self .api = TestInstagramAPI (access_token = access_token )
43
54
44
55
def test_popular_media (self ):
45
56
self .api .popular_media (count = 10 )
0 commit comments