@@ -322,26 +322,33 @@ def test_compare_fastapi_and_webpy_responses(session):
322322 _login (session_fastapi , BASE_URL_FASTAPI )
323323 _login (session_webpy , BASE_URL_WEBPY )
324324
325- test_year = 2025
325+ # Use different years for each API to avoid database conflicts
326+ test_year_fastapi = 2025
327+ test_year_webpy = 2026
326328 test_goal = 20
327329
328- # Create goal in both
330+ # Create goal in FastAPI
329331 r_fastapi = session_fastapi .post (
330332 f"{ BASE_URL_FASTAPI } /reading-goal.json" ,
331- data = {"goal" : test_goal , "year" : test_year },
333+ data = {"goal" : test_goal , "year" : test_year_fastapi },
332334 )
335+ assert r_fastapi .status_code == 200
336+
337+ # Create goal in web.py
333338 r_webpy = session_webpy .post (
334339 f"{ BASE_URL_WEBPY } /reading-goal.json" ,
335- data = {"goal" : test_goal , "year" : test_year },
340+ data = {"goal" : test_goal , "year" : test_year_webpy },
336341 )
342+ assert r_webpy .status_code == 200
337343
338- # Both should succeed
339- assert r_fastapi .status_code == r_webpy .status_code == 200
344+ # Compare response structure (both should have same format)
340345 assert r_fastapi .json () == r_webpy .json ()
341346
342- # Get all goals
343- r_fastapi = session_fastapi .get (f"{ BASE_URL_FASTAPI } /reading-goal.json" )
344- r_webpy = session_webpy .get (f"{ BASE_URL_WEBPY } /reading-goal.json" )
347+ # Get specific year from each API
348+ r_fastapi = session_fastapi .get (
349+ f"{ BASE_URL_FASTAPI } /reading-goal.json?year={ test_year_fastapi } "
350+ )
351+ r_webpy = session_webpy .get (f"{ BASE_URL_WEBPY } /reading-goal.json?year={ test_year_webpy } " )
345352
346353 assert r_fastapi .status_code == r_webpy .status_code == 200
347354 data_fastapi = r_fastapi .json ()
@@ -352,28 +359,20 @@ def test_compare_fastapi_and_webpy_responses(session):
352359 assert isinstance (data_fastapi ["goal" ], list )
353360 assert isinstance (data_webpy ["goal" ], list )
354361
355- # Get specific year
356- r_fastapi = session_fastapi .get (
357- f"{ BASE_URL_FASTAPI } /reading-goal.json?year={ test_year } "
358- )
359- r_webpy = session_webpy .get (f"{ BASE_URL_WEBPY } /reading-goal.json?year={ test_year } " )
360-
361- assert r_fastapi .status_code == r_webpy .status_code == 200
362- data_fastapi = r_fastapi .json ()
363- data_webpy = r_webpy .json ()
364-
365- assert data_fastapi ["goal" ][0 ]["year" ] == data_webpy ["goal" ][0 ]["year" ]
362+ # Compare response formats (same goal value, different years)
366363 assert data_fastapi ["goal" ][0 ]["goal" ] == data_webpy ["goal" ][0 ]["goal" ]
364+ assert data_fastapi ["goal" ][0 ]["year" ] == test_year_fastapi
365+ assert data_webpy ["goal" ][0 ]["year" ] == test_year_webpy
367366
368367 finally :
369368 # Cleanup
370369 session_fastapi .post (
371370 f"{ BASE_URL_FASTAPI } /reading-goal.json" ,
372- data = {"goal" : 0 , "year" : test_year , "is_update" : "true" },
371+ data = {"goal" : 0 , "year" : test_year_fastapi , "is_update" : "true" },
373372 )
374373 session_webpy .post (
375374 f"{ BASE_URL_WEBPY } /reading-goal.json" ,
376- data = {"goal" : 0 , "year" : test_year , "is_update" : "true" },
375+ data = {"goal" : 0 , "year" : test_year_webpy , "is_update" : "true" },
377376 )
378377 _logout (session_fastapi , BASE_URL_FASTAPI )
379378 _logout (session_webpy , BASE_URL_WEBPY )
0 commit comments