Skip to content

armgit / wger

Public Imported from GitHub
0

Self hosted FLOSS fitness/workout, nutrition and weight tracker

tests: FIX UNIQUE constraint failed by using update_or_create for UserStatistics

infektydd124deded148
diff --git a/wger/core/tests/test_delete_user.py b/wger/core/tests/test_delete_user.py
index 6ce12fa5c..86fa78e79 100644
--- a/wger/core/tests/test_delete_user.py
+++ b/wger/core/tests/test_delete_user.py
@@ -227,11 +227,11 @@ class UserDeleteTrophyIntegrationTestCase(WgerTestCase):
checker_params={"count": 1},
is_active=True
)
- stats = UserStatistics.objects.create(
+ UserStatistics.objects.update_or_create(
user=user,
- total_workouts=1
+ defaults={"total_workouts": 1}
)
- logger.info("Created Trophy and UserStatistics")
+ logger.info("Created Trophy and updated UserStatistics")
UserStatisticsService.update_statistics(user)
TrophyService.evaluate_all_trophies(user)
logger.info("Trophy services invoked")