mirror of
https://github.com/bringout/oca-ocb-test.git
synced 2026-04-21 17:02:00 +02:00
Initial commit: Test packages
This commit is contained in:
commit
080accd21c
338 changed files with 32413 additions and 0 deletions
|
|
@ -0,0 +1,59 @@
|
|||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from odoo.tests import HttpCase, tagged
|
||||
from odoo.tests.common import HOST
|
||||
from odoo.tools import config, mute_logger
|
||||
|
||||
|
||||
@tagged('-at_install', 'post_install')
|
||||
class WithContext(HttpCase):
|
||||
def test_01_homepage_url(self):
|
||||
# Setup
|
||||
website = self.env['website'].browse([1])
|
||||
website.write({
|
||||
'name': 'Test Website',
|
||||
'domain': f'http://{HOST}:{config["http_port"]}',
|
||||
'homepage_url': '/unexisting',
|
||||
})
|
||||
home_url = '/'
|
||||
contactus_url = '/contactus'
|
||||
contactus_url_full = website.domain + contactus_url
|
||||
contactus_content = b'content="Contact Us | Test Website"'
|
||||
self.env['website.menu'].search([
|
||||
('website_id', '=', website.id),
|
||||
('url', '=', contactus_url),
|
||||
]).sequence = 1
|
||||
|
||||
# 404 shouldn't be served but fallback on first menu
|
||||
# -------------------------------------------
|
||||
# / page exists | first menu | homepage_url
|
||||
# -------------------------------------------
|
||||
# yes | /contactus | /unexisting
|
||||
# -------------------------------------------
|
||||
r = self.url_open(website.homepage_url)
|
||||
self.assertEqual(r.status_code, 404, "The website homepage_url should be a 404")
|
||||
r = self.url_open(home_url)
|
||||
self.assertEqual(r.status_code, 200)
|
||||
self.assertEqual(r.history[0].status_code, 303)
|
||||
self.assertURLEqual(r.url, contactus_url_full)
|
||||
self.assertIn(contactus_content, r.content)
|
||||
|
||||
# same with 403
|
||||
# -------------------------------------------
|
||||
# / page exists | first menu | homepage_url
|
||||
# -------------------------------------------
|
||||
# yes | /contactus | /test_website/200/name-1
|
||||
# -------------------------------------------
|
||||
rec_unpublished = self.env['test.model'].create({
|
||||
'name': 'name',
|
||||
'is_published': False,
|
||||
})
|
||||
website.homepage_url = f"/test_website/200/name-{rec_unpublished.id}"
|
||||
with mute_logger('odoo.http'): # mute 403 warning
|
||||
r = self.url_open(website.homepage_url)
|
||||
self.assertEqual(r.status_code, 404, "The website homepage_url should be a 404")
|
||||
r = self.url_open(home_url)
|
||||
self.assertEqual(r.status_code, 200)
|
||||
self.assertEqual(r.history[0].status_code, 303)
|
||||
self.assertURLEqual(r.url, contactus_url_full)
|
||||
self.assertIn(contactus_content, r.content)
|
||||
Loading…
Add table
Add a link
Reference in a new issue