Skip to content

Commit

Permalink
Add a positive test unit for _is_smiles when chem is none in test_com…
Browse files Browse the repository at this point in the history
…pound_identifier.py (#1332)

* Add a positive test for _is_smiles when chem is none in test_compound_identifier.py

* Test for valid SMILES input

---------

Co-authored-by: Dhanshree Arora <[email protected]>
  • Loading branch information
Ajoke23 and DhanshreeA authored Nov 18, 2024
1 parent d599866 commit ea74556
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion test/test_compound_identifier.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import pytest
from ersilia.utils.identifiers.compound import CompoundIdentifier
from unittest.mock import patch

@pytest.fixture
def compound_identifier():
Expand All @@ -18,8 +19,17 @@ def test_is_input_header_negative(compound_identifier, header):
def test_is_key_header_positive(compound_identifier, header):
"""Test that valid key headers return True."""
assert compound_identifier.is_key_header(header) is True

@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)

@patch('ersilia.utils.identifiers.compound.CompoundIdentifier._pubchem_smiles_to_inchikey')
def test_is_smiles_positive_chem_none(mock_pubchem, compound_identifier):
compound_identifier.Chem = None
mock_pubchem.return_value = "InChIKey"

# Test with a valid SMILES input
smiles_string = 'CCO' #Ethanol SMILES
assert compound_identifier._is_smiles(smiles_string) is True

0 comments on commit ea74556

Please sign in to comment.