summaryrefslogtreecommitdiff
path: root/addons/snailmail_account
diff options
context:
space:
mode:
authorJulien Castiaux <juc@odoo.com>2019-09-06 08:35:02 +0000
committerJulien Castiaux <juc@odoo.com>2019-09-10 13:42:10 +0000
commitd930a78f35ce7f19b614c3adf0f99880b87ad12b (patch)
tree252d8a906c0a8cf8253ba3908aa9b433944b380e /addons/snailmail_account
parent1d15892eaf5b2231dc8188ad9306354b62f871f0 (diff)
[FIX] snailmail_account: external pingen test
Commit 4d64e553b8e3 introduced an 'mt-3' in the address layout of the external background layout to fix a problem related to the display of phone numbers. That fix introduced an error with the pingen external post service. It requires the area where the destination address is printed to be blank, due to the mt-3, the background image was visible instead of that blank area. As removing solely the mt-3 doesn't break the first problem and solve the second, it is safe to remove it. Before this commit, no message was logged to help finding out why the test was failing. The `requests.raise_for_status` method raises an error on both 400 and 500 status code. We don't want the test to break in case pingen screw up their side so 500 errors are just logged. 400 errors still raise an exception. closes odoo/odoo#36504 Signed-off-by: Christophe Monniez (moc) <moc@odoo.com>
Diffstat (limited to 'addons/snailmail_account')
-rw-r--r--addons/snailmail_account/tests/test_pingen_send.py29
1 files changed, 18 insertions, 11 deletions
diff --git a/addons/snailmail_account/tests/test_pingen_send.py b/addons/snailmail_account/tests/test_pingen_send.py
index 5f2bf0b55e1..ea4cd973487 100644
--- a/addons/snailmail_account/tests/test_pingen_send.py
+++ b/addons/snailmail_account/tests/test_pingen_send.py
@@ -2,10 +2,13 @@
import requests
import json
import base64
+import logging
from odoo.addons.account.tests.account_test_classes import AccountingTestCase
from odoo.tests import tagged
+_logger = logging.getLogger(__name__)
+
@tagged('post_install', '-at_install', '-standard', 'external')
class TestPingenSend(AccountingTestCase):
@@ -59,16 +62,20 @@ class TestPingenSend(AccountingTestCase):
}
response = requests.post(self.pingen_url, data=self.data, files=files)
-
- try:
- response.raise_for_status()
- except:
- return False
-
- return True
+ if 400 <= response.status_code <= 599:
+ msg = "%(code)s %(side)s Error: %(reason)s for url: %(url)s\n%(body)s" % {
+ 'code': response.status_code,
+ 'side': r"%s",
+ 'reason': response.reason,
+ 'url': self.pingen_url,
+ 'body': response.text}
+ if response.status_code <= 499:
+ raise requests.HTTPError(msg % "Client")
+ else:
+ _logger.warning(msg % "Server")
def test_pingen_send_invoice(self):
- self.assertTrue(self.render_and_send('external_layout_standard'))
- self.assertTrue(self.render_and_send('external_layout_background'))
- self.assertTrue(self.render_and_send('external_layout_boxed'))
- self.assertTrue(self.render_and_send('external_layout_clean'))
+ self.render_and_send('external_layout_standard')
+ self.render_and_send('external_layout_background')
+ self.render_and_send('external_layout_boxed')
+ self.render_and_send('external_layout_clean')