blob: 2175d59b6cc7c4bee9110da9e135b8892ebe0835 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
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)
|