-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.py
executable file
·155 lines (130 loc) · 3.96 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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
#!/usr/bin/python
import time
from riot_observer import RiotObserver
from riot_observer import LoLException
from riot_observer import constants as c
GREEN = ('\033[92m') #green
YELLOW = ('\033[93m') #yellow
RED = ('\033[91m') #red
END = ('\033[0m') #reset
key = input("API Key: ")
w = RiotObserver(key=key, default_region=c.NORTH_AMERICA)
def wait():
while not w.can_make_request():
time.sleep(1)
try:
print(YELLOW + "\nTesting: Summoner API" + END)
s_name = input("> Summoner: ")
s = w.get_summoner_by_name(summoner_name=s_name)
wait()
s_id = s['id']
s_accid = s['accountId']
print("> Summoner id: %s " % s_id)
print("> Account id: %s " % s_accid)
s = w.get_summoner_by_id(summoner_id=s_id)
wait()
s = w.get_summoner_by_accountid(account_id=s_accid)
wait()
print("> Name: %s " % s['name'])
print(GREEN + "Summoner API is OK.\n" + END)
time.sleep(2)
except LoLException as e:
print(RED + "Error: %s" % e + "\n" + END)
time.sleep(2)
input("Press enter to continue...")
time.sleep(2)
try:
print(YELLOW + "\nTesting: Champion API" + END)
c = w.get_all_champions(free_to_play=True)
wait()
c_id = c['champions'][0]['id']
print("> Test id: %s " % c_id)
c = w.get_champion(champion_id=c_id)
wait()
print("> Free to play: %s " % c['freeToPlay'])
print(GREEN + "Champion API is OK.\n" + END)
time.sleep(2)
except LoLException as e:
print(RED + "Error: %s" % e + "\n" + END)
time.sleep(2)
input("Press enter to continue...")
time.sleep(2)
try:
print(YELLOW + "\nTesting: Spectator API" + END)
g = w.get_featured_games()
wait()
g_name = g['gameList'][0]['participants'][0]['summonerName']
game_id = g['gameList'][0]['gameId']
print("> Test Summoner Name: %s " % g_name)
g_id = w.get_summoner_by_name(summoner_name=g_name)['id']
wait()
print("> Summoner ID: %s " % g_id)
g = w.get_current_game(summoner_id=g_id)
wait()
print(GREEN + "Spectator API is OK.\n" + END)
time.sleep(2)
except LoLException as e:
print(RED + "Error: %s" % e + "\n" + END)
time.sleep(2)
input("Press enter to continue...")
time.sleep(2)
try:
print(YELLOW + "\nTesting: Match API" + END)
print("> Account ID: %s " % s_accid)
mr = w.get_recent_matchlist(account_id=s_accid)
wait()
m = w.get_matchlist(account_id=s_accid)
wait()
m_id = m['matches'][0]['gameId']
print("> Match id: %s " % m_id)
m = w.get_match(match_id=m_id)
wait()
m = w.get_timeline(match_id=m_id)
wait()
print(GREEN + "Match API is OK.\n" + END)
time.sleep(2)
except LoLException as e:
print(RED + "Error: %s" % e + "\n" + END)
time.sleep(2)
input("Press enter to continue...")
time.sleep(2)
try:
print(YELLOW + "\nTesting: League API" + END)
l = w.get_challenger()
wait()
lcn = l['entries'][0]['playerOrTeamName']
print("> Challenger summoner: %s " % lcn)
l = w.get_position(summoner_id=s_id)
wait()
print(GREEN + "League API is OK.\n" + END)
time.sleep(2)
except LoLException as e:
print(RED + "Error: %s" % e + "\n" + END)
time.sleep(2)
input("Press enter to continue...")
time.sleep(2)
try:
print(YELLOW + "\nTesting: Status API" + END)
status = w.get_shard_data()
wait()
host = status['hostname']
status_g = status['services'][0]['status']
print("> Hostname: %s " % host)
print("> Game status: %s " % status_g)
print(GREEN + "League API is OK.\n" + END)
time.sleep(2)
except LoLException as e:
print(RED + "Error: %s" % e + "\n" + END)
time.sleep(2)
input("Press enter to continue...")
time.sleep(2)
try:
print(YELLOW + "\nTesting: Static Data API" + END)
icons = w.static_get_icons()
languages = w.static_get_languages()
print("> Version: %s " % icons['version'])
print(GREEN + "Static Data API is OK.\n" + END)
time.sleep(2)
except LoLException as e:
print(RED + "Error: %s" % e + "\n" + END)
time.sleep(2)