[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:
Brett Wood
2017-10-09 08:21:24 -07:00
committed by Dave Lasley
parent 890c51c602
commit bc4d08b9b1
26 changed files with 1155 additions and 0 deletions

View 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

View File

@@ -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(),
)

View File

@@ -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,
)

View File

@@ -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,
)

View 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',
)