-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_conspyre.py
90 lines (75 loc) · 2.82 KB
/
test_conspyre.py
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
import sys
import conspyre
import time
from conspyre import ConnectionError, ModuleNotFoundException
try:
conspyre.template.connect(server= 'http://127.0.0.1:8080')
except Exception, me:
print me
print "Skipping creation"
conspyre.template.login('Template_dog_lover', 'pass')
conspyre.template.put(key="points", value=100)
print conspyre.template.get(key="points")
print conspyre.template.has(key="points")
conspyre.template.update(dict={"points":101, "title":"Lord Awesome"})
print conspyre.template.items()
print conspyre.template.has(key="points")
print conspyre.template.items()
print conspyre.template.put(key="points", value=100)
print conspyre.template.get(key="points")
print conspyre.template.has(key="clothes")
print conspyre.template.update(dict={"points":200, "clothes": "Alpha, Beta"})
print conspyre.template.get(key="points")
print conspyre.template.items()
conspyre.template.logout()
print "Testing Logging"
conspyre.template.log("Exploding!")
conspyre.template.log("Another!!")
conspyre.template.log("Puppies!")
conspyre.template.disconnect()
print "Attempting to connect to the school server."
conspyre.template.connect(server= 'http://127.0.0.1:8080')
try:
print "Registering Becky"
conspyre.template.register('rtrexler', 'Becky Trexler', 'pass')
except ConnectionError, c:
print c
except Exception, e:
print e
print "Logging Becky in and out"
conspyre.template.login('rtrexler', 'pass')
conspyre.template.logout()
print "Viewing Teachers"
teachers = conspyre.template.get_teacher_list()
print teachers
print "Setting Teacher to Cory"
conspyre.template.teacher= teachers[0]['username']
print "Viewing Students"
print conspyre.template.get_student_list(None)
print "Requesting Password Reset"
try:
conspyre.template.request_reset('rtrexler')
except Exception, e:
print e
print "Skipping password reset."
attempts_left = 5
print "Waiting for password to be reset..."
print "(Log into the server to reset the password)"
while not conspyre.template.password_is_resetable('rtrexler') and attempts_left:
time.sleep(4)
attempts_left-= 1
print "... Password still not reset. Trying %d more times." % attempts_left
if attempts_left:
pass
#conspyre.template.reset_password('rtrexler', 'password')
conspyre.template.login('dog_lover', 'pass')
print "Welcome %s!" % conspyre.template.name
# print "First", conspyre.template.get_dog_list()['dogs']
# dogs = conspyre.template.get_dog_list()['dogs']
# conspyre.template.rename_dog(id=dogs[0]['id'], name='Alfred')
# print "Renamed", conspyre.template.get_dog_list()['dogs']
# conspyre.template.add_dog(breed='poodle', name='dogbert')
# print "Added", conspyre.template.get_dog_list()['dogs']
# dogs = conspyre.template.get_dog_list()['dogs']
# conspyre.template.release_dog(id=dogs[0]['id'])
# print "Removed", conspyre.template.get_dog_list()['dogs']