From 86fd0e0bec0c56ffa7857d9bf8c2c0dac25f99dc Mon Sep 17 00:00:00 2001 From: BonfaceKilz Date: Fri, 4 Sep 2020 01:02:38 +0300 Subject: Fix false positive tests * test/requests/link_checker.py: (verify_static_file): Add it. Verify that a static link is fetched by checking for the message "Error: 404 not Found" in page. (check_package_js_files): Add appropriate 'js' or 'css' prefix. --- test/requests/link_checker.py | 53 +++++++++++++++++++++++++++---------------- 1 file changed, 34 insertions(+), 19 deletions(-) (limited to 'test/requests') diff --git a/test/requests/link_checker.py b/test/requests/link_checker.py index 47454c75..d040ba54 100644 --- a/test/requests/link_checker.py +++ b/test/requests/link_checker.py @@ -52,6 +52,21 @@ def verify_link(link): if DO_FAIL: raise ex + +def verify_static_file(link): + print("verifying "+link) + try: + result = requests.get(link, timeout=20, verify=False) + if (result.status_code == 200 and + result.content.find("Error: 404 Not Found") <= 0): + print(link+" ==> OK") + else: + print("ERROR: link {}".format(link)) + raise Exception("Failed verify") + except ConnectionError as ex: + print("ERROR: ", link, ex) + + def check_page(host, start_url): print("") print("Checking links host "+host+" in page `"+start_url+"`") @@ -85,28 +100,28 @@ def check_packaged_js_files(args_obj, parser): host = args_obj.host js_files = [ # Datatables Extensions: - "/DataTablesExtensions/buttonsBootstrap/css/buttons.bootstrap.css", - "/DataTablesExtensions/buttons/js/dataTables.buttons.min.js", - "/DataTablesExtensions/buttonStyles/css/buttons.dataTables.min.css", - "/DataTablesExtensions/buttons/js/dataTables.buttons.min.js", - "/DataTablesExtensions/colResize/dataTables.colResize.js", - "/DataTablesExtensions/colReorder/js/dataTables.colReorder.js", - "/DataTablesExtensions/buttons/js/buttons.colVis.min.js", - "/DataTables/js/jquery.dataTables.js", - "/DataTablesExtensions/scroller/css/scroller.dataTables.min.css", + "/css/DataTablesExtensions/buttonsBootstrap/css/buttons.bootstrap.css", + "/js/DataTablesExtensions/buttons/js/dataTables.buttons.min.js", + "/css/DataTablesExtensions/buttonStyles/css/buttons.dataTables.min.css", + "/js/DataTablesExtensions/buttons/js/dataTables.buttons.min.js", + "/js/DataTablesExtensions/colResize/dataTables.colResize.js", + "/js/DataTablesExtensions/colReorder/js/dataTables.colReorder.js", + "/js/DataTablesExtensions/buttons/js/buttons.colVis.min.js", + "/js/DataTables/js/jquery.dataTables.js", + "/css/DataTablesExtensions/scroller/css/scroller.dataTables.min.css", # Datatables plugins: - "/DataTablesExtensions/plugins/sorting/natural.js", - "/DataTablesExtensions/plugins/sorting/scientific.js", + "/js/DataTablesExtensions/plugins/sorting/natural.js", + "/js/DataTablesExtensions/plugins/sorting/scientific.js", # Other js libraries - "/chroma/chroma.min.js", - "/d3-tip/d3-tip.js", - "/d3js/d3.min.js", - "/js_alt/underscore.min.js", - "/nvd3/nv.d3.min.css", - "/qtip2/jquery.qtip.min.js", - "/js_alt/md5.min.js", + "/js/chroma/chroma.min.js", + "/js/d3-tip/d3-tip.js", + "/js/d3js/d3.min.js", + "/js/js_alt/underscore.min.js", + "/js/nvd3/nv.d3.min.css", + "/js/qtip2/jquery.qtip.min.js", + "/js/js_alt/md5.min.js", ] print("Checking links") for link in js_files: - verify_link(host+link) + verify_static_file(host+link) -- cgit v1.2.3