mirror of
https://github.com/OCA/contract.git
synced 2025-02-13 17:57:24 +02:00
[10.0][ADD] Add website_portal_contract (#62)
* [ADD] Add website_portal_contract * [ADD] website_portal_contract: Add url test, usage video. * [FIX] website_portal_contract: Fix controller test. * [FIX] website_portal_contract: Change all tests to HttpCase.
This commit is contained in:
8
website_portal_contract/tests/__init__.py
Normal file
8
website_portal_contract/tests/__init__.py
Normal file
@@ -0,0 +1,8 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright 2017 LasLabs Inc.
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
|
||||
from . import test_account_analytic_account
|
||||
from . import test_account_analytic_contract_template
|
||||
from . import test_account_analytic_contract
|
||||
from . import test_controller
|
||||
@@ -0,0 +1,32 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright 2017 LasLabs Inc.
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
|
||||
from odoo.tests.common import HttpCase
|
||||
|
||||
|
||||
class TestAccountAnalyticAccount(HttpCase):
|
||||
|
||||
def setUp(self):
|
||||
super(TestAccountAnalyticAccount, self).setUp()
|
||||
self.account = self.env.ref(
|
||||
'website_portal_contract.account_analytic_account_1'
|
||||
)
|
||||
self.contract = self.env.ref(
|
||||
'website_portal_contract.account_analytic_contract_1'
|
||||
)
|
||||
|
||||
def test_website_template_id(self):
|
||||
""" Test website_template_id inherited from contract """
|
||||
self.assertEquals(
|
||||
self.account.website_template_id,
|
||||
self.contract.website_template_id,
|
||||
)
|
||||
|
||||
def test_search_contracts(self):
|
||||
""" Test returns correct contracts """
|
||||
self.account.partner_id = self.env.ref('base.partner_root')
|
||||
self.assertIn(
|
||||
self.account,
|
||||
self.env['account.analytic.account']._search_contracts(),
|
||||
)
|
||||
@@ -0,0 +1,22 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright 2017 LasLabs Inc.
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
|
||||
from odoo.tests.common import HttpCase
|
||||
|
||||
|
||||
class TestAccountAnalyticContract(HttpCase):
|
||||
|
||||
def setUp(self):
|
||||
super(TestAccountAnalyticContract, self).setUp()
|
||||
self.contract_mod = self.env['account.analytic.contract']
|
||||
self.template = self.env.ref(
|
||||
'website_portal_contract.website_contract_template_default'
|
||||
)
|
||||
|
||||
def test_get_default_template(self):
|
||||
""" Test get_default_template returns correct template """
|
||||
self.assertEquals(
|
||||
self.contract_mod._get_default_template(),
|
||||
self.template,
|
||||
)
|
||||
@@ -0,0 +1,21 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright 2017 LasLabs Inc.
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
|
||||
from odoo.tests.common import HttpCase
|
||||
|
||||
|
||||
class TestAccountAnalyticContractTemplate(HttpCase):
|
||||
|
||||
def setUp(self):
|
||||
super(TestAccountAnalyticContractTemplate, self).setUp()
|
||||
self.template = self.env.ref(
|
||||
'website_portal_contract.website_contract_template_default'
|
||||
)
|
||||
|
||||
def test_open_template(self):
|
||||
""" Test open_template returns correct url """
|
||||
self.assertEquals(
|
||||
self.template.open_template()['url'],
|
||||
'/contract/template/%d' % self.template.id,
|
||||
)
|
||||
37
website_portal_contract/tests/test_controller.py
Normal file
37
website_portal_contract/tests/test_controller.py
Normal file
@@ -0,0 +1,37 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright 2017 LasLabs Inc.
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
|
||||
from odoo.tests.common import HttpCase
|
||||
from odoo.addons.website.models.website import slug
|
||||
|
||||
|
||||
class TestController(HttpCase):
|
||||
|
||||
post_install = True
|
||||
at_install = False
|
||||
|
||||
def test_template_view(self):
|
||||
""" It should respond with 200 status """
|
||||
contract = self.env.ref(
|
||||
'website_portal_contract.'
|
||||
'website_contract_template_default'
|
||||
)
|
||||
self.authenticate('admin', 'admin')
|
||||
response = self.url_open(
|
||||
'/contract/template/%s' % slug(contract)
|
||||
)
|
||||
self.assertEquals(
|
||||
response.getcode(),
|
||||
200,
|
||||
)
|
||||
|
||||
def test_portal_contract_view_tour(self):
|
||||
""" Tests contract view is correct """
|
||||
tour = "odoo.__DEBUG__.services['web_tour.tour']"
|
||||
self.phantom_js(
|
||||
url_path='/my/home',
|
||||
code="%s.run('test_contract_view')" % tour,
|
||||
ready="%s.tours.test_contract_view.ready" % tour,
|
||||
login='portal',
|
||||
)
|
||||
Reference in New Issue
Block a user