diff options
author | zsloan | 2018-04-16 10:46:56 -0500 |
---|---|---|
committer | GitHub | 2018-04-16 10:46:56 -0500 |
commit | a58a4c3b8ee4f7256a18c99542ff6a9f355c0a2e (patch) | |
tree | 1e7677fa1fa210a2a957855578cd3ac3a47b720b /test/requests/link_checker.py | |
parent | 270f86c41f7c90cc4ca51bca0aec789a09a36a0e (diff) | |
parent | ebbc8c67c13b44df98ea3c2b355e86f77572543b (diff) | |
download | genenetwork2-a58a4c3b8ee4f7256a18c99542ff6a9f355c0a2e.tar.gz |
Merge pull request #317 from pjotrp/testing
Testing
Diffstat (limited to 'test/requests/link_checker.py')
-rw-r--r-- | test/requests/link_checker.py | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/test/requests/link_checker.py b/test/requests/link_checker.py index 64553ed8..715f330c 100644 --- a/test/requests/link_checker.py +++ b/test/requests/link_checker.py @@ -18,6 +18,10 @@ def is_internal_link(link): pattern = re.compile("^/.*") return pattern.match(link) +def is_in_page_link(link): + pattern = re.compile("^#.*") + return pattern.match(link) + def get_links(doc): return filter( lambda x: not ( @@ -40,6 +44,7 @@ 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: @@ -52,9 +57,10 @@ def check_page(host, start_url): print("Checking links host "+host+" in page `"+start_url+"`") doc = parse(start_url).getroot() links = get_links(doc) + in_page_links = filter(is_in_page_link, links) 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 = filter(lambda x: not (is_internal_link(x) or is_in_page_link(x)), links) + for link in internal_links: verify_link(host+link) |