From 08434eb3407d95102068224b2743f636c6f6bc50 Mon Sep 17 00:00:00 2001 From: Cal Corum Date: Wed, 22 Oct 2025 19:20:43 -0500 Subject: [PATCH] Clear Injury bug fix --- commands/injuries/management.py | 2 +- services/injury_service.py | 3 ++- tests/test_services_injury.py | 8 +++++--- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/commands/injuries/management.py b/commands/injuries/management.py index 3459e95..90ac45a 100644 --- a/commands/injuries/management.py +++ b/commands/injuries/management.py @@ -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( diff --git a/services/injury_service.py b/services/injury_service.py index 9f85d3d..bb07bfe 100644 --- a/services/injury_service.py +++ b/services/injury_service.py @@ -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}") diff --git a/tests/test_services_injury.py b/tests/test_services_injury.py index a40de60..f9f4402 100644 --- a/tests/test_services_injury.py +++ b/tests/test_services_injury.py @@ -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 )