diff options
| author | Julien Castiaux <juc@odoo.com> | 2019-11-15 10:04:15 +0000 |
|---|---|---|
| committer | Julien Castiaux <juc@odoo.com> | 2019-11-15 10:45:00 +0000 |
| commit | a9ddc5a50ee0964419956034d91921730669b4d3 (patch) | |
| tree | 3cc6b83f952cbfc318142e2b0121606e1e5cbcc6 /addons/snailmail_account | |
| parent | c5570c4e7d18453825125de00f0a00418cb07c48 (diff) | |
[FIX] snailmail_account: use HttpCase to contact pingen
Pingen is a service that print (like really, using a printer) pdfs
document in order to mail them (using the real post and postmen). In
order to ensure we are compatible with their API, we send to their
sandbox environment a bunch of standard documents (like an invoice).
Those PDFs documents are generated our side using wkhtmltopdf but as the
test were not started using a HttpCase, the assets were not correctly
available.
This also reverts commit 3f5a0a1ef46c3ae6c4ed318d05d519c9e85b4e3b.
closes odoo/odoo#40323
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
Diffstat (limited to 'addons/snailmail_account')
| -rw-r--r-- | addons/snailmail_account/tests/test_pingen_send.py | 46 |
1 files changed, 19 insertions, 27 deletions
diff --git a/addons/snailmail_account/tests/test_pingen_send.py b/addons/snailmail_account/tests/test_pingen_send.py index 523dfe3f6cf..324361785fa 100644 --- a/addons/snailmail_account/tests/test_pingen_send.py +++ b/addons/snailmail_account/tests/test_pingen_send.py @@ -4,30 +4,28 @@ import json import base64 import logging -from odoo.addons.account.tests.common import AccountTestCommon +from odoo.addons.account.tests.common import HttpCase from odoo.tests import tagged _logger = logging.getLogger(__name__) - @tagged('post_install', '-at_install', '-standard', 'external') -class TestPingenSend(AccountTestCommon): +class TestPingenSend(HttpCase): - @classmethod - def setUpClass(cls): - super().setUpClass() - cls.pingen_url = "https://stage-api.pingen.com/document/upload/token/30fc3947dbea4792eb12548b41ec8117/" - cls.sample_invoice = cls.create_invoice() - cls.sample_invoice.partner_id.vat = "BE000000000" - cls.letter = cls.env['snailmail.letter'].create({ - 'partner_id': cls.sample_invoice.partner_id.id, + def setUp(self): + super(TestPingenSend, self).setUp() + self.pingen_url = "https://stage-api.pingen.com/document/upload/token/30fc3947dbea4792eb12548b41ec8117/" + self.sample_invoice = self.create_invoice() + self.sample_invoice.partner_id.vat = "BE000000000" + self.letter = self.env['snailmail.letter'].create({ + 'partner_id': self.sample_invoice.partner_id.id, 'model': 'account.move', - 'res_id': cls.sample_invoice.id, - 'user_id': cls.env.user.id, - 'company_id': cls.sample_invoice.company_id.id, - 'report_template': cls.env.ref('account.account_invoices').id + 'res_id': self.sample_invoice.id, + 'user_id': self.env.user.id, + 'company_id': self.sample_invoice.company_id.id, + 'report_template': self.env.ref('account.account_invoices').id }) - cls.data = { + self.data = { 'data': json.dumps({ 'speed': 1, 'color': 1, @@ -36,16 +34,15 @@ class TestPingenSend(AccountTestCommon): }) } - @classmethod - def create_invoice(cls): + def create_invoice(self): """ Create a sample invoice """ - invoice = cls.env['account.move'].with_context(default_type='out_invoice').create({ + invoice = self.env['account.move'].with_context(default_type='out_invoice').create({ 'type': 'out_invoice', - 'partner_id': cls.env.ref("base.res_partner_2").id, - 'currency_id': cls.env.ref('base.EUR').id, + 'partner_id': self.env.ref("base.res_partner_2").id, + 'currency_id': self.env.ref('base.EUR').id, 'invoice_date': '2018-12-11', 'invoice_line_ids': [(0, 0, { - 'product_id': cls.env.ref("product.product_product_4").id, + 'product_id': self.env.ref("product.product_product_4").id, 'quantity': 1, 'price_unit': 42, })], @@ -58,7 +55,6 @@ class TestPingenSend(AccountTestCommon): def render_and_send(self, report_name): self.sample_invoice.company_id.external_report_layout_id = self.env.ref('web.' + report_name) self.letter.attachment_id = False - attachment_id = self.letter.with_context(force_report_rendering=True)._fetch_attachment() files = { @@ -79,10 +75,6 @@ class TestPingenSend(AccountTestCommon): _logger.warning(msg % "Server") def test_pingen_send_invoice(self): - # Avoid assets to be unlinked during the test - # and to reload the registry - self.registry.enter_test_mode(self.cr) - self.render_and_send('external_layout_standard') self.render_and_send('external_layout_background') self.render_and_send('external_layout_boxed') |
