-
Notifications
You must be signed in to change notification settings - Fork 0
/
client.py
212 lines (186 loc) · 6.56 KB
/
client.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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
import requests
import json
# ##############################################################################
# CATEGORIES
categories = [
{'name': 'Junior',
'code': 'JUN',
'initials': 'J',
'gender': 'M',
'reference': ''},
{'name': 'Senior',
'code': 'SEN',
'initials': 'S',
'gender': 'M',
'reference': ''},
]
for cat in categories:
r = requests.post('http://127.0.0.1:8000/categories',
data=json.dumps(cat),
headers={'content-type': 'application/json'})
r = requests.get('http://127.0.0.1:8000/categories',)
print("Code: %s\nText: %s" % (r.status_code, r.text))
# ##############################################################################
# COUNTRIES
countries = [
{'name': 'Brazil',
'code': 'BR',
'initials': 'B',
'reference': 'BRA001'},
{'name': 'United States of America',
'code': 'USA',
'initials': 'EEUU',
'reference': 'USA001'},
]
for country in countries:
r = requests.post('http://127.0.0.1:8000/countries',
data=json.dumps(country),
headers={'content-type': 'application/json'})
r = requests.get('http://127.0.0.1:8000/countries',)
print("Code: %s\nText: %s" % (r.status_code, r.text))
# ##############################################################################
# DISCIPLINES
disciplines = [
{'name': 'Hockey Inline',
'code': 'HI',
'web': 'https://hockey-inline.wrg2019.com/',
'reference': 'HI-001'},
{'name': 'Inline Freestyle',
'code': 'IF',
'web': 'https://inline-freestyle.wrg2019.com/',
'reference': 'IF-001'},
]
for discipline in disciplines:
r = requests.post('http://127.0.0.1:8000/disciplines',
data=json.dumps(discipline),
headers={'content-type': 'application/json'})
r = requests.get('http://127.0.0.1:8000/disciplines',)
print("Code: %s\nText: %s" % (r.status_code, r.text))
# ##############################################################################
# LOCATIONS
locations = [
{'name': 'Palau Sant Jordi',
'address': 'Passeig Olimpic',
'postal_code': '08038',
'city': 'Barcelona',
'country': 'Spain',
'gps': '43.0317522,-7.5922429',
'reference': 'PSJ-001'},
{'name': 'Santa Coloma de Gramanet',
'address': 'Carrer del Peru',
'postal_code': '08052',
'city': 'Barcelona',
'country': 'Spain',
'gps': '41.4534932,2.2051065',
'reference': 'SCG-001'},
]
for location in locations:
r = requests.post('http://127.0.0.1:8000/locations',
data=json.dumps(location),
headers={'content-type': 'application/json'})
r = requests.get('http://127.0.0.1:8000/locations',)
print("Code: %s\nText: %s" % (r.status_code, r.text))
# ##############################################################################
# REFEREES
referees = [
{'name': 'Pier Luiggi',
'surname': 'Colina',
'birthdate': '1972-01-01T12:12:12Z',
'bio': 'Biography of Pier Luiggi Colina',
'photo': 'path/to/uploads/photos/pierluiggi-md5.jpg',
'gender': 'M'},
{'name': 'Manuel Enrique',
'surname': 'Mejuto Gonzalez',
'birthdate': '1974-11-21T14:15:27Z',
'bio': 'Biography of Mejuto Gonzalez',
'photo': 'path/to/uploads/photos/mejutogonzalez-md5.jpg',
'gender': 'M'},
]
for referee in referees:
r = requests.post('http://127.0.0.1:8000/referees',
data=json.dumps(referee),
headers={'content-type': 'application/json'})
r = requests.get('http://127.0.0.1:8000/referees',)
print("Code: %s\nText: %s" % (r.status_code, r.text))
# ##############################################################################
# ROUNDS
rounds = [
{'name': 'Quarters Finals',
'order': 1},
{'name': 'Semifinals',
'order': 2},
{'name': 'Final',
'order': 3},
]
for round in rounds:
r = requests.post('http://127.0.0.1:8000/rounds',
data=json.dumps(round),
headers={'content-type': 'application/json'})
r = requests.get('http://127.0.0.1:8000/rounds',)
print("Code: %s\nText: %s" % (r.status_code, r.text))
# ##############################################################################
# SESSIONS
sessions = [
{'name': 'Short Program Junior Women',
'code': 'SPJW',
'reference': 'SPJW-001',
'date': '2018-07-03',
'time': '18:30:00'},
{'name': 'Short Program Senior Men',
'code': 'SPSM',
'reference': 'SPSM-001',
'date': '2018-07-03',
'time': '19:30:00'},
]
for session in sessions:
r = requests.post('http://127.0.0.1:8000/sessions',
data=json.dumps(session),
headers={'content-type': 'application/json'})
r = requests.get('http://127.0.0.1:8000/sessions',)
print("Code: %s\nText: %s" % (r.status_code, r.text))
# ##############################################################################
# TEAM
teams = [
{'name': 'Brazil Inline Roller',
'bio': 'Biography of Brazil Inline Roller',
'photo': 'path/to/uploads/photos/bra-inline-roller-md5.jpg'},
{'name': 'USA hockey-inline',
'bio': 'Biography of USA hockey-inline',
'photo': 'path/to/uploads/photos/usa-hockey-inline-md5.jpg'},
]
for team in teams:
r = requests.post('http://127.0.0.1:8000/teams',
data=json.dumps(team),
headers={'content-type': 'application/json'})
r = requests.get('http://127.0.0.1:8000/teams',)
print("Code: %s\nText: %s" % (r.status_code, r.text))
# ##############################################################################
# ATHLETES
athletes = [
{'name': 'Mery',
'surname': 'Poppins',
'birthdate': '2001-01-01T12:12:12Z',
'bio': "This is the Merys biography",
'photo': 'path/to/uploads/photos/-merypoppins-md5.jpg',
'weight': 60,
'height': 160,
'gender': 'W',
'country_id': 1,
'reference': 'REF001'},
{'name': 'Felipe Juan Froilan',
'surname': 'De todos los Santos Marichalar y Borbon',
'birthdate': '2001-01-01T12:12:12Z',
'bio': "This is the Felipe Juan Froilan biography",
'photo': 'path/to/uploads/photos/froilan-md5.jpg',
'weight': 75,
'height': 182,
'gender': 'M',
'country_id': 2,
'reference': 'REF002'},
]
for athlete in athletes:
r = requests.post('http://127.0.0.1:8000/athletes',
data=json.dumps(athlete),
headers={'content-type': 'application/json'})
r = requests.get('http://127.0.0.1:8000/athletes',)
print("Code: %s\nText: %s" % (r.status_code, r.text))