Jarvis/jarvis/people/tests_models.py

82 lines
2.4 KiB
Python

from datetime import datetime
import pendulum
from django.test import TestCase
from jarvis.people.models import Gymnast
class GymnastTestCase(TestCase):
def setUp(self):
Gymnast.objects.create(
last_name="Pauchou", first_name="Fred", birthdate="1987-07-03", gender=0
)
def test_gymnast_tostring(self):
gymnast = Gymnast.objects.get(last_name="Pauchou")
self.assertEqual(str(gymnast), "Fred Pauchou")
def test_gymnaste_get_age(self):
"""Je pars du principe qu'il n'y a pas d'erreur dans la fonction `age` de la librairie
Pendulum
"""
gymnast = Gymnast.objects.get(last_name="Pauchou")
age = pendulum.datetime(
gymnast.birthdate.year, gymnast.birthdate.month, gymnast.birthdate.day
).age
self.assertEqual(gymnast.age, age)
def test_gymnaste_get_next_age(self):
"""Je pars du principe qu'il n'y a pas d'erreur dans la fonction `age` de la librairie
Pendulum
"""
gymnast = Gymnast.objects.get(last_name="Pauchou")
age = (
pendulum.datetime(
gymnast.birthdate.year, gymnast.birthdate.month, gymnast.birthdate.day
).age
+ 1
)
self.assertEqual(gymnast.next_age, age)
def test_gymnaste_next_birthday(self):
gymnast = Gymnast.objects.get(last_name="Pauchou")
now = pendulum.now()
year = now.year
if now.month > 7 or (now.month == 7 and now.day > 3):
year += 1
self.assertEqual(gymnast.next_birthday.strftime("%d/%m/%Y"), f"03/07/{year}")
def test_next_birthday_in_days(self):
gymnast = Gymnast.objects.get(last_name="Pauchou")
now = pendulum.now()
if now.month > 7 or (now.month == 7 and now.day > 3):
birthdate = now.add(years=1)
else:
birthdate = pendulum.date(
now.year, gymnast.birthdate.month, gymnast.birthdate.day
)
number_of_days = birthdate - now
self.assertEqual(gymnast.next_birthday_in_days, number_of_days.in_days())
def skill_max_for_type(self):
pass
def test_nb_known_skill_by_type(self):
pass
def test_unknown_skill_gt_level(self):
pass
def test_unknown_skill_lte_rank(self):
pass
def test_unknown_skill_gt_rank(self):
pass
def get_informations_from_type(self):
pass