forked from DGNum/gestioCOF
petitcours.tests -- Add tests for demande (raw) views
This commit is contained in:
parent
3d27dc9a41
commit
0fe63d3eae
1 changed files with 84 additions and 0 deletions
|
@ -1505,3 +1505,87 @@ class PetitCoursRetraitementViewTestCase(
|
|||
|
||||
resp = self.client.get(self.url)
|
||||
self.assertEqual(resp.status_code, 200)
|
||||
|
||||
|
||||
class PetitCoursDemandeViewTestCase(ViewTestCaseMixin, TestCase):
|
||||
url_name = "petits-cours-demande"
|
||||
url_expected = "/petitcours/demande"
|
||||
|
||||
http_methods = ["GET", "POST"]
|
||||
|
||||
auth_user = None
|
||||
auth_forbidden = []
|
||||
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
os.environ["RECAPTCHA_TESTING"] = "True"
|
||||
self.subject1 = create_petitcours_subject()
|
||||
self.subject2 = create_petitcours_subject()
|
||||
|
||||
def tearDown(self):
|
||||
os.environ["RECAPTCHA_TESTING"] = "False"
|
||||
|
||||
def test_get(self):
|
||||
resp = self.client.get(self.url)
|
||||
self.assertEqual(resp.status_code, 200)
|
||||
|
||||
def test_post(self):
|
||||
data = {
|
||||
"name": "Le nom",
|
||||
"email": "lemail@mail.net",
|
||||
"phone": "0123456789",
|
||||
"quand": "matin, midi et soir",
|
||||
"freq": "tous les jours",
|
||||
"lieu": "partout",
|
||||
"matieres": [str(self.subject1.pk), str(self.subject2.pk)],
|
||||
"agrege_requis": "1",
|
||||
"niveau": "lycee",
|
||||
"remarques": "no comment",
|
||||
"g-recaptcha-response": "PASSED",
|
||||
}
|
||||
resp = self.client.post(self.url, data)
|
||||
|
||||
self.assertEqual(resp.status_code, 200)
|
||||
self.assertTrue(resp.context["success"], msg=str(resp.context["form"].errors))
|
||||
|
||||
|
||||
class PetitCoursDemandeRawViewTestCase(ViewTestCaseMixin, TestCase):
|
||||
url_name = "petits-cours-demande-raw"
|
||||
url_expected = "/petitcours/demande-raw"
|
||||
|
||||
http_methods = ["GET", "POST"]
|
||||
|
||||
auth_user = None
|
||||
auth_forbidden = []
|
||||
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
os.environ["RECAPTCHA_TESTING"] = "True"
|
||||
self.subject1 = create_petitcours_subject()
|
||||
self.subject2 = create_petitcours_subject()
|
||||
|
||||
def tearDown(self):
|
||||
os.environ["RECAPTCHA_TESTING"] = "False"
|
||||
|
||||
def test_get(self):
|
||||
resp = self.client.get(self.url)
|
||||
self.assertEqual(resp.status_code, 200)
|
||||
|
||||
def test_post(self):
|
||||
data = {
|
||||
"name": "Le nom",
|
||||
"email": "lemail@mail.net",
|
||||
"phone": "0123456789",
|
||||
"quand": "matin, midi et soir",
|
||||
"freq": "tous les jours",
|
||||
"lieu": "partout",
|
||||
"matieres": [str(self.subject1.pk), str(self.subject2.pk)],
|
||||
"agrege_requis": "1",
|
||||
"niveau": "lycee",
|
||||
"remarques": "no comment",
|
||||
"g-recaptcha-response": "PASSED",
|
||||
}
|
||||
resp = self.client.post(self.url, data)
|
||||
|
||||
self.assertEqual(resp.status_code, 200)
|
||||
self.assertTrue(resp.context["success"], msg=str(resp.context["form"].errors))
|
||||
|
|
Loading…
Reference in a new issue