forked from Rexxt/papillon-python
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.py
86 lines (76 loc) · 2.39 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
import requests, time
print('Testeur papillon-python')
api_url = input('URL de l\'API (http://127.0.0.1:8000) $ ')
if api_url == '':
api_url = 'http://127.0.0.1:8000'
pronote_url = input('URL de Pronote $ ')
username = input('Nom d\'utilisateur $ ')
password = input('Mot de passe $ ')
ent = input('Code de l\'ENT $ ')
response = requests.post(api_url.rstrip('/') + '/generatetoken', data={'url': pronote_url, 'username': username, 'password': password, 'ent': ent})
print('login effectué')
token = response.json()
start = time.time()
response = requests.get(api_url.rstrip('/') + '/user', params={'token': token})
end = time.time()
print(f'/user ({round((end-start)*1000)}ms):')
try:
print(response.json())
except:
print('fail')
start = time.time()
response = requests.get(api_url.rstrip('/') + '/timetable', params={'token': token, 'dateString': '2022-01-05'})
end = time.time()
print(f'/timetable ({round((end-start)*1000)}ms):')
try:
print(response.json())
except:
print('fail')
start = time.time()
response = requests.get(api_url.rstrip('/') + '/homework', params={'token': token, 'dateFrom': '2022-01-05', 'dateTo': '2022-01-09'})
end = time.time()
print(f'/homework ({round((end-start)*1000)}ms):')
try:
print(response.json())
except:
print('fail')
start = time.time()
response = requests.get(api_url.rstrip('/') + '/grades', params={'token': token})
end = time.time()
print(f'/grades ({round((end-start)*1000)}ms):')
try:
print(response.json())
except:
print('fail')
start = time.time()
response = requests.get(api_url.rstrip('/') + '/absences', params={'token': token})
end = time.time()
print(f'/absences ({round((end-start)*1000)}ms):')
try:
print(response.json())
except:
print('fail')
start = time.time()
response = requests.get(api_url.rstrip('/') + '/news', params={'token': token})
end = time.time()
print(f'/news ({round((end-start)*1000)}ms):')
try:
print(response.json())
except:
print('fail')
start = time.time()
response = requests.get(api_url.rstrip('/') + '/discussions', params={'token': token})
end = time.time()
print(f'/discussions ({round((end-start)*1000)}ms):')
try:
print(response.json())
except:
print('fail')
start = time.time()
response = requests.get(api_url.rstrip('/') + '/export/ical', params={'token': token})
end = time.time()
print(f'/export/ical ({round((end-start)*1000)}ms):')
try:
print(response.json())
except:
print('fail')