added advanced workout
This commit is contained in:
@@ -5,11 +5,13 @@ from sqlalchemy import create_engine
|
||||
from sqlalchemy.orm import Session, sessionmaker
|
||||
|
||||
from app.db.models import Base, FitnessProfile, FoodLog, User, WorkoutLog
|
||||
from app.fitness.gamification import _plan_hit, build_gamification
|
||||
from app.daily.metrics import plan_hit
|
||||
from app.fitness.gamification import build_gamification, clear_gamification_cache
|
||||
|
||||
|
||||
class GamificationTests(unittest.TestCase):
|
||||
def setUp(self) -> None:
|
||||
clear_gamification_cache()
|
||||
self.engine = create_engine("sqlite:///:memory:")
|
||||
Base.metadata.create_all(self.engine)
|
||||
self.Session = sessionmaker(bind=self.engine)
|
||||
@@ -29,14 +31,22 @@ class GamificationTests(unittest.TestCase):
|
||||
db.commit()
|
||||
|
||||
def test_plan_hit_lose_goal(self) -> None:
|
||||
summary = {
|
||||
"meals": [{"id": 1}],
|
||||
"totals": {"calories": 1900},
|
||||
"targets": {"calories": 2000},
|
||||
}
|
||||
self.assertTrue(_plan_hit(summary, "lose"))
|
||||
summary["totals"]["calories"] = 2200
|
||||
self.assertFalse(_plan_hit(summary, "lose"))
|
||||
self.assertTrue(
|
||||
plan_hit(
|
||||
{"calories": 1900},
|
||||
{"calories": 2000},
|
||||
"lose",
|
||||
has_meals=True,
|
||||
)
|
||||
)
|
||||
self.assertFalse(
|
||||
plan_hit(
|
||||
{"calories": 2200},
|
||||
{"calories": 2000},
|
||||
"lose",
|
||||
has_meals=True,
|
||||
)
|
||||
)
|
||||
|
||||
def test_meal_streak_and_medals(self) -> None:
|
||||
d1 = date(2026, 6, 16)
|
||||
|
||||
Reference in New Issue
Block a user