mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-12-23 07:23:46 +00:00
Setup tests for Vente model.
This commit is contained in:
parent
c76f32cf26
commit
e0a65e4d04
8 changed files with 95 additions and 33 deletions
41
cotisations/migrations/0041_auto_20191103_2131.py
Normal file
41
cotisations/migrations/0041_auto_20191103_2131.py
Normal file
|
@ -0,0 +1,41 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.11.23 on 2019-11-03 20:31
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('cotisations', '0040_auto_20191002_2335'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='balancepayment',
|
||||
name='payment',
|
||||
field=models.OneToOneField(editable=False, on_delete=django.db.models.deletion.CASCADE, related_name='payment_method_balance', to='cotisations.Paiement'),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='chequepayment',
|
||||
name='payment',
|
||||
field=models.OneToOneField(editable=False, on_delete=django.db.models.deletion.CASCADE, related_name='payment_method_cheque', to='cotisations.Paiement'),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='comnpaypayment',
|
||||
name='payment',
|
||||
field=models.OneToOneField(editable=False, on_delete=django.db.models.deletion.CASCADE, related_name='payment_method_comnpay', to='cotisations.Paiement'),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='freepayment',
|
||||
name='payment',
|
||||
field=models.OneToOneField(editable=False, on_delete=django.db.models.deletion.CASCADE, related_name='payment_method_free', to='cotisations.Paiement'),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='notepayment',
|
||||
name='payment',
|
||||
field=models.OneToOneField(editable=False, on_delete=django.db.models.deletion.CASCADE, related_name='payment_method_note', to='cotisations.Paiement'),
|
||||
),
|
||||
]
|
|
@ -40,7 +40,7 @@ class BalancePayment(PaymentMethodMixin, models.Model):
|
|||
payment = models.OneToOneField(
|
||||
Paiement,
|
||||
on_delete=models.CASCADE,
|
||||
related_name='payment_method',
|
||||
related_name='payment_method_balance',
|
||||
editable=False
|
||||
)
|
||||
minimum_balance = models.DecimalField(
|
||||
|
|
|
@ -38,7 +38,7 @@ class ChequePayment(PaymentMethodMixin, models.Model):
|
|||
payment = models.OneToOneField(
|
||||
Paiement,
|
||||
on_delete=models.CASCADE,
|
||||
related_name='payment_method',
|
||||
related_name='payment_method_cheque',
|
||||
editable=False
|
||||
)
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@ class ComnpayPayment(PaymentMethodMixin, models.Model):
|
|||
payment = models.OneToOneField(
|
||||
Paiement,
|
||||
on_delete=models.CASCADE,
|
||||
related_name='payment_method',
|
||||
related_name='payment_method_comnpay',
|
||||
editable=False
|
||||
)
|
||||
payment_credential = models.CharField(
|
||||
|
|
|
@ -38,7 +38,7 @@ class FreePayment(PaymentMethodMixin, models.Model):
|
|||
payment = models.OneToOneField(
|
||||
Paiement,
|
||||
on_delete=models.CASCADE,
|
||||
related_name='payment_method',
|
||||
related_name='payment_method_free',
|
||||
editable=False
|
||||
)
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@ class NotePayment(PaymentMethodMixin, models.Model):
|
|||
payment = models.OneToOneField(
|
||||
Paiement,
|
||||
on_delete = models.CASCADE,
|
||||
related_name = 'payment_method',
|
||||
related_name = 'payment_method_note',
|
||||
editable = False
|
||||
)
|
||||
server = models.CharField(
|
||||
|
|
49
cotisations/test_models.py
Normal file
49
cotisations/test_models.py
Normal file
|
@ -0,0 +1,49 @@
|
|||
from django.test import TestCase
|
||||
|
||||
import datetime
|
||||
from django.utils import timezone
|
||||
|
||||
from users.models import User
|
||||
from .models import Vente, Facture, Cotisation, Paiement
|
||||
|
||||
class VenteModelTests(TestCase):
|
||||
def setUp(self):
|
||||
self.user = User.objects.create(
|
||||
pseudo="testUser",
|
||||
email="test@example.org"
|
||||
)
|
||||
self.paiement = Paiement.objects.create(
|
||||
moyen="test payment"
|
||||
)
|
||||
self.f = Facture.objects.create(
|
||||
user=self.user,
|
||||
paiement=self.paiement,
|
||||
valid=True
|
||||
)
|
||||
|
||||
def test_one_day_cotisation(self):
|
||||
"""
|
||||
It should be possible to have one day membership.
|
||||
"""
|
||||
date = timezone.now()
|
||||
purchase = Vente.objects.create(
|
||||
facture=self.f,
|
||||
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=1),
|
||||
delta=datetime.timedelta(seconds=1)
|
||||
)
|
||||
|
||||
def tearDown(self):
|
||||
self.f.delete()
|
||||
self.user.delete()
|
||||
self.paiement.delete()
|
||||
|
||||
|
|
@ -1,28 +0,0 @@
|
|||
# Re2o est un logiciel d'administration développé initiallement au rezometz. Il
|
||||
# se veut agnostique au réseau considéré, de manière à être installable en
|
||||
# quelques clics.
|
||||
#
|
||||
# Copyright © 2017 Gabriel Détraz
|
||||
# Copyright © 2017 Lara Kermarec
|
||||
# Copyright © 2017 Augustin Lemesle
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License along
|
||||
# with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
"""cotisations.tests
|
||||
The tests for the Cotisations module.
|
||||
"""
|
||||
|
||||
# from django.test import TestCase
|
||||
|
||||
# Create your tests here.
|
Loading…
Reference in a new issue