def test_get_missed_message_token(self) -> None: with self.settings(EMAIL_GATEWAY_PATTERN="*****@*****.**"): address = 'mm' + ('x' * 32) + '@example.com' self.assertTrue(is_missed_message_address(address)) token = get_missed_message_token_from_address(address) self.assertEqual(token, 'x' * 32) # This next section was a bug at one point--we'd treat ordinary # user addresses that happened to begin with "mm" as being # the special mm+32chars tokens. address = '*****@*****.**' self.assertFalse(is_missed_message_address(address)) with self.assertRaises(ZulipEmailForwardError): get_missed_message_token_from_address(address) # Now test the case where we our address does not match the # EMAIL_GATEWAY_PATTERN. # This used to crash in an ugly way; we want to throw a proper # exception. address = '*****@*****.**' self.assertFalse(is_missed_message_address(address)) with self.assertRaises(ZulipEmailForwardError): get_missed_message_token_from_address(address)
def get_token(address: str) -> str: with self.settings(EMAIL_GATEWAY_PATTERN="*****@*****.**"): return get_missed_message_token_from_address(address)
def get_token(address: Text) -> Text: with self.settings(EMAIL_GATEWAY_PATTERN="*****@*****.**"): return get_missed_message_token_from_address(address)
def get_token(address): # type: (Text) -> Text with self.settings(EMAIL_GATEWAY_PATTERN="*****@*****.**"): return get_missed_message_token_from_address(address)