Skip to content

Commit

Permalink
Check that invitee details is not empty (#1853)
Browse files Browse the repository at this point in the history
* Check that invitee details is not empty

* Add test for empty invitee details

* Fix remind recruitment test

---------

Co-authored-by: Melisa Bok <[email protected]>
  • Loading branch information
enrubio and melisabok authored Oct 16, 2023
1 parent cb2c3c6 commit 62edc8a
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 9 deletions.
17 changes: 9 additions & 8 deletions openreview/venue_request/process/recruitmentProcess.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
39 changes: 38 additions & 1 deletion tests/test_venue_request_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = ''',\n[email protected], 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='[email protected]')
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
Expand Down Expand Up @@ -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='[email protected]')[-1]
assert 'Remind Recruitment Status' not in last_message['content']['text']
Expand Down

0 comments on commit 62edc8a

Please sign in to comment.