11import asyncio
2- from datetime import datetime , timedelta
2+ import datetime
3+ from datetime import timedelta
34
45import pytest
56from httpx import ASGITransport , AsyncClient
@@ -197,9 +198,9 @@ async def test_endpoints_admin(client, database_setup):
197198 response = await client .post ("/election" , json = {
198199 "name" : "testElection4" ,
199200 "type" : "general_election" ,
200- "datetime_start_nominations" : (datetime .now () - timedelta (days = 1 )).isoformat (),
201- "datetime_start_voting" : (datetime .now () + timedelta (days = 7 )).isoformat (),
202- "datetime_end_voting" : (datetime .now () + timedelta (days = 14 )).isoformat (),
201+ "datetime_start_nominations" : (datetime .datetime . now (tz = datetime . UTC ) - timedelta (days = 1 )).isoformat (),
202+ "datetime_start_voting" : (datetime .datetime . now (tz = datetime . UTC ) + timedelta (days = 7 )).isoformat (),
203+ "datetime_end_voting" : (datetime .datetime . now (tz = datetime . UTC ) + timedelta (days = 14 )).isoformat (),
203204 "available_positions" : ["president" , "treasurer" ],
204205 "survey_link" : "https://youtu.be/dQw4w9WgXcQ?si=kZROi2tu-43MXPM5"
205206 })
@@ -208,9 +209,9 @@ async def test_endpoints_admin(client, database_setup):
208209 response = await client .post ("/election" , json = {
209210 "name" : "byElection4" ,
210211 "type" : "by_election" ,
211- "datetime_start_nominations" : (datetime .now () - timedelta (days = 1 )).isoformat (),
212- "datetime_start_voting" : (datetime .now () + timedelta (days = 7 )).isoformat (),
213- "datetime_end_voting" : (datetime .now () + timedelta (days = 14 )).isoformat (),
212+ "datetime_start_nominations" : (datetime .datetime . now (tz = datetime . UTC ) - timedelta (days = 1 )).isoformat (),
213+ "datetime_start_voting" : (datetime .datetime . now (tz = datetime . UTC ) + timedelta (days = 7 )).isoformat (),
214+ "datetime_end_voting" : (datetime .datetime . now (tz = datetime . UTC ) + timedelta (days = 14 )).isoformat (),
214215 "survey_link" : "https://youtu.be/dQw4w9WgXcQ?si=kZROi2tu-43MXPM5"
215216 })
216217 assert response .status_code == 200
@@ -275,9 +276,9 @@ async def test_endpoints_admin(client, database_setup):
275276 # update the above election
276277 response = await client .patch ("/election/testElection4" , json = {
277278 "election_type" : "general_election" ,
278- "datetime_start_nominations" : (datetime .now () - timedelta (days = 1 )).isoformat (),
279- "datetime_start_voting" : (datetime .now () + timedelta (days = 7 )).isoformat (),
280- "datetime_end_voting" : (datetime .now () + timedelta (days = 14 )).isoformat (),
279+ "datetime_start_nominations" : (datetime .datetime . now (tz = datetime . UTC ) - timedelta (days = 1 )).isoformat (),
280+ "datetime_start_voting" : (datetime .datetime . now (tz = datetime . UTC ) + timedelta (days = 7 )).isoformat (),
281+ "datetime_end_voting" : (datetime .datetime . now (tz = datetime . UTC ) + timedelta (days = 14 )).isoformat (),
281282 "available_positions" : ["president" , "vice-president" , "treasurer" ], # update this
282283 "survey_link" : "https://youtu.be/dQw4w9WgXcQ?si=kZROi2tu-43MXPM5"
283284 })
0 commit comments