Skip to content
Snippets Groups Projects
Commit 7bb8033f authored by Bryan BRANCOTTE's avatar Bryan BRANCOTTE
Browse files

stop as soon as error is seen

parent 4b7a6f4d
No related branches found
No related tags found
1 merge request!259stop as soon as error is seen
Pipeline #154098 failed
......@@ -378,6 +378,8 @@ class CandidateForm(ModelFormWithReadOnly):
def clean(self):
cleaned_data = super().clean()
if self.errors:
return cleaned_data
if len(cleaned_data.get("profiles", [])) > live_settings.max_num_profile__int > 0:
raise ValidationError(
{
......
......@@ -1191,6 +1191,46 @@ class TestCandidateApply(TooledTestCase):
"all question must have an answer, even empty",
)
def test_apply_with_wrong_email(self):
live_settings.show_email_as_message = False
live_settings.max_num_referee = 0
live_settings.cv_enabled = False
load_demo.create_candidate_questions(load_demo.create_faker_instance(0))
steps = list()
#######################################################################
# Apply
#######################################################################
candidate_wizard = "candidate_wizard"
url = reverse('strass:candidate-apply')
# self.client.force_login(self.user)
response_home = self.client.get(url, follow=True)
target = response_home.redirect_chain[0][0]
step_name = target.split("/")[-2]
form_data = {f"{candidate_wizard}-current_step": target.split("/")[-2]}
response = self.client.post(target, form_data, follow=True)
self.assertEqual(response.status_code, 200)
steps.append(WizardStep(target=target, response=response, form_data=form_data, step_name=step_name))
del target, response, form_data, step_name
del response_home, url
target = steps[-1].response.redirect_chain[0][0]
step_name = target.split("/")[-2]
cv = open(os.path.join(self.test_data, "cv.pdf"), "rb")
form_data = {
step_name + "-first_name": "Ada",
step_name + "-last_name": "Lovelace",
step_name + "-email": "ada.lovelace@pasteurfr", # dot is missing
step_name + "-profiles": "2",
step_name + "-motivation": "Yes I am !",
step_name + "-cv": SimpleUploadedFile(cv.name, cv.read(), content_type="application/pdf"),
step_name + "-lang": "en",
f"{candidate_wizard}-current_step": step_name,
}
response = self.client.post(target, form_data, follow=False)
self.assertEqual(response.status_code, 200)
def test_reviewers_notification(self):
fake = Faker()
fake.seed_instance(0)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment