1 # ##### BEGIN GPL LICENSE BLOCK #####
3 # This program is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU General Public License
5 # as published by the Free Software Foundation; either version 2
6 # of the License, or (at your option) any later version.
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with this program; if not, write to the Free Software Foundation,
15 # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 # ##### END GPL LICENSE BLOCK #####
21 # Use for validating our wiki interlinking.
22 # ./blender.bin --background -noaudio --python source/tests/bl_rna_wiki_reference.py
24 # 1) test_data() -- ensure the data we have is correct format
25 # 2) test_lookup_coverage() -- ensure that we have lookups for _every_ RNA path
26 # 3) test_urls() -- ensure all the URL's are correct
27 # 4) test_language_coverage() -- ensure language lookup table is complete
33 import rna_wiki_reference
35 assert(isinstance(rna_wiki_reference.url_manual_mapping, tuple))
36 for i, value in enumerate(rna_wiki_reference.url_manual_mapping):
38 assert(len(value) == 2)
39 assert(isinstance(value[0], str))
40 assert(isinstance(value[1], str))
42 print("Expected a tuple of 2 strings, instead item %d is a %s: %r" % (i, type(value), value))
47 # a stripped down version of api_dump() in rna_info_dump.py
49 def test_lookup_coverage():
54 struct = rna_info.BuildRNAInfo()[0]
55 for struct_id, v in sorted(struct.items()):
56 props = [(prop.identifier, prop) for prop in v.properties]
57 struct_path = "bpy.types.%s" % struct_id[1]
58 for prop_id, prop in props:
59 yield (struct_path, "%s.%s" % (struct_path, prop_id))
61 for submod_id in dir(bpy.ops):
62 op_path = "bpy.ops.%s" % submod_id
63 for op_id in dir(getattr(bpy.ops, submod_id)):
64 yield (op_path, "%s.%s" % (op_path, op_id))
67 from bl_operators import wm
72 for rna_group, rna_id in rna_ids():
73 url = wm.WM_OT_doc_view_manual._lookup_rna_url(rna_id, verbose=False)
74 print(rna_id, "->", url)
76 set_group_all.add(rna_group)
78 set_group_doc.add(rna_group)
80 # finally report undocumented groups
82 print("---------------------")
83 print("Undocumented Sections")
85 for rna_group in sorted(set_group_all):
86 if rna_group not in set_group_doc:
87 print("%s.*" % rna_group)
93 def test_language_coverage():
99 test_lookup_coverage()
100 test_language_coverage()
102 if __name__ == "__main__":