From 9d5131a696c6e168fe4a802442c868b5dd6eb4ce Mon Sep 17 00:00:00 2001 From: Romain Derie Date: Wed, 26 Jun 2019 14:00:07 +0000 Subject: [PATCH] [FIX] website_sale: add tests Parent commit moved needed functions into misc so this test could use those. This test is for parent's parent commit which fix checkout billing address edition. Part of #34396 --- .../website_sale/tests/test_sale_process.py | 30 ++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/addons/website_sale/tests/test_sale_process.py b/addons/website_sale/tests/test_sale_process.py index ae3f63e436f..6609b4e4d9c 100644 --- a/addons/website_sale/tests/test_sale_process.py +++ b/addons/website_sale/tests/test_sale_process.py @@ -1,7 +1,11 @@ # -*- coding: utf-8 -*- # Part of Odoo. See LICENSE file for full copyright and licensing details. + import odoo.tests +from odoo.addons.website_sale.controllers.main import WebsiteSale +from odoo.addons.website.tools import MockRequest + @odoo.tests.tagged('post_install', '-at_install') class TestUi(odoo.tests.HttpCase): @@ -14,4 +18,28 @@ class TestUi(odoo.tests.HttpCase): def test_03_demo_checkout(self): self.phantom_js("/", "odoo.__DEBUG__.services['web_tour.tour'].run('shop_buy_product')", "odoo.__DEBUG__.services['web_tour.tour'].tours.shop_buy_product.ready", login="demo") - # TO DO - add public test with new address when convert to web.tour format. + +@odoo.tests.tagged('post_install', '-at_install') +class TestWebsiteSaleCheckoutAddress(odoo.tests.TransactionCase): + def test_01_edit_billing_address(self): + website = self.env['website'].browse(1) + p = self.env.user.partner_id + so = self.env['sale.order'].create({ + 'partner_id': p.id, + 'website_id': website.id, + 'order_line': [(0, 0, { + 'product_id': self.env['product.product'].create({'name': 'Product A', 'list_price': 100}).id, + 'name': 'Product A', + })] + }) + country_id = self.env['res.country'].search([], limit=1).id + + WebsiteSaleController = WebsiteSale() + with MockRequest(self.env, website=website, sale_order_id=so.id): + WebsiteSaleController.address(name='website_sale test user', email='email@email.email', street='ooo', city='ooo', country_id=country_id, submitted=1, partner_id=p.id) + self.assertFalse(p.website_id, "Partner should not have a website set on him after editing billing.") + + website.specific_user_account = True + with MockRequest(self.env, website=website, sale_order_id=so.id): + WebsiteSaleController.address(name='website_sale test user', email='email@email.email', street='ooo', city='ooo', country_id=country_id, submitted=1, partner_id=p.id) + self.assertEqual(p.website_id, website, "Partner should have a website set on him after editing billing.")