Clear Injury bug fix

This commit is contained in:
Cal Corum 2025-10-22 19:20:43 -05:00
parent a80b84ae25
commit 08434eb340
3 changed files with 8 additions and 5 deletions

View File

@ -645,7 +645,7 @@ class InjuryGroup(app_commands.Group):
return
# Clear player's il_return field
await player_service.update_player(player.id, {'il_return': None})
await player_service.update_player(player.id, {'il_return': ''})
# Success response
success_embed = EmbedTemplate.success(

View File

@ -187,7 +187,8 @@ class InjuryService(BaseService[Injury]):
True if successfully cleared, False otherwise
"""
try:
updated_injury = await self.patch(injury_id, {'is_active': False})
# Note: API expects is_active as query parameter, not JSON body
updated_injury = await self.patch(injury_id, {'is_active': False}, use_query_params=True)
if updated_injury:
logger.info(f"Cleared injury {injury_id}")

View File

@ -245,12 +245,13 @@ class TestInjuryService:
"""Test clearing an injury."""
with patch('api.client.get_config', return_value=mock_config):
with aioresponses() as m:
# Mock the PATCH request (note: patch sends data in body, not URL)
# Mock the PATCH request - API expects is_active as query parameter
# Note: Python's str(False) converts to "False" (capital F)
cleared_data = sample_injury_data.copy()
cleared_data['is_active'] = False
m.patch(
'https://api.example.com/v3/injuries/1',
'https://api.example.com/v3/injuries/1?is_active=False',
payload=cleared_data
)
@ -263,8 +264,9 @@ class TestInjuryService:
"""Test clearing injury when it fails."""
with patch('api.client.get_config', return_value=mock_config):
with aioresponses() as m:
# Note: Python's str(False) converts to "False" (capital F)
m.patch(
'https://api.example.com/v3/injuries/1',
'https://api.example.com/v3/injuries/1?is_active=False',
status=500
)