Bevel Factor Mapping
[blender.git] / source / tests / bl_rna_wiki_reference.py
index a4019214138ae59a44d22ae9520eb050a6a9df2b..c394107d8d177ac7cc204443c4c520704ac5f512 100644 (file)
 
 import bpy
 
+
 def test_data():
     import rna_wiki_reference
-    
+
     assert(isinstance(rna_wiki_reference.url_manual_mapping, tuple))
     for i, value in enumerate(rna_wiki_reference.url_manual_mapping):
         try:
@@ -44,12 +45,11 @@ def test_data():
             traceback.print_exc()
             raise
 
-# a stripped down version of api_dump() in rna_info_dump.py
 
+# a stripped down version of api_dump() in rna_info_dump.py
 def test_lookup_coverage():
 
     def rna_ids():
-        
         import rna_info
         struct = rna_info.BuildRNAInfo()[0]
         for struct_id, v in sorted(struct.items()):
@@ -81,23 +81,64 @@ def test_lookup_coverage():
     print("")
     print("---------------------")
     print("Undocumented Sections")
-    
+
     for rna_group in sorted(set_group_all):
         if rna_group not in set_group_doc:
             print("%s.*" % rna_group)
 
-def test_urls():
-    pass  # TODO
-
 
 def test_language_coverage():
     pass  # TODO
 
 
+def test_urls():
+    import sys
+    import rna_wiki_reference
+
+    import urllib.error
+    from urllib.request import urlopen
+
+    prefix = rna_wiki_reference.url_manual_prefix
+    urls = {suffix for (rna_id, suffix) in rna_wiki_reference.url_manual_mapping}
+
+    urls_len = "%d" % len(urls)
+    print("")
+    print("-------------" + "-" * len(urls_len))
+    print("Testing URLS %s" % urls_len)
+    print("")
+
+    color_red = '\033[0;31m'
+    color_green = '\033[1;32m'
+    color_normal = '\033[0m'
+
+    urls_fail = []
+
+    for url in sorted(urls):
+        url_full = prefix + url
+        print("  %s ... " % url_full, end="")
+        sys.stdout.flush()
+        try:
+            urllib.request.urlopen(url_full)
+            print(color_green + "OK" + color_normal)
+        except urllib.error.HTTPError:
+            print(color_red + "FAIL!" + color_normal)
+            urls_fail.append(url)
+
+    if urls_fail:
+        urls_len = "%d" % len(urls_fail)
+        print("")
+        print("------------" + "-" * len(urls_len))
+        print("Failed URLS %s" % urls_len)
+        print("")
+        for url in urls_fail:
+            print("  %s%s%s" % (color_red, url, color_normal))
+
+
 def main():
     test_data()
     test_lookup_coverage()
     test_language_coverage()
+    test_urls()
 
 if __name__ == "__main__":
     main()