flock: Fix error message for invalid user.
ADD
zulip_bots/zulip_bots/bots/flock/fixtures/test_found_invalid_recipient.json
+{
+ "request": {
+ "api_url": "https://api.flock.co/v1/roster.listContacts",
+ "method": "GET",
+ "params": {
+ "token": "12345"
+ }
+ },
+ "response": [
+ {
+ "id": 1234567890123456789012345678901,
+ "firstName": "david"
+ }
+ ],
+ "response-headers": {
+ "content-type": "application/json; charset=utf-8"
+ }
+}

MODIFY
zulip_bots/zulip_bots/bots/flock/flock.py
zulip_bots/zulip_bots/bots/flock/flock.py
@@ -62,7 +62,7 @@ def get_flock_response(content: str, config: Dict[str, str]) -> str:
return error
if len(str(recipient_id)) > 30:
- return recipient_id
+ return "Found user is invalid."
payload = {
'to': recipient_id,

MODIFY
zulip_bots/zulip_bots/bots/flock/test_flock.py
zulip_bots/zulip_bots/bots/flock/test_flock.py
@@ -43,6 +43,12 @@ right now.\nPlease try again later")
self.mock_http_conversation('test_no_recipient_found'):
self.verify_reply('david: hello', bot_response)
+ def test_found_invalid_recipient(self) -> None:
+ bot_response = "Found user is invalid."
+ with self.mock_config_info(self.normal_config), \
+ self.mock_http_conversation('test_found_invalid_recipient'):
+ self.verify_reply('david: hello', bot_response)
+
@patch('zulip_bots.bots.flock.flock.get_recipient_id')
def test_message_send_success(self, get_recipient_id: str) -> None:
bot_response = "Message sent."

flock: Fix error message for invalid user.