Skip to content

Commit

Permalink
add negative test for the _is_inchikey method in CompoundIdentifier c…
Browse files Browse the repository at this point in the history
…lass (#1334)

Co-authored-by: Dhanshree Arora <[email protected]>
  • Loading branch information
adebisi4145 and DhanshreeA authored Nov 18, 2024
1 parent edb1aae commit c4c790a
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions test/test_compound_identifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,6 @@ def test_is_key_header_positive(compound_identifier, header):
@pytest.mark.parametrize("header", ["id","smiles","inchi","input", "some_header", "random", "header", ""])
def test_is_key_header_negative(compound_identifier, header):
assert not compound_identifier.is_key_header(header)

def test_guess_type_with_inchikey(compound_identifier):
inchikey = "LFQSCWFLJHTTHZ-UHFFFAOYSA-N"
result = compound_identifier.guess_type(inchikey)
assert result == "inchikey"


@pytest.mark.parametrize("inchikey", [
Expand All @@ -43,6 +38,24 @@ def test_is_inchikey_positive(compound_identifier, inchikey):
"""Test that valid InChIKeys return True."""
assert compound_identifier._is_inchikey(inchikey) is True


@pytest.mark.parametrize("inchikey", [
"BSYNRYMUTXBXSQUHFFFAOYSA",
"BSYNRYMUTXBXSQ-UHFFFAOYSA-XY",
"12345678901234-1234567890-X",
"BSYNRYMUTXBXSQ_UHFFFAOYSA-N",
"BSYNRYMUTXBXSQ-UHFFFAOYSA"
])
def test_is_inchikey_negative(compound_identifier, inchikey):
"""Test that invalid InChIKeys return False."""
assert not compound_identifier._is_inchikey(inchikey)


def test_guess_type_with_inchikey(compound_identifier):
inchikey = "LFQSCWFLJHTTHZ-UHFFFAOYSA-N"
result = compound_identifier.guess_type(inchikey)
assert result == "inchikey"


@patch('ersilia.utils.identifiers.compound.CompoundIdentifier._pubchem_smiles_to_inchikey')
def test_is_smiles_positive_chem_none(mock_pubchem, compound_identifier):
Expand Down

0 comments on commit c4c790a

Please sign in to comment.