-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This makes sure it's not none before checking if it can be stripped
- Loading branch information
Showing
2 changed files
with
85 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,97 @@ | ||
import pytest | ||
|
||
from gilda.term import Term, get_identifiers_url | ||
|
||
|
||
def test_invalid(): | ||
with pytest.raises(ValueError): | ||
Term( | ||
None, | ||
"Mitochondria", | ||
"GO", | ||
"GO:0005739", | ||
"mitochondrion", | ||
"synonym", | ||
"mesh", | ||
None, | ||
"MESH", | ||
"D008928", | ||
) | ||
|
||
with pytest.raises(ValueError): | ||
Term( | ||
"", | ||
"Mitochondria", | ||
"GO", | ||
"GO:0005739", | ||
"mitochondrion", | ||
"synonym", | ||
"mesh", | ||
None, | ||
"MESH", | ||
"D008928", | ||
) | ||
|
||
with pytest.raises(ValueError): | ||
Term( | ||
" ", | ||
"Mitochondria", | ||
"GO", | ||
"GO:0005739", | ||
"mitochondrion", | ||
"synonym", | ||
"mesh", | ||
None, | ||
"MESH", | ||
"D008928", | ||
) | ||
|
||
|
||
def test_standalone_get_url(): | ||
assert get_identifiers_url('UP', 'P12345') == \ | ||
'https://identifiers.org/uniprot:P12345' | ||
assert get_identifiers_url('HGNC', '12345') == \ | ||
'https://identifiers.org/hgnc:12345' | ||
assert get_identifiers_url('CHEBI', 'CHEBI:12345') == \ | ||
'https://identifiers.org/CHEBI:12345' | ||
assert ( | ||
get_identifiers_url("UP", "P12345") == "https://identifiers.org/uniprot:P12345" | ||
) | ||
assert get_identifiers_url("HGNC", "12345") == "https://identifiers.org/hgnc:12345" | ||
assert ( | ||
get_identifiers_url("CHEBI", "CHEBI:12345") | ||
== "https://identifiers.org/CHEBI:12345" | ||
) | ||
|
||
|
||
def test_term_get_url(): | ||
term = Term(db='CHEBI', id='CHEBI:12345', entry_name='X', | ||
norm_text='x', text='X', source='test', status='name') | ||
assert term.get_curie() == \ | ||
'CHEBI:12345' | ||
assert term.get_idenfiers_url() == \ | ||
'https://identifiers.org/CHEBI:12345' | ||
term = Term( | ||
db="CHEBI", | ||
id="CHEBI:12345", | ||
entry_name="X", | ||
norm_text="x", | ||
text="X", | ||
source="test", | ||
status="name", | ||
) | ||
assert term.get_curie() == "CHEBI:12345" | ||
assert term.get_idenfiers_url() == "https://identifiers.org/CHEBI:12345" | ||
assert term.get_groundings() == {(term.db, term.id)} | ||
assert term.get_namespaces() == {term.db} | ||
|
||
|
||
def test_term_source_db_id(): | ||
term = Term('mitochondria', 'Mitochondria', 'GO', 'GO:0005739', | ||
'mitochondrion', 'synonym', 'mesh', None, 'MESH', 'D008928') | ||
assert term.source_db == 'MESH' | ||
assert term.source_id == 'D008928' | ||
assert term.get_groundings() == {(term.db, term.id), | ||
(term.source_db, term.source_id)} | ||
term = Term( | ||
"mitochondria", | ||
"Mitochondria", | ||
"GO", | ||
"GO:0005739", | ||
"mitochondrion", | ||
"synonym", | ||
"mesh", | ||
None, | ||
"MESH", | ||
"D008928", | ||
) | ||
assert term.source_db == "MESH" | ||
assert term.source_id == "D008928" | ||
assert term.get_groundings() == { | ||
(term.db, term.id), | ||
(term.source_db, term.source_id), | ||
} | ||
|
||
assert term.get_namespaces() == {term.db, term.source_db} |