Skip to content

Commit

Permalink
improve license testcases
Browse files Browse the repository at this point in the history
  • Loading branch information
Jerry committed Aug 4, 2021
1 parent f2c1f69 commit fd1e258
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 58 deletions.
58 changes: 0 additions & 58 deletions tests/web/handlers/test_annotation.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,64 +197,6 @@ def test_33_allow_null(self):
assert res['_uid'] is None
assert res['_index'] is None

### Additional Features ###

def test_40_license(self):
""" GET /v1/gene/12566?fields=pantherdb.uniprot_kb
{
"_id": "12566",
"_version": 1,
"pantherdb": {
"_license": "http://pantherdb.org/tou.jsp",
"uniprot_kb": "P97377"
...
}
...
}
"""
res = self.request('/v1/gene/12566?fields=pantherdb.uniprot_kb').json()
assert res['pantherdb']['_license'] == "http://pantherdb.org/tou.jsp"

def test_41_license_transform(self):
""" GET /v1/gene/12566?fields=interpro
{
"_id": "12566",
"_version": 1,
"interpro": [
{
"_license": "http://pantherdb.org/tou.jsp",
"desc": "Protein kinase domain",
"id": "IPR000719",
"short_desc": "Prot_kinase_dom"
},
...
]
}
"""
res = self.request('/v1/gene/12566?fields=interpro').json()
for dic in res['interpro']:
assert dic['_license'] == "http://pantherdb.org/tou.jsp"

def test_42_license_transform(self):
""" GET /v1/gene/12566?fields=pantherdb.ortholog
{
"_id": "12566",
"_version": 1,
"pantherdb": {
"_license": "http://pantherdb.org/tou.jsp",
"ortholog": [
{
"RGD": "70486",
"_license": "http://pantherdb.org/tou.jsp",
...
},
...
],
}
"""
res = self.request('/v1/gene/12566?fields=pantherdb.ortholog').json()
for dic in res['pantherdb']['ortholog']:
assert dic['_license'] == "http://pantherdb.org/tou.jsp"

class TestAnnotationPOST(BiothingsWebAppTest):

Expand Down
64 changes: 64 additions & 0 deletions tests/web/handlers/test_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,3 +91,67 @@ def test_12_field_prefix(self):
assert res
for key in res:
assert key.startswith('accession')

# any access to the metadata endpoint would trigger an internal
# refresh on the metadata service, which feeds the values for
# other components like license injection in the formatter.

def test_20_license(self):
""" GET /v1/gene/12566?fields=pantherdb.uniprot_kb
{
"_id": "12566",
"_version": 1,
"pantherdb": {
"_license": "http://pantherdb.org/tou.jsp",
"uniprot_kb": "P97377"
...
}
...
}
"""
self.request('/v1/metadata/') # refresh internal metadata
res = self.request('/v1/gene/12566?fields=pantherdb.uniprot_kb').json()
assert res['pantherdb']['_license'] == "http://pantherdb.org/tou.jsp"

def test_21_license_transform(self):
""" GET /v1/gene/12566?fields=interpro
{
"_id": "12566",
"_version": 1,
"interpro": [
{
"_license": "http://pantherdb.org/tou.jsp",
"desc": "Protein kinase domain",
"id": "IPR000719",
"short_desc": "Prot_kinase_dom"
},
...
]
}
"""
self.request('/v1/metadata/') # refresh internal metadata
res = self.request('/v1/gene/12566?fields=interpro').json()
for dic in res['interpro']:
assert dic['_license'] == "http://pantherdb.org/tou.jsp"

def test_22_license_transform(self):
""" GET /v1/gene/12566?fields=pantherdb.ortholog
{
"_id": "12566",
"_version": 1,
"pantherdb": {
"_license": "http://pantherdb.org/tou.jsp",
"ortholog": [
{
"RGD": "70486",
"_license": "http://pantherdb.org/tou.jsp",
...
},
...
],
}
"""
self.request('/v1/metadata/') # refresh internal metadata
res = self.request('/v1/gene/12566?fields=pantherdb.ortholog').json()
for dic in res['pantherdb']['ortholog']:
assert dic['_license'] == "http://pantherdb.org/tou.jsp"

0 comments on commit fd1e258

Please sign in to comment.