forked from DGNum/gestioCOF
Fix tests: mock captcha clean method
This commit is contained in:
parent
47dd078b6a
commit
ac8ad15ad1
1 changed files with 7 additions and 13 deletions
|
@ -1,5 +1,5 @@
|
||||||
import json
|
import json
|
||||||
import os
|
from unittest import mock
|
||||||
|
|
||||||
from django.contrib.auth import get_user_model
|
from django.contrib.auth import get_user_model
|
||||||
from django.test import TestCase
|
from django.test import TestCase
|
||||||
|
@ -257,18 +257,15 @@ class PetitCoursDemandeViewTestCase(ViewTestCaseMixin, TestCase):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super().setUp()
|
super().setUp()
|
||||||
os.environ["RECAPTCHA_TESTING"] = "True"
|
|
||||||
self.subject1 = create_petitcours_subject()
|
self.subject1 = create_petitcours_subject()
|
||||||
self.subject2 = create_petitcours_subject()
|
self.subject2 = create_petitcours_subject()
|
||||||
|
|
||||||
def tearDown(self):
|
|
||||||
os.environ["RECAPTCHA_TESTING"] = "False"
|
|
||||||
|
|
||||||
def test_get(self):
|
def test_get(self):
|
||||||
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_post(self):
|
@mock.patch("hcaptcha.fields.hCaptchaField.clean")
|
||||||
|
def test_post(self, mock_clean):
|
||||||
data = {
|
data = {
|
||||||
"name": "Le nom",
|
"name": "Le nom",
|
||||||
"email": "lemail@mail.net",
|
"email": "lemail@mail.net",
|
||||||
|
@ -280,7 +277,7 @@ class PetitCoursDemandeViewTestCase(ViewTestCaseMixin, TestCase):
|
||||||
"agrege_requis": "1",
|
"agrege_requis": "1",
|
||||||
"niveau": "lycee",
|
"niveau": "lycee",
|
||||||
"remarques": "no comment",
|
"remarques": "no comment",
|
||||||
"g-recaptcha-response": "PASSED",
|
"h-captcha-response": 1,
|
||||||
}
|
}
|
||||||
resp = self.client.post(self.url, data)
|
resp = self.client.post(self.url, data)
|
||||||
|
|
||||||
|
@ -299,18 +296,15 @@ class PetitCoursDemandeRawViewTestCase(ViewTestCaseMixin, TestCase):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super().setUp()
|
super().setUp()
|
||||||
os.environ["RECAPTCHA_TESTING"] = "True"
|
|
||||||
self.subject1 = create_petitcours_subject()
|
self.subject1 = create_petitcours_subject()
|
||||||
self.subject2 = create_petitcours_subject()
|
self.subject2 = create_petitcours_subject()
|
||||||
|
|
||||||
def tearDown(self):
|
|
||||||
os.environ["RECAPTCHA_TESTING"] = "False"
|
|
||||||
|
|
||||||
def test_get(self):
|
def test_get(self):
|
||||||
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_post(self):
|
@mock.patch("hcaptcha.fields.hCaptchaField.clean")
|
||||||
|
def test_post(self, mock_clean):
|
||||||
data = {
|
data = {
|
||||||
"name": "Le nom",
|
"name": "Le nom",
|
||||||
"email": "lemail@mail.net",
|
"email": "lemail@mail.net",
|
||||||
|
@ -322,7 +316,7 @@ class PetitCoursDemandeRawViewTestCase(ViewTestCaseMixin, TestCase):
|
||||||
"agrege_requis": "1",
|
"agrege_requis": "1",
|
||||||
"niveau": "lycee",
|
"niveau": "lycee",
|
||||||
"remarques": "no comment",
|
"remarques": "no comment",
|
||||||
"g-recaptcha-response": "PASSED",
|
"h-captcha-response": 1,
|
||||||
}
|
}
|
||||||
resp = self.client.post(self.url, data)
|
resp = self.client.post(self.url, data)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue