diff options
author | zsloan | 2018-08-14 20:16:32 +0000 |
---|---|---|
committer | zsloan | 2018-08-14 20:16:32 +0000 |
commit | 838362c116b02c090dadeb76cda27e9902a6626a (patch) | |
tree | a6be104cc73e3bc9e271f9b5ca854dd32f3b810d /test/requests/link_checker.py | |
parent | 0bead53661ea701ffd9f9d565e4d2ecbbed81a8e (diff) | |
parent | 85defabb17ecdef1c7b8e92fa2e06b44d1e9ca49 (diff) | |
download | genenetwork2-838362c116b02c090dadeb76cda27e9902a6626a.tar.gz |
Merge branch 'testing' of https://github.com/genenetwork/genenetwork2 into production
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) |