flock: Rename method find_recipient
to find_recipient_id
.
This commit is contained in:
parent
0a7a06f028
commit
c2a3d4c517
|
@ -13,7 +13,7 @@ You can send messages to any Flock user associated with your account from Zulip.
|
||||||
|
|
||||||
# Matches the recipient name provided by user with list of users in his contacts.
|
# Matches the recipient name provided by user with list of users in his contacts.
|
||||||
# If matches, returns the matched User's ID
|
# If matches, returns the matched User's ID
|
||||||
def find_recipient(res: str, recipient_name: str) -> str:
|
def find_recipient_id(res: str, recipient_name: str) -> str:
|
||||||
for obj in res:
|
for obj in res:
|
||||||
if recipient_name == obj['firstName']:
|
if recipient_name == obj['firstName']:
|
||||||
return obj['id']
|
return obj['id']
|
||||||
|
@ -33,7 +33,7 @@ def get_recipient_id(recipient_name: str, config: Dict[str, str]) -> str:
|
||||||
right now.\nPlease try again later"
|
right now.\nPlease try again later"
|
||||||
|
|
||||||
res = res.json()
|
res = res.json()
|
||||||
recipient_id = find_recipient(res, recipient_name)
|
recipient_id = find_recipient_id(res, recipient_name)
|
||||||
if recipient_id is None:
|
if recipient_id is None:
|
||||||
return "No user found. Make sure you typed it correctly."
|
return "No user found. Make sure you typed it correctly."
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -37,7 +37,7 @@ right now.\nPlease try again later")
|
||||||
self.verify_reply('Ricky: test message', "Uh-Oh, couldn\'t process the request \
|
self.verify_reply('Ricky: test message', "Uh-Oh, couldn\'t process the request \
|
||||||
right now.\nPlease try again later")
|
right now.\nPlease try again later")
|
||||||
|
|
||||||
@patch('zulip_bots.bots.flock.flock.find_recipient')
|
@patch('zulip_bots.bots.flock.flock.find_recipient_id')
|
||||||
def test_no_recipient_found(self, find_recipient: str) -> None:
|
def test_no_recipient_found(self, find_recipient: str) -> None:
|
||||||
bot_response = "No user found. Make sure you typed it correctly."
|
bot_response = "No user found. Make sure you typed it correctly."
|
||||||
find_recipient.return_value = None
|
find_recipient.return_value = None
|
||||||
|
|
Loading…
Reference in a new issue