Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
openstructure
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container registry
Model registry
Analyze
Contributor 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
schwede
openstructure
Commits
4dfb5216
Unverified
Commit
4dfb5216
authored
1 year ago
by
Xavier Robin
Browse files
Options
Downloads
Patches
Plain Diff
test: add more tests for FindCompounds
Test behavior when no results and of invalid "by"
parent
599a0dd6
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
modules/conop/tests/test_compound.py
+19
-2
19 additions, 2 deletions
modules/conop/tests/test_compound.py
with
19 additions
and
2 deletions
modules/conop/tests/test_compound.py
+
19
−
2
View file @
4dfb5216
...
...
@@ -24,7 +24,7 @@ class TestCompound(unittest.TestCase):
self
.
assertEqual
(
compound
.
inchi_key
,
"
QNAYBMKLOCPYGJ-REOHCLBHSA-N
"
)
self
.
assertEqual
(
compound
.
smiles
,
"
C[C@@H](C(=O)O)N
"
)
def
testFindCompoundBySMILES
(
self
):
def
testFindCompound
s
BySMILES
(
self
):
"""
Test FindCompound by=
"
smiles
"
.
"""
compounds
=
self
.
compound_lib
.
FindCompounds
(
'
O
'
,
by
=
"
smiles
"
)
# Make sure all the compounds have the right smiles
...
...
@@ -39,7 +39,7 @@ class TestCompound(unittest.TestCase):
# lib, which should always be the case.
self
.
assertFalse
(
compounds
[
0
].
obsolete
)
def
testFindCompoundByInChI
(
self
):
def
testFindCompound
s
ByInChI
(
self
):
"""
Test FindCompound by=
"
inchi_code|key
"
.
"""
inchi_code
=
"
InChI=1/H2O/h1H2
"
inchi_key
=
"
XLYOFNOQVPJJNP-UHFFFAOYAF
"
...
...
@@ -56,6 +56,23 @@ class TestCompound(unittest.TestCase):
self
.
assertNotEqual
(
compound
,
None
)
self
.
assertEqual
(
compound
.
inchi
,
inchi_code
)
self
.
assertEqual
(
compound
.
inchi_key
,
inchi_key
)
def
testFindCompoundsNoResults
(
self
):
"""
Check that FindCompounds returns an empty list if no result is
found.
"""
# Searching an InChI code by SMILES can never succeed and
# should return an empty list
compounds
=
self
.
compound_lib
.
FindCompounds
(
"
InChI=1/H2O/h1H2
"
,
by
=
"
smiles
"
)
self
.
assertEqual
(
len
(
compounds
),
0
)
def
testFindCompoundsInvalidKey
(
self
):
"""
Ensure we don
'
t search by invalid keys
"""
with
self
.
assertRaises
(
Exception
,
msg
=
"
smile
"
):
compounds
=
self
.
compound_lib
.
FindCompounds
(
"
O
"
,
by
=
"
smile
"
)
# We also don't accept tlc - although this would technically be valid
with
self
.
assertRaises
(
Exception
,
msg
=
"
tlc
"
):
compounds
=
self
.
compound_lib
.
FindCompounds
(
"
ALA
"
,
by
=
"
tlc
"
)
if
__name__
==
'
__main__
'
:
from
ost
import
testutils
...
...
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