diff options
| author | fja-odoo <fja@odoo.com> | 2019-06-11 12:26:53 +0000 |
|---|---|---|
| committer | fja-odoo <fja@odoo.com> | 2019-06-28 08:53:52 +0000 |
| commit | 90818fd083774988c331d741d34181a5af5ecd3a (patch) | |
| tree | e67fcc581e0952d80a90185a0926b1ec0601bfc0 /addons/test_website/controllers/main.py | |
| parent | 83c1d56d2f3d22672803118f33c2f702721df1e5 (diff) | |
[IMP] test_website: add test tour for the website errors
The purpose of these tests is to verify that errors informations
are displayed correctly on the website.
Part of https://github.com/odoo/odoo/pull/32132
task-1894820
Diffstat (limited to 'addons/test_website/controllers/main.py')
| -rw-r--r-- | addons/test_website/controllers/main.py | 61 |
1 files changed, 58 insertions, 3 deletions
diff --git a/addons/test_website/controllers/main.py b/addons/test_website/controllers/main.py index ae45d160b06..cc60ccfd25f 100644 --- a/addons/test_website/controllers/main.py +++ b/addons/test_website/controllers/main.py @@ -1,16 +1,19 @@ # -*- coding: utf-8 -*- # Part of Odoo. See LICENSE file for full copyright and licensing details. +import json +import werkzeug + from odoo import http from odoo.http import request from odoo.addons.portal.controllers.web import Home -import json +from odoo.exceptions import UserError, ValidationError, AccessError, MissingError, AccessError, AccessDenied class WebsiteTest(Home): - @http.route('/test_view', type='http', auth="public", website=True) - def test_view(self, **kw): + @http.route('/test_view', type='http', auth='public', website=True) + def test_view(self, **kwargs): return request.render('test_website.test_view') @http.route('/ignore_args/converteronly/<string:a>/', type='http', auth="public", website=True) @@ -40,3 +43,55 @@ class WebsiteTest(Home): @http.route('/multi_company_website', type='http', auth="public", website=True) def test_company_context(self): return request.make_response(json.dumps(request.context.get('allowed_company_ids'))) + + @http.route('/test_error_view', type='http', auth='public', website=True) + def test_error_view(self, **kwargs): + return request.render('test_website.test_error_view') + + @http.route('/test_user_error_http', type='http', auth='public', website=True) + def test_user_error_http(self, **kwargs): + raise UserError("This is a user http test") + + @http.route('/test_user_error_json', type='json', auth='public', website=True) + def test_user_error_json(self, **kwargs): + raise UserError("This is a user rpc test") + + @http.route('/test_validation_error_http', type='http', auth='public', website=True) + def test_validation_error_http(self, **kwargs): + raise ValidationError("This is a validation http test") + + @http.route('/test_validation_error_json', type='json', auth='public', website=True) + def test_validation_error_json(self, **kwargs): + raise ValidationError("This is a validation rpc test") + + @http.route('/test_access_error_json', type='json', auth='public', website=True) + def test_access_error_json(self, **kwargs): + raise AccessError("This is an access rpc test") + + @http.route('/test_access_error_http', type='http', auth='public', website=True) + def test_access_error_http(self, **kwargs): + raise AccessError("This is an access http test") + + @http.route('/test_missing_error_json', type='json', auth='public', website=True) + def test_missing_error_json(self, **kwargs): + raise MissingError("This is a missing rpc test") + + @http.route('/test_missing_error_http', type='http', auth='public', website=True) + def test_missing_error_http(self, **kwargs): + raise MissingError("This is a missing http test") + + @http.route('/test_internal_error_json', type='json', auth='public', website=True) + def test_internal_error_json(self, **kwargs): + raise werkzeug.exceptions.InternalServerError() + + @http.route('/test_internal_error_http', type='http', auth='public', website=True) + def test_internal_error_http(self, **kwargs): + raise werkzeug.exceptions.InternalServerError() + + @http.route('/test_access_denied_json', type='json', auth='public', website=True) + def test_denied_error_json(self, **kwargs): + raise AccessDenied("This is an access denied rpc test") + + @http.route('/test_access_denied_http', type='http', auth='public', website=True) + def test_denied_error_http(self, **kwargs): + raise AccessDenied("This is an access denied http test") |
