8
0
Fork 0
mirror of https://gitlab2.federez.net/re2o/re2o synced 2024-11-25 12:53:11 +00:00
re2o/users/test_models.py
Hugo Levy-Falk c4a104b3b6 I like my black.
Just ran black on the whoe repository. Fix #210.
2019-11-04 22:47:24 +01:00

44 lines
1.3 KiB
Python

from django.test import TestCase
import datetime
from django.utils import timezone
from users.models import User
from cotisations.models import Vente, Facture, Paiement
class UserModelTests(TestCase):
def setUp(self):
self.user = User.objects.create(pseudo="testUser")
def tearDown(self):
self.user.facture_set.all().delete()
self.user.delete()
def test_multiple_cotisations_are_taken_into_account(self):
paiement = Paiement.objects.create(moyen="test payment")
invoice = Facture.objects.create(user=self.user, paiement=paiement, valid=True)
date = timezone.now()
purchase1 = Vente.objects.create(
facture=invoice,
number=1,
name="Test purchase",
duration=0,
duration_days=1,
type_cotisation="All",
prix=0,
)
purchase2 = Vente.objects.create(
facture=invoice,
number=1,
name="Test purchase",
duration=0,
duration_days=1,
type_cotisation="All",
prix=0,
)
self.assertAlmostEqual(
self.user.end_connexion() - date,
datetime.timedelta(days=2),
delta=datetime.timedelta(seconds=1),
)