|
|
@ -12,31 +12,10 @@ from .models import Article, Cotisation, Facture, Paiement, Vente |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class NewFactureTests(TestCase): |
|
|
class NewFactureTests(TestCase): |
|
|
def tearDown(self): |
|
|
@classmethod |
|
|
self.user.facture_set.all().delete() |
|
|
def setUpTestData(cls): |
|
|
self.user.delete() |
|
|
cls.paiement = Paiement.objects.create(moyen="test payment") |
|
|
self.paiement.delete() |
|
|
cls.article_one_day = Article.objects.create( |
|
|
self.article_one_day.delete() |
|
|
|
|
|
self.article_one_month.delete() |
|
|
|
|
|
self.article_one_month_and_one_week.delete() |
|
|
|
|
|
|
|
|
|
|
|
def setUp(self): |
|
|
|
|
|
self.user = Adherent.objects.create(pseudo="testUser", email="test@example.org") |
|
|
|
|
|
self.user.set_password("plopiplop") |
|
|
|
|
|
self.user.user_permissions.set( |
|
|
|
|
|
[ |
|
|
|
|
|
Permission.objects.get_by_natural_key( |
|
|
|
|
|
"add_facture", "cotisations", "facture" |
|
|
|
|
|
), |
|
|
|
|
|
Permission.objects.get_by_natural_key( |
|
|
|
|
|
"use_every_payment", "cotisations", "paiement" |
|
|
|
|
|
), |
|
|
|
|
|
] |
|
|
|
|
|
) |
|
|
|
|
|
self.user.save() |
|
|
|
|
|
|
|
|
|
|
|
self.paiement = Paiement.objects.create(moyen="test payment") |
|
|
|
|
|
self.article_one_day = Article.objects.create( |
|
|
|
|
|
name="One day", |
|
|
name="One day", |
|
|
prix=0, |
|
|
prix=0, |
|
|
duration_connection=0, |
|
|
duration_connection=0, |
|
|
@ -45,7 +24,7 @@ class NewFactureTests(TestCase): |
|
|
duration_days_membership=1, |
|
|
duration_days_membership=1, |
|
|
available_for_everyone=True, |
|
|
available_for_everyone=True, |
|
|
) |
|
|
) |
|
|
self.article_one_month = Article.objects.create( |
|
|
cls.article_one_month = Article.objects.create( |
|
|
name="One mounth", |
|
|
name="One mounth", |
|
|
prix=0, |
|
|
prix=0, |
|
|
duration_connection=1, |
|
|
duration_connection=1, |
|
|
@ -54,7 +33,7 @@ class NewFactureTests(TestCase): |
|
|
duration_days_membership=0, |
|
|
duration_days_membership=0, |
|
|
available_for_everyone=True, |
|
|
available_for_everyone=True, |
|
|
) |
|
|
) |
|
|
self.article_one_month_and_one_week = Article.objects.create( |
|
|
cls.article_one_month_and_one_week = Article.objects.create( |
|
|
name="One mounth and one week", |
|
|
name="One mounth and one week", |
|
|
prix=0, |
|
|
prix=0, |
|
|
duration_connection=1, |
|
|
duration_connection=1, |
|
|
@ -63,6 +42,26 @@ class NewFactureTests(TestCase): |
|
|
duration_days_membership=7, |
|
|
duration_days_membership=7, |
|
|
available_for_everyone=True, |
|
|
available_for_everyone=True, |
|
|
) |
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def tearDown(self): |
|
|
|
|
|
self.user.facture_set.all().delete() |
|
|
|
|
|
self.user.delete() |
|
|
|
|
|
|
|
|
|
|
|
def setUp(self): |
|
|
|
|
|
self.user = Adherent.objects.create(pseudo="testUser", email="test@example.org") |
|
|
|
|
|
self.user.set_password("plopiplop") |
|
|
|
|
|
self.user.user_permissions.set( |
|
|
|
|
|
[ |
|
|
|
|
|
Permission.objects.get_by_natural_key( |
|
|
|
|
|
"add_facture", "cotisations", "facture" |
|
|
|
|
|
), |
|
|
|
|
|
Permission.objects.get_by_natural_key( |
|
|
|
|
|
"use_every_payment", "cotisations", "paiement" |
|
|
|
|
|
), |
|
|
|
|
|
] |
|
|
|
|
|
) |
|
|
|
|
|
self.user.save() |
|
|
self.client.login(username="testUser", password="plopiplop") |
|
|
self.client.login(username="testUser", password="plopiplop") |
|
|
|
|
|
|
|
|
def test_invoice_with_one_day(self): |
|
|
def test_invoice_with_one_day(self): |
|
|
@ -72,7 +71,7 @@ class NewFactureTests(TestCase): |
|
|
"form-INITIAL_FORMS": 0, |
|
|
"form-INITIAL_FORMS": 0, |
|
|
"form-MIN_NUM_FORMS": 0, |
|
|
"form-MIN_NUM_FORMS": 0, |
|
|
"form-MAX_NUM_FORMS": 1000, |
|
|
"form-MAX_NUM_FORMS": 1000, |
|
|
"form-0-article": 1, |
|
|
"form-0-article": self.article_one_day.pk, |
|
|
"form-0-quantity": 1, |
|
|
"form-0-quantity": 1, |
|
|
} |
|
|
} |
|
|
date = timezone.now() |
|
|
date = timezone.now() |
|
|
@ -94,7 +93,7 @@ class NewFactureTests(TestCase): |
|
|
"form-INITIAL_FORMS": 0, |
|
|
"form-INITIAL_FORMS": 0, |
|
|
"form-MIN_NUM_FORMS": 0, |
|
|
"form-MIN_NUM_FORMS": 0, |
|
|
"form-MAX_NUM_FORMS": 1000, |
|
|
"form-MAX_NUM_FORMS": 1000, |
|
|
"form-0-article": 2, |
|
|
"form-0-article": self.article_one_month.pk, |
|
|
"form-0-quantity": 1, |
|
|
"form-0-quantity": 1, |
|
|
} |
|
|
} |
|
|
date = timezone.now() |
|
|
date = timezone.now() |
|
|
@ -114,9 +113,9 @@ class NewFactureTests(TestCase): |
|
|
"form-INITIAL_FORMS": 0, |
|
|
"form-INITIAL_FORMS": 0, |
|
|
"form-MIN_NUM_FORMS": 0, |
|
|
"form-MIN_NUM_FORMS": 0, |
|
|
"form-MAX_NUM_FORMS": 1000, |
|
|
"form-MAX_NUM_FORMS": 1000, |
|
|
"form-0-article": 1, |
|
|
"form-0-article": self.article_one_day.pk, |
|
|
"form-0-quantity": 7, |
|
|
"form-0-quantity": 7, |
|
|
"form-1-article": 2, |
|
|
"form-1-article": self.article_one_month.pk, |
|
|
"form-1-quantity": 1, |
|
|
"form-1-quantity": 1, |
|
|
} |
|
|
} |
|
|
date = timezone.now() |
|
|
date = timezone.now() |
|
|
@ -137,9 +136,9 @@ class NewFactureTests(TestCase): |
|
|
"form-INITIAL_FORMS": 0, |
|
|
"form-INITIAL_FORMS": 0, |
|
|
"form-MIN_NUM_FORMS": 0, |
|
|
"form-MIN_NUM_FORMS": 0, |
|
|
"form-MAX_NUM_FORMS": 1000, |
|
|
"form-MAX_NUM_FORMS": 1000, |
|
|
"form-0-article": 2, |
|
|
"form-0-article": self.article_one_month.pk, |
|
|
"form-0-quantity": 1, |
|
|
"form-0-quantity": 1, |
|
|
"form-1-article": 2, |
|
|
"form-1-article": self.article_one_month.pk, |
|
|
"form-1-quantity": 1, |
|
|
"form-1-quantity": 1, |
|
|
} |
|
|
} |
|
|
response = self.client.post( |
|
|
response = self.client.post( |
|
|
|