-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathtest.py
66 lines (53 loc) · 1.75 KB
/
test.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
from api import StreamClient, ObjCode, AtTaskObject
def example():
client = StreamClient('http://localhost:8080/attask/api')
print 'Logging in...'
client.login('admin','user')
print 'Done'
print 'Retrieving user...'
user = AtTaskObject(client.get(ObjCode.USER,client.user_id,['ID','homeGroupID','emailAddr']))
print 'Done'
print user
print 'Searching projects...'
results = client.search(ObjCode.PROJECT,{'groupID':user.homeGroupID})
print 'Done'
print '%s project(s) found' % len(results)
for p in results:
project = AtTaskObject(p)
print ' - %s' % project.name
print 'Creating project...'
project = AtTaskObject(client.post(ObjCode.PROJECT,{'name':'My Project','groupID':user.homeGroupID}))
print 'Done'
print project
print 'Retrieving project...'
project = AtTaskObject(client.get(ObjCode.PROJECT,project.ID))
print 'Done'
print project
print 'Editing project...'
project = AtTaskObject(client.put(ObjCode.PROJECT,project.ID,{'ownerID':user.ID}),client)
print 'Done'
print project
print 'Deleting project...'
client.delete(ObjCode.PROJECT,project.ID)
print 'Done'
print 'Creating another project...'
project = AtTaskObject({},client)
project.objCode = ObjCode.PROJECT
project.name = 'My New Project'
project.groupID = user.homeGroupID
project.save()
print 'Done'
print project
print 'Editing another project...'
project.ownerID = user.ID
project.save()
print 'Done'
print project
print 'Deleting another project...'
client.delete(ObjCode.PROJECT,project.ID)
print 'Done'
print 'Logging out...'
client.logout()
print 'Done'
if __name__ == '__main__':
example()