aboutsummaryrefslogtreecommitdiff
path: root/test/requests/link_checker.py
diff options
context:
space:
mode:
authorMuriithi Frederick Muriuki2018-03-19 17:08:05 +0300
committerMuriithi Frederick Muriuki2018-03-19 17:08:05 +0300
commit178102c304e5ad1da2af5b2ab0af2484edb8a609 (patch)
tree791ef75d2ea158501567771512bc0214fa6da42d /test/requests/link_checker.py
parent5ccf077f53c6546bb9258c7116b4b1cf8903375f (diff)
downloadgenenetwork2-178102c304e5ad1da2af5b2ab0af2484edb8a609.tar.gz
* Add mapping tests. Fix link-checker tests.
* Add tests for the R/qtl and CIM mapping tools. * Fix tests for in-page links.
Diffstat (limited to 'test/requests/link_checker.py')
-rw-r--r--test/requests/link_checker.py16
1 files changed, 12 insertions, 4 deletions
diff --git a/test/requests/link_checker.py b/test/requests/link_checker.py
index 256bf6ef..a75327f0 100644
--- a/test/requests/link_checker.py
+++ b/test/requests/link_checker.py
@@ -16,6 +16,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 (
@@ -32,17 +36,21 @@ def verify_link(link):
else:
print("ERROR: link `"+link+"` failed with status "
, result.status_code)
- except ConnectionError as ex:
- print("ERROR: ", link, ex)
+ except Exception as ex:
+ print("ERROR: ("+link+")", ex)
def check_page(host, start_url):
print("")
print("Checking links 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 in_page_links:
+ verify_link(start_url+link)
+
for link in internal_links:
verify_link(host+link)