Commit a87e5221 authored by Lukas Jelonek's avatar Lukas Jelonek
Browse files

Add check to test if the generated urls return valid exit codes

parent 8eda5c8f
import unittest
from dbxref import resolver
valid_ids = [
invalid_ids = [
class TestDbxrefResolve(unittest.TestCase):
def test_conversion_of_string_to_dbxref(self):
......@@ -69,10 +105,17 @@ class TestDbxrefResolve(unittest.TestCase):
self.assertEqual(resolver.check_dbxref_exists(resolver.convert_string_to_dbxref(d[0])), d[1] )
def test_check_urls(self):
import json
data = '[]'
data3 = '[{"locations": [{"type": "xml", "url": ""}, {"type": "html", "url": ""}], "dbxref": "GO:1234"},{"dbxref": "UniProtKB/Swiss-Prot:P12345", "locations": [{"url": "", "type": "xml"}, {"url": "", "type": "html"}]}, {"dbxref": "UniProtKB/TrEMBL:A2VB99", "locations": [{"url": "", "type": "xml"}, {"url": "", "type": "html"}]}, {"dbxref": "taxon:452271", "locations": [{"url": "", "type": "xml"}, {"url": "", "type": "html"}]}, {"dbxref": "SO:0000704", "locations": [{"url": "", "type": "html"}]}, {"dbxref": "RFAM:RF00360", "locations": [{"url": "", "type": "xml"}, {"url": "", "type": "html"}]}, {"dbxref": "pubmed:19037750", "locations": [{"url": "", "type": "html"}]}, {"dbxref": "PFAM:PF00002", "locations": [{"url": "", "type": "html"}]}, {"dbxref": "PDB:4AJY", "locations": [{"url": "", "type": "xml"}, {"url": "", "type": "html"}]}, {"dbxref": "InterPro:IPR002928", "locations": [{"url": "", "type": "html"}]}, {"dbxref": "", "locations": [{"url": "", "type": "html"}]}, {"dbxref": "", "locations": [{"url": "", "type": "html"}]}, {"dbxref": "GeneID:956582", "locations": [{"url": "", "type": "xml"}, {"url": "", "type": "html"}]}, {"dbxref": "GO:0097281", "locations": [{"url": "", "type": "xml"}, {"url": "", "type": "html"}]}, {"dbxref": "GI:731497", "locations": [{"url": "", "type": "xml"}, {"url": "", "type": "html"}]}, {"dbxref": "EC:", "locations": [{"url": "", "type": "html"}]}]'
data = json.loads(data3)
import requests
dbxrefs = resolver.convert_to_dbxrefs(valid_ids)
resolved = resolver.resolve(dbxrefs, check_existence=False)
for r in resolved:
for k in r['locations']:
for url in r['locations'][k]:
with self.subTest(url=url):
with requests.get(url, allow_redirects=True, timeout=3) as req:
self.assertLess(req.status_code, 400)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment