diff --git a/zulip_bots/zulip_bots/bots/flock/fixtures/test_found_invalid_recipient.json b/zulip_bots/zulip_bots/bots/flock/fixtures/test_found_invalid_recipient.json new file mode 100644 index 0000000..85467a0 --- /dev/null +++ b/zulip_bots/zulip_bots/bots/flock/fixtures/test_found_invalid_recipient.json @@ -0,0 +1,18 @@ +{ + "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" + } +} diff --git a/zulip_bots/zulip_bots/bots/flock/flock.py b/zulip_bots/zulip_bots/bots/flock/flock.py index 5249c33..d6eb660 100644 --- a/zulip_bots/zulip_bots/bots/flock/flock.py +++ b/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, diff --git a/zulip_bots/zulip_bots/bots/flock/test_flock.py b/zulip_bots/zulip_bots/bots/flock/test_flock.py index f1cb4b2..251cc23 100644 --- a/zulip_bots/zulip_bots/bots/flock/test_flock.py +++ b/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."