about summary refs log tree commit diff
path: root/test/requests/link_checker.py
diff options
context:
space:
mode:
authorPjotr Prins2018-03-30 08:14:02 +0000
committerPjotr Prins2018-03-30 08:14:02 +0000
commitc4d3f406fb01f81b2b952a622f2f7bb0967c8c91 (patch)
tree6abc6dbe8a60dac7fd13991930a793d303e53c58 /test/requests/link_checker.py
parent13ba222e4a04c514d10c35caafb5297309914d4c (diff)
downloadgenenetwork2-c4d3f406fb01f81b2b952a622f2f7bb0967c8c91.tar.gz
Add --fail argument to test runner
Diffstat (limited to 'test/requests/link_checker.py')
-rw-r--r--test/requests/link_checker.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/test/requests/link_checker.py b/test/requests/link_checker.py
index 5adbf9a9..0f81caa4 100644
--- a/test/requests/link_checker.py
+++ b/test/requests/link_checker.py
@@ -4,6 +4,8 @@ import requests
 from lxml.html import parse
 from requests.exceptions import ConnectionError
 
+DO_FAIL=False  # fail on error
+
 def is_root_link(link):
     pattern = re.compile("^/$")
     return pattern.match(link)
@@ -25,6 +27,7 @@ def get_links(doc):
               , doc.cssselect("a")))
 
 def verify_link(link):
+    assert(DO_FAIL)
     if link[0] == "#":
         # local link on page
         return
@@ -38,8 +41,12 @@ def verify_link(link):
         else:
             print("ERROR: link `"+link+"` failed with status "
                   , result.status_code)
+            if DO_FAIL:
+                raise Exception("Failed verify")
     except ConnectionError as ex:
         print("ERROR: ", link, ex)
+        if DO_FAIL:
+            raise ex
 
 def check_page(host, start_url):
     print("")
@@ -48,7 +55,7 @@ def check_page(host, start_url):
     links = get_links(doc)
     internal_links = filter(is_internal_link, links)
     external_links = filter(lambda x: not is_internal_link(x), links)
-    external_links.append("http://somenon-existentsite.brr")
+    # external_links.append("http://somenon-existentsite.brr")
     for link in internal_links:
         verify_link(host+link)