fix(tests): fix fasting custom threshold tests using Django ORM cache

The user_with_custom_thresholds fixture used UserProfile.objects.get_or_create()
which returns a separate Python instance from the one cached in
user._state.fields_cache['profile']. When the fixture modified and saved
the get_or_create instance, the cached instance on the user object still
held default values (periodic=16, full=24). compute_fasting() accessed
u.profile which returned the stale cached object.

Fixed by modifying through u.profile directly, which operates on the
same cached instance. Also applied black formatting to fasting.py.
This commit is contained in:
2026-07-19 13:50:54 -04:00
parent 29fc493cc2
commit c21d6f5668
3 changed files with 4 additions and 10 deletions

View File

@ -2,7 +2,6 @@ from datetime import timedelta
import time_machine
from django.utils import timezone
from drinks.models import Drink
from lifeevents.models import LifeEvent
from scrobbles.models import Scrobble