Skip to content

Commit 134f339

Browse files
committed
test: add unit test for UserStatisticsService.get_or_create_statistics handling deleted user
Addresses review comment on PR #2233
1 parent 3d43afa commit 134f339

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

wger/trophies/tests/test_services.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,14 @@ def test_handle_workout_deletion(self):
106106
self.assertEqual(stats.total_weight_lifted, Decimal('0'))
107107

108108

109+
def test_get_or_create_statistics_deleted_user(self):
110+
"""
111+
Test get_or_create raises DoesNotExist for deleted user
112+
"""
113+
with patch.object(User.objects, 'filter') as mock_filter:
114+
mock_filter.return_value.exists.return_value = False
115+
with self.assertRaises(User.DoesNotExist):
116+
UserStatisticsService.get_or_create_statistics(self.user)
109117
class TrophyServiceTestCase(WgerTestCase):
110118
"""
111119
Test the TrophyService

0 commit comments

Comments
 (0)