forked from korylprince/pygvoicelib
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_save_handler.py
More file actions
executable file
·59 lines (51 loc) · 1.65 KB
/
test_save_handler.py
File metadata and controls
executable file
·59 lines (51 loc) · 1.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/usr/bin/python
import sys
import pygvoicelib
try:
input = raw_input
except NameError:
input = input
save_loc = None
def handle_captcha(voice):
voice.passwd = passwd
print 'Captcha URL is: %s\n' % (voice.captcha_url)
print 'Enter captcha value: '
voice.captcha_entry = input()
def handle_save_token(voice):
global save_loc
print 'Saving Credentials ...'
save_loc = voice.get_state()
def run_test(uesr, passwd)
voice = pygvoicelib.GoogleVoice(user, passwd)
voice.handle_captcha_entry = handle_captcha
voice.handle_save_token = handle_save_token
try:
ret = voice.get_numbers()
ret2 = voice.cancel()
print 'Test 1 OK - We succeeded to login'
except pygvoicelib.LoginError, e:
if e.reason == 'failed':
print 'Test 1 FAILED - We failed to login (Wrong passwod)'
elif e.reason == 'captcha':
print 'Test 1 FAILED - We failed to login (Captcha locked)'
else:
print 'Test 1 FAILED - Unknown Error'
except:
print 'Test 1 FAILED - Unknown Error'
if not save_loc:
print 'Test 2 FAILED - Token not saved'
else:
voice2 = pygvoicelib.GoogleVoice(*save_loc)
try:
ret = voice2.get_numbers()
ret2 = voice2.cancel()
print 'Test 2 OK - The state was loaded properly'
except Exception, e:
print e.reason
print 'Test 2 FAILED - The state was not loaded properly'
if __name__ == '__main__':
print 'Please enter your Google Username:',
user = input()
print 'Please enter your Password:',
passwd = input()
run_test(user, passwd)