From 62edc8afaebb2b8fa5fe3b059e5e430f1bc34009 Mon Sep 17 00:00:00 2001 From: Emilia Rubio <22416602+enrubio@users.noreply.github.com> Date: Mon, 16 Oct 2023 11:04:31 -0400 Subject: [PATCH] Check that invitee details is not empty (#1853) * Check that invitee details is not empty * Add test for empty invitee details * Fix remind recruitment test --------- Co-authored-by: Melisa Bok --- .../process/recruitmentProcess.py | 17 ++++---- tests/test_venue_request_v2.py | 39 ++++++++++++++++++- 2 files changed, 47 insertions(+), 9 deletions(-) diff --git a/openreview/venue_request/process/recruitmentProcess.py b/openreview/venue_request/process/recruitmentProcess.py index 1430f9349..a8648b059 100644 --- a/openreview/venue_request/process/recruitmentProcess.py +++ b/openreview/venue_request/process/recruitmentProcess.py @@ -35,14 +35,15 @@ def process(client, note, invitation): for invitee in invitee_details: if invitee: details = [i.strip() for i in invitee.split(',') if i] - if len(details) == 1: - email = details[0][1:] if details[0].startswith('(') else details[0] - name = None - else: - email = details[0][1:] if details[0].startswith('(') else details[0] - name = details[1][:-1] if details[1].endswith(')') else details[1] - invitee_emails.append(email) - invitee_names.append(name) + if details: + if len(details) == 1: + email = details[0][1:] if details[0].startswith('(') else details[0] + name = None + else: + email = details[0][1:] if details[0].startswith('(') else details[0] + name = details[1][:-1] if details[1].endswith(')') else details[1] + invitee_emails.append(email) + invitee_names.append(name) # Fetch contact info diff --git a/tests/test_venue_request_v2.py b/tests/test_venue_request_v2.py index 52fa8ae2b..62cc0a636 100644 --- a/tests/test_venue_request_v2.py +++ b/tests/test_venue_request_v2.py @@ -647,6 +647,43 @@ def test_venue_recruitment(self, client, test_client, selenium, request_page, ve assert '0 users' in last_comment.content['invited'] assert 'No recruitment invitation was sent to the users listed under \'Already Invited\' because they have already been invited.' in last_comment.content['comment'] + ## Test invitee details with comma only and empty line + reviewer_details = ''',\nreviewer_candidate3_v2@mail.com, Reviewer Three\n\n''' + recruitment_note = test_client.post_note(openreview.Note( + content={ + 'title': 'Recruitment', + 'invitee_role': 'Reviewers', + 'invitee_reduced_load': ['1', '2', '3'], + 'invitee_details': reviewer_details, + 'invitation_email_subject': '[' + venue['request_form_note'].content['Abbreviated Venue Name'] + '] Invitation to serve as {{invitee_role}}', + 'invitation_email_content': 'Dear {{fullname}},\n\nYou have been nominated by the program chair committee of Test 2030 Venue V2 to serve as {{invitee_role}}.\n\nTo respond to the invitation, please click on the following link:\n\n{{invitation_url}}\n\nCheers!\n\nProgram Chairs' + }, + forum=venue['request_form_note'].forum, + replyto=venue['request_form_note'].forum, + invitation='{}/-/Request{}/Recruitment'.format(venue['support_group_id'], venue['request_form_note'].number), + readers=['{}/Program_Chairs'.format(venue['venue_id']), venue['support_group_id']], + signatures=['~SomeFirstName_User1'], + writers=[] + )) + assert recruitment_note + + helpers.await_queue() + + # No error in posting note + process_logs = client.get_process_logs(id=recruitment_note.id) + assert len(process_logs) == 1 + assert process_logs[0]['status'] == 'ok' + assert process_logs[0]['invitation'] == '{}/-/Request{}/Recruitment'.format(venue['support_group_id'], venue['request_form_note'].number) + + # Emails get sent correctly + messages = client.get_messages(to='reviewer_candidate3_v2@mail.com') + assert messages and len(messages) == 1 + assert messages[0]['content']['subject'] == "[TestVenue@OR'2030V2] Invitation to serve as Reviewer" + assert messages[0]['content']['text'].startswith('Dear Reviewer Three,\n\nYou have been nominated by the program chair committee of Test 2030 Venue V2 to serve as Reviewer.') + + last_comment = client.get_notes(invitation=recruitment_status_invitation, sort='tmdate')[0] + assert '1 users' in last_comment.content['invited'] + def test_venue_recruitment_tilde_IDs(self, client, test_client, selenium, request_page, venue, helpers): # Test Reviewer Recruitment @@ -810,7 +847,7 @@ def test_venue_remind_recruitment(self, client, test_client, selenium, request_p remind_recruitment_status_invitation = '{}/-/Request{}/Remind_Recruitment_Status'.format(venue['support_group_id'], venue['request_form_note'].number) last_comment = client.get_notes(invitation=remind_recruitment_status_invitation, sort='tmdate')[0] - assert '3 users' in last_comment.content['reminded'] + assert '4 users' in last_comment.content['reminded'] last_message = client.get_messages(to='support@openreview.net')[-1] assert 'Remind Recruitment Status' not in last_message['content']['text']