summaryrefslogtreecommitdiff
path: root/addons/base_setup/tests/test_res_config_doc_links.py
diff options
context:
space:
mode:
authorstephanchrst <stephanchrst@gmail.com>2022-05-10 21:51:50 +0700
committerstephanchrst <stephanchrst@gmail.com>2022-05-10 21:51:50 +0700
commit3751379f1e9a4c215fb6eb898b4ccc67659b9ace (patch)
treea44932296ef4a9b71d5f010906253d8c53727726 /addons/base_setup/tests/test_res_config_doc_links.py
parent0a15094050bfde69a06d6eff798e9a8ddf2b8c21 (diff)
initial commit 2
Diffstat (limited to 'addons/base_setup/tests/test_res_config_doc_links.py')
-rw-r--r--addons/base_setup/tests/test_res_config_doc_links.py57
1 files changed, 57 insertions, 0 deletions
diff --git a/addons/base_setup/tests/test_res_config_doc_links.py b/addons/base_setup/tests/test_res_config_doc_links.py
new file mode 100644
index 00000000..2175d59b
--- /dev/null
+++ b/addons/base_setup/tests/test_res_config_doc_links.py
@@ -0,0 +1,57 @@
+# -*- coding: utf-8 -*-
+# Part of Odoo. See LICENSE file for full copyright and licensing details.
+
+from odoo.tests.common import HttpCase, tagged
+import re
+
+
+@tagged('-standard', 'external', 'post_install', '-at_install') # nightly is not a real tag
+class TestResConfigDocLinks(HttpCase):
+ """
+ Parse the 'res_config' view to extract all documentation links and
+ check that every links are still valid.
+ """
+
+ def setUp(self):
+ """
+ Set-up the test environment
+ """
+ super(TestResConfigDocLinks, self).setUp()
+ self.re = re.compile("<a href=\"(\S+/documentation/\S+)\"")
+ self.links = set()
+
+ def test_01_links(self):
+ """
+ Firs test: check that all documentation links in 'res_config_settings'
+ views are not broken.
+ """
+ self._parse_view(self.env.ref('base.res_config_settings_view_form'))
+
+ for link in self.links:
+ self._check_link(link)
+
+ def _check_link(self, link):
+ """
+ Try to open the link and check the response status code
+ """
+ res = self.url_open(url=link)
+
+ self.assertEqual(
+ res.status_code, 200,
+ "The following link is broken: '%s'" % (link)
+ )
+
+ def _parse_view(self, view):
+ """
+ Analyse the view to extract documentation links and store them
+ in a set.
+ Then, parse its children if any.
+ """
+
+ # search the documentation links in the current view
+ for match in re.finditer(self.re, view.arch):
+ self.links.add(match.group(1))
+
+ # and then, search inside children
+ for child in view.inherit_children_ids:
+ self._parse_view(child)