8
0
Fork 0
mirror of https://gitlab2.federez.net/re2o/re2o synced 2024-12-23 07:23:46 +00:00

Fix cotisations/test_views tests

This commit is contained in:
chapeau 2024-02-29 11:07:26 +01:00
parent c95e4b7a4b
commit c12cc07d72
2 changed files with 39 additions and 40 deletions

View file

@ -670,7 +670,7 @@ class APIEndpointsTestCase(APITestCase):
def assert_more(response, url, format): def assert_more(response, url, format):
"""Assert the response is valid json when format is json""" """Assert the response is valid json when format is json"""
if format is "json": if format == "json":
json.loads(response.content.decode()) json.loads(response.content.decode())
self.check_responses_code( self.check_responses_code(

View file

@ -12,13 +12,41 @@ from .models import Article, Cotisation, Facture, Paiement, Vente
class NewFactureTests(TestCase): class NewFactureTests(TestCase):
@classmethod
def setUpTestData(cls):
cls.paiement = Paiement.objects.create(moyen="test payment")
cls.article_one_day = Article.objects.create(
name="One day",
prix=0,
duration_connection=0,
duration_days_connection=1,
duration_membership=0,
duration_days_membership=1,
available_for_everyone=True,
)
cls.article_one_month = Article.objects.create(
name="One mounth",
prix=0,
duration_connection=1,
duration_days_connection=0,
duration_membership=1,
duration_days_membership=0,
available_for_everyone=True,
)
cls.article_one_month_and_one_week = Article.objects.create(
name="One mounth and one week",
prix=0,
duration_connection=1,
duration_days_connection=7,
duration_membership=1,
duration_days_membership=7,
available_for_everyone=True,
)
def tearDown(self): def tearDown(self):
self.user.facture_set.all().delete() self.user.facture_set.all().delete()
self.user.delete() self.user.delete()
self.paiement.delete()
self.article_one_day.delete()
self.article_one_month.delete()
self.article_one_month_and_one_week.delete()
def setUp(self): def setUp(self):
self.user = Adherent.objects.create(pseudo="testUser", email="test@example.org") self.user = Adherent.objects.create(pseudo="testUser", email="test@example.org")
@ -34,35 +62,6 @@ class NewFactureTests(TestCase):
] ]
) )
self.user.save() self.user.save()
self.paiement = Paiement.objects.create(moyen="test payment")
self.article_one_day = Article.objects.create(
name="One day",
prix=0,
duration_connection=0,
duration_days_connection=1,
duration_membership=0,
duration_days_membership=1,
available_for_everyone=True,
)
self.article_one_month = Article.objects.create(
name="One mounth",
prix=0,
duration_connection=1,
duration_days_connection=0,
duration_membership=1,
duration_days_membership=0,
available_for_everyone=True,
)
self.article_one_month_and_one_week = Article.objects.create(
name="One mounth and one week",
prix=0,
duration_connection=1,
duration_days_connection=7,
duration_membership=1,
duration_days_membership=7,
available_for_everyone=True,
)
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(