@@ -127,24 +127,24 @@ async def test_endpoints(client, database_setup):
127127 })
128128 assert response .status_code == 401 # unauthorized access to register candidates
129129
130- response = await client .patch (f"/elections/{ election_name } " , params = {
130+ response = await client .patch (f"/elections/{ election_name } " , json = {
131131 "type" : "general_election" ,
132132 "datetime_start_nominations" : "2025-08-18T09:00:00Z" ,
133133 "datetime_start_voting" : "2025-09-03T09:00:00Z" ,
134134 "datetime_end_voting" : "2025-09-18T23:59:59Z" ,
135- "available_positions" : "president, treasurer" ,
135+ "available_positions" : [ "president" , " treasurer"] ,
136136 "survey_link" : "https://youtu.be/dQw4w9WgXcQ?si=kZROi2tu-43MXPM5"
137137
138138 })
139139 assert response .status_code == 401
140140
141- response = await client .patch (f"/elections/registration/{ election_name } /pkn4 " , params = {
141+ response = await client .patch (f"/elections/registration/{ election_name } /vice-president/ { load_test_db . SYSADMIN_COMPUTING_ID } " , json = {
142142 "position" : "president" ,
143143 "speech" : "I would like to run for president because I'm the best in Valorant at SFU."
144144 })
145145 assert response .status_code == 401
146146
147- response = await client .put ("/elections/nominee/info " , params = {
147+ response = await client .patch ("/elections/nominee/jdo12 " , json = {
148148 "full_name" : "John Doe VI" ,
149149 "linked_in" : "linkedin.com/john-doe-vi" ,
150150 "instagram" : "john_vi" ,
@@ -156,7 +156,7 @@ async def test_endpoints(client, database_setup):
156156 response = await client .delete (f"/elections/{ election_name } " )
157157 assert response .status_code == 401
158158
159- response = await client .delete (f"/elections/registration/{ election_name } /president" )
159+ response = await client .delete (f"/elections/registration/{ election_name } /vice- president/ { load_test_db . SYSADMIN_COMPUTING_ID } " )
160160 assert response .status_code == 401
161161
162162
@@ -190,7 +190,7 @@ async def test_endpoints_admin(client, database_setup):
190190 assert response .status_code == 200
191191
192192 # ensure that authorized users can create an election
193- response = await client .post ("/elections/testElection4" , params = {
193+ response = await client .post ("/elections/testElection4" , json = {
194194 "election_type" : "general_election" ,
195195 "datetime_start_nominations" : (datetime .now () - timedelta (days = 1 )).isoformat (),
196196 "datetime_start_voting" : (datetime .now () + timedelta (days = 7 )).isoformat (),
@@ -200,7 +200,7 @@ async def test_endpoints_admin(client, database_setup):
200200 })
201201 assert response .status_code == 200
202202 # ensure that user can create elections without knowing each position type
203- response = await client .post ("/elections/byElection4" , params = {
203+ response = await client .post ("/elections/byElection4" , json = {
204204 "election_type" : "by_election" ,
205205 "datetime_start_nominations" : (datetime .now () - timedelta (days = 1 )).isoformat (),
206206 "datetime_start_voting" : (datetime .now () + timedelta (days = 7 )).isoformat (),
@@ -210,7 +210,7 @@ async def test_endpoints_admin(client, database_setup):
210210 assert response .status_code == 200
211211
212212 # try creating an invalid election name
213- response = await client .post ("/elections/list" , params = {
213+ response = await client .post ("/elections/list" , json = {
214214 "election_type" : "by_election" ,
215215 "datetime_start_nominations" : (datetime .now () - timedelta (days = 1 )).isoformat (),
216216 "datetime_start_voting" : (datetime .now () + timedelta (days = 7 )).isoformat (),
@@ -223,21 +223,21 @@ async def test_endpoints_admin(client, database_setup):
223223
224224
225225 # try to register for a past election -> should say nomination period expired
226- response = await client .post ("/elections/registration/test election 1" , params = {
226+ response = await client .post ("/elections/registration/test election 1" , json = {
227227 "position" : "president" ,
228228 })
229229 assert response .status_code == 400
230230 assert "nomination period" in response .json ()["detail" ]
231231
232232 # try to register for an invalid position
233- response = await client .post (f"/elections/registration/{ election_name } " , params = {
233+ response = await client .post (f"/elections/registration/{ election_name } " , json = {
234234 "position" : "CEO" ,
235235 })
236236 assert response .status_code == 400
237237 assert "invalid position" in response .json ()["detail" ]
238238
239239 # try to register in an unknown election
240- response = await client .post ("/elections/registration/unknownElection12345" , params = {
240+ response = await client .post ("/elections/registration/unknownElection12345" , json = {
241241 "position" : "president" ,
242242 })
243243 assert response .status_code == 404
@@ -246,7 +246,7 @@ async def test_endpoints_admin(client, database_setup):
246246
247247
248248 # register for an election correctly
249- response = await client .post (f"/elections/registration/{ election_name } " , params = {
249+ response = await client .post (f"/elections/registration/{ election_name } " , json = {
250250 "position" : "president" ,
251251 })
252252 assert response .status_code == 200
@@ -255,14 +255,14 @@ async def test_endpoints_admin(client, database_setup):
255255 assert response .status_code == 200
256256
257257 # duplicate registration
258- response = await client .post (f"/elections/registration/{ election_name } " , params = {
258+ response = await client .post (f"/elections/registration/{ election_name } " , json = {
259259 "position" : "president" ,
260260 })
261261 assert response .status_code == 400
262262 assert "registered" in response .json ()["detail" ]
263263
264264 # update the above election
265- response = await client .patch ("/elections/testElection4" , params = {
265+ response = await client .patch ("/elections/testElection4" , json = {
266266 "election_type" : "general_election" ,
267267 "datetime_start_nominations" : (datetime .now () - timedelta (days = 1 )).isoformat (),
268268 "datetime_start_voting" : (datetime .now () + timedelta (days = 7 )).isoformat (),
@@ -273,14 +273,14 @@ async def test_endpoints_admin(client, database_setup):
273273 assert response .status_code == 200
274274
275275 # update the registration
276- response = await client .patch (f"/elections/registration/{ election_name } /pkn4" , params = {
276+ response = await client .patch (f"/elections/registration/{ election_name } /pkn4" , json = {
277277 "position" : "president" ,
278278 "speech" : "Vote for me as treasurer"
279279 })
280280 assert response .status_code == 200
281281
282282 # try updating a non-registered election
283- response = await client .patch ("/elections/registration/testElection4/pkn4" , params = {
283+ response = await client .patch ("/elections/registration/testElection4/pkn4" , json = {
284284 "position" : "president" ,
285285 "speech" : "Vote for me as president, I am good at valorant."
286286 })
@@ -299,7 +299,7 @@ async def test_endpoints_admin(client, database_setup):
299299 assert response .status_code == 200
300300
301301 # update nominee info
302- response = await client .put ("/elections/nominee/info" , params = {
302+ response = await client .put ("/elections/nominee/info" , json = {
303303 "full_name" : "Puneet N" ,
304304 "linked_in" : "linkedin.com/not-my-linkedin" ,
305305 })
0 commit comments