Petits cours : tests

This commit is contained in:
Ludovic Stephan 2020-09-15 11:47:53 +02:00
parent edf6a03bc4
commit b03cf05ef7
2 changed files with 4 additions and 29 deletions

View file

@ -8,7 +8,6 @@ from django.urls import reverse
from gestioncof.tests.mixins import ViewTestCaseMixin from gestioncof.tests.mixins import ViewTestCaseMixin
from .utils import ( from .utils import (
PetitCoursTestHelpers,
create_petitcours_ability, create_petitcours_ability,
create_petitcours_demande, create_petitcours_demande,
create_petitcours_subject, create_petitcours_subject,
@ -160,9 +159,7 @@ class PetitCoursInscriptionViewTestCase(ViewTestCaseMixin, TestCase):
self.assertFalse(self.user.petitcoursability_set.all()) self.assertFalse(self.user.petitcoursability_set.all())
class PetitCoursTraitementViewTestCase( class PetitCoursTraitementViewTestCase(ViewTestCaseMixin, TestCase):
ViewTestCaseMixin, PetitCoursTestHelpers, TestCase
):
url_name = "petits-cours-demande-traitement" url_name = "petits-cours-demande-traitement"
http_methods = ["GET", "POST"] http_methods = ["GET", "POST"]
@ -188,14 +185,10 @@ class PetitCoursTraitementViewTestCase(
self.demande.matieres.add(self.subject) self.demande.matieres.add(self.subject)
def test_get(self): def test_get(self):
self.require_custommails()
resp = self.client.get(self.url) resp = self.client.get(self.url)
self.assertEqual(resp.status_code, 200) self.assertEqual(resp.status_code, 200)
def test_get_with_match(self): def test_get_with_match(self):
self.require_custommails()
create_petitcours_ability( create_petitcours_ability(
user=self.user, matiere=self.subject, niveau="college" user=self.user, matiere=self.subject, niveau="college"
) )
@ -211,8 +204,6 @@ class PetitCoursTraitementViewTestCase(
) )
def test_post_with_match(self): def test_post_with_match(self):
self.require_custommails()
create_petitcours_ability( create_petitcours_ability(
user=self.user, matiere=self.subject, niveau="college" user=self.user, matiere=self.subject, niveau="college"
) )
@ -230,9 +221,7 @@ class PetitCoursTraitementViewTestCase(
self.assertIsNotNone(self.demande.processed) self.assertIsNotNone(self.demande.processed)
class PetitCoursRetraitementViewTestCase( class PetitCoursRetraitementViewTestCase(ViewTestCaseMixin, TestCase):
ViewTestCaseMixin, PetitCoursTestHelpers, TestCase
):
url_name = "petits-cours-demande-retraitement" url_name = "petits-cours-demande-retraitement"
http_methods = ["GET", "POST"] http_methods = ["GET", "POST"]
@ -253,8 +242,6 @@ class PetitCoursRetraitementViewTestCase(
self.demande = create_petitcours_demande() self.demande = create_petitcours_demande()
def test_get(self): def test_get(self):
self.require_custommails()
resp = self.client.get(self.url) resp = self.client.get(self.url)
self.assertEqual(resp.status_code, 200) self.assertEqual(resp.status_code, 200)

View file

@ -1,8 +1,4 @@
import os from gestioncof.tests.utils import create_user
from django.conf import settings
from django.core.management import call_command
from petitscours.models import ( from petitscours.models import (
PetitCoursAbility, PetitCoursAbility,
PetitCoursAttributionCounter, PetitCoursAttributionCounter,
@ -13,7 +9,7 @@ from petitscours.models import (
def create_petitcours_ability(**kwargs): def create_petitcours_ability(**kwargs):
if "user" not in kwargs: if "user" not in kwargs:
kwargs["user"] = create_user() kwargs["user"] = create_user("toto")
if "matiere" not in kwargs: if "matiere" not in kwargs:
kwargs["matiere"] = create_petitcours_subject() kwargs["matiere"] = create_petitcours_subject()
if "niveau" not in kwargs: if "niveau" not in kwargs:
@ -29,11 +25,3 @@ def create_petitcours_demande(**kwargs):
def create_petitcours_subject(**kwargs): def create_petitcours_subject(**kwargs):
return PetitCoursSubject.objects.create(**kwargs) return PetitCoursSubject.objects.create(**kwargs)
class PetitCoursTestHelpers:
def require_custommails(self):
data_file = os.path.join(
settings.BASE_DIR, "gestioncof", "management", "data", "custommail.json"
)
call_command("syncmails", data_file, verbosity=0)