import pendulum from django.test import TestCase from jarvis.people.models import Gymnast from jarvis.followup.models import ( Chrono, ChronoDetails, Injury, LearnedSkill, Plan, Point, WellBeing, GymnastHasRoutine, NumberOfRoutineDone, HeightWeight, Note, Intensity, SeasonInformation, CompetitivePointsStats, ) from jarvis.followup.models import ( CHRONO_TYPE_CHOICE, SCORE_TYPE_CHOICE, ) class TestModels(TestCase): def setUp(self): """Mise en place des variables pour les tests.""" gymnast = Gymnast.objects.create( last_name="Pauchou", first_name="Fred", birthdate="1987-07-03", gender=0 ) Chrono.objects.create( gymnast=gymnast, chrono_type=0, score_type=0, score=15, tof=13 ) Injury.objects.create( gymnast=gymnast, location=0, injury_type=0, body_side=0, mechanism=0 ) def test_chrono_to_string(self): gymnast = Gymnast.objects.get(last_name="Pauchou") chrono = Chrono.objects.get(gymnast=gymnast) today = pendulum.now().to_date_string() print(today) self.assertEqual(str(chrono), f"Fred Pauchou - 13.000 ({today} - 0)") # def test_chrono_timeline_representation(self): # gymnast = Gymnast.objects.get(last_name="Pauchou") # chrono = Chrono.objects.get(gymnast=gymnast) # today = pendulum.now().date() # self.assertEqual( # chrono.timeline_representation, # f"
  • {today.to_date_string()} - New personel best {CHRONO_TYPE_CHOICE[chrono.chrono_type][1]}: 15.000' (13.000')
  • ", # pylint: disable=line-too-long # ) def test_compute_tof(self): res = Chrono.compute_tof(15) self.assertEqual(res, 13) def test_injury_to_string(self): gymnast = Gymnast.objects.get(last_name="Pauchou") injury = Injury.objects.get(gymnast=gymnast) today = pendulum.now().date() self.assertEqual(str(injury), f"Fred Pauchou ({today})")