From 68a1426e58475965a052d511c61e4ca2230b0e17 Mon Sep 17 00:00:00 2001 From: Chris Hill-Scott Date: Wed, 26 Jul 2017 10:46:39 +0100 Subject: [PATCH] More Python client weirdness MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit There’s some weird interaction between the message attribute of the exception and mocking. Luckily there is an internal attribute – `_message` which doesn’t go through all the magic. --- app/main/views/send.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/main/views/send.py b/app/main/views/send.py index 557faf0ba..07b837101 100644 --- a/app/main/views/send.py +++ b/app/main/views/send.py @@ -668,11 +668,11 @@ def _check_notification(service_id, template_id, exception=None): def get_template_error_dict(exception): # TODO: Make API return some computer-friendly identifier as well as the end user error messages - if 'service is in trial mode' in exception.message: + if 'service is in trial mode' in exception._message: error = 'not-allowed-to-send-to' - elif 'Exceeded send limits' in exception.message: + elif 'Exceeded send limits' in exception._message: error = 'too-many-messages' - elif 'Content for template has a character count greater than the limit of' in exception.message: + elif 'Content for template has a character count greater than the limit of' in exception._message: error = 'message-too-long' else: raise exception