Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
ippidb-web
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
iPPIDB
ippidb-web
Commits
5356b72b
Commit
5356b72b
authored
5 years ago
by
Hervé MENAGER
Browse files
Options
Downloads
Patches
Plain Diff
change imports in tests.py, in preparation for refactoring
parent
a5f2ded9
No related branches found
No related tags found
1 merge request
!13
Master
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
ippisite/ippidb/tests.py
+30
-18
30 additions, 18 deletions
ippisite/ippidb/tests.py
with
30 additions
and
18 deletions
ippisite/ippidb/tests.py
+
30
−
18
View file @
5356b72b
...
...
@@ -11,8 +11,20 @@ from django.urls import reverse
import
requests
from
ippidb
import
ws
,
models
from
ippidb.ws
import
get_uniprot_info
from
ippidb
import
models
from
ippidb.ws
import
(
get_uniprot_info
,
get_doi_info
,
get_pfam_info
,
get_google_patent_info
,
PatentNotFound
,
get_pubmed_info
,
get_pdb_uniprot_mapping
,
get_pdb_pfam_mapping
,
EntryNotFoundError
,
convert_iupac_to_smiles_and_inchi
,
convert_smiles_to_iupac
,
)
from
.models
import
(
Compound
,
CompoundTanimoto
,
...
...
@@ -29,7 +41,7 @@ from .models import DrugBankCompound, Protein
class
MolSmiTestCase
(
TestCase
):
"""
Test MOL to SMILES and SMILES to MOL format conversion
function
s
Test MOL to SMILES and SMILES to MOL format conversion
iPPI-DB web service
s
"""
def
setUp
(
self
):
...
...
@@ -538,7 +550,7 @@ class TestGetDoiInfo(TestCase):
def
test_get_doi_info
(
self
):
try
:
resp
=
ws
.
get_doi_info
(
"
10.1073/pnas.0805139105
"
)
resp
=
get_doi_info
(
"
10.1073/pnas.0805139105
"
)
except
requests
.
exceptions
.
HTTPError
as
he
:
# skip this test if the DOI server throws an error
# (that happens)
...
...
@@ -561,7 +573,7 @@ class TestGetDoiInfo(TestCase):
class
TestGetPfamInfo
(
TestCase
):
def
test_get_pfam_info
(
self
):
target
=
{
"
id
"
:
"
bZIP_1
"
,
"
description
"
:
"
bZIP transcription factor
"
}
resp
=
ws
.
get_pfam_info
(
"
PF00170
"
)
resp
=
get_pfam_info
(
"
PF00170
"
)
self
.
assertEqual
(
resp
,
target
)
...
...
@@ -576,13 +588,13 @@ class TestGetGooglePatentInfo(TestCase):
"
McGrew, Robert T. Bell,
"
"
Steven Joseph Rich, Cisco Technology Inc
"
,
}
resp
=
ws
.
get_google_patent_info
(
"
US8856504
"
)
resp
=
get_google_patent_info
(
"
US8856504
"
)
self
.
assertEqual
(
resp
,
target
)
def
test_entry_not_found
(
self
):
self
.
assertRaises
(
ws
.
PatentNotFound
,
ws
.
get_google_patent_info
,
PatentNotFound
,
get_google_patent_info
,
"
US8856504US8856504US885US8856504US8856504
"
,
)
...
...
@@ -608,7 +620,7 @@ class TestGetPubMEDIdInfo(TestCase):
"
authors_list
"
:
"
Brancotte B, Biton A, Bernard-Pierrot I,
"
"
Radvanyi F, Reyal F, Cohen-Boulakia S
"
,
}
resp
=
ws
.
get_pubmed_info
(
"
21349868
"
)
resp
=
get_pubmed_info
(
"
21349868
"
)
self
.
assertEqual
(
resp
,
target
)
...
...
@@ -730,13 +742,13 @@ class TestGetPDBUniProtMapping(TestCase):
def
test_find_info
(
self
):
target
=
sorted
([
"
Q03164
"
,
"
O00255
"
])
resp
=
ws
.
get_pdb_uniprot_mapping
(
"
3u85
"
)
resp
=
get_pdb_uniprot_mapping
(
"
3u85
"
)
resp
=
sorted
(
resp
)
self
.
assertEqual
(
resp
,
target
)
self
.
assertEqual
(
len
(
resp
),
len
(
set
(
resp
)))
def
test_entry_not_found
(
self
):
self
.
assertRaises
(
ws
.
EntryNotFoundError
,
ws
.
get_pdb_uniprot_mapping
,
"
Xu85
"
)
self
.
assertRaises
(
EntryNotFoundError
,
get_pdb_uniprot_mapping
,
"
Xu85
"
)
class
TestGetPDBPfamMapping
(
TestCase
):
...
...
@@ -748,11 +760,11 @@ class TestGetPDBPfamMapping(TestCase):
target
=
{
"
PF05053
"
:
{
"
identifier
"
:
"
Menin
"
,
"
description
"
:
"
Menin
"
,
"
name
"
:
"
Menin
"
}
}
resp
=
ws
.
get_pdb_pfam_mapping
(
"
3u85
"
)
resp
=
get_pdb_pfam_mapping
(
"
3u85
"
)
self
.
assertDictEqual
(
resp
,
target
)
def
test_entry_not_found
(
self
):
self
.
assertRaises
(
ws
.
EntryNotFoundError
,
ws
.
get_pdb_
uniprot
_mapping
,
"
Xu85
"
)
self
.
assertRaises
(
EntryNotFoundError
,
get_pdb_
pfam
_mapping
,
"
Xu85
"
)
class
TestConvertIUPACToSMILESAndMore
(
TestCase
):
...
...
@@ -792,7 +804,7 @@ class TestConvertIUPACToSMILESAndMore(TestCase):
),
]
for
iupac
,
dict_expected
in
pairs
:
dict_returned
=
ws
.
convert_iupac_to_smiles_and_inchi
(
iupac
)
dict_returned
=
convert_iupac_to_smiles_and_inchi
(
iupac
)
self
.
assertEqual
(
dict_expected
[
"
smiles
"
],
dict_returned
[
"
smiles
"
])
self
.
assertEqual
(
dict_expected
[
"
inchi
"
],
dict_returned
[
"
inchi
"
])
self
.
assertEqual
(
dict_expected
[
"
stdinchi
"
],
dict_returned
[
"
stdinchi
"
])
...
...
@@ -800,12 +812,12 @@ class TestConvertIUPACToSMILESAndMore(TestCase):
def
test_invalid_entry
(
self
):
self
.
assertRaises
(
ws
.
EntryNotFoundError
,
ws
.
convert_iupac_to_smiles_and_inchi
,
EntryNotFoundError
,
convert_iupac_to_smiles_and_inchi
,
"
3-{1-oxo-6-[4-(piperid
"
,
)
self
.
assertRaises
(
ws
.
EntryNotFoundError
,
ws
.
convert_iupac_to_smiles_and_inchi
,
None
EntryNotFoundError
,
convert_iupac_to_smiles_and_inchi
,
None
)
...
...
@@ -818,7 +830,7 @@ class TestConvertSMILESToIUPAC(TestCase):
smiles_to_iupacs
=
{
"
CCC
"
:
"
propane
"
}
for
smiles
,
expected_iupac
in
smiles_to_iupacs
.
items
():
self
.
assertEqual
(
ws
.
convert_smiles_to_iupac
(
smiles
).
lower
(),
expected_iupac
.
lower
()
convert_smiles_to_iupac
(
smiles
).
lower
(),
expected_iupac
.
lower
()
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment