diff --git a/ippisite/ippidb/tests.py b/ippisite/ippidb/tests.py index 89e0da3b65c88ddc2e0550dbd34e439384c54889..13e1978a03bfe103fbfc03bb29894b56000db8d6 100644 --- a/ippisite/ippidb/tests.py +++ b/ippisite/ippidb/tests.py @@ -1,3 +1,5 @@ +import re + from django.test import TestCase from openbabel import vectorUnsignedInt @@ -5,16 +7,20 @@ from .models import Compound, CompoundTanimoto, create_tanimoto from .utils import FingerPrinter, mol2smi, smi2mol class MolSmiTestCase(TestCase): + """ + Test MOL to SMILES and SMILES to MOL format conversion functions + """ def setUp(self): self.smiles_str = "C" - self.mol_str = "\n OpenBabel09041811452D\n\n 1 0 0 0 0 0 0 0 0 0999 V2000\n 0.0000 0.0000 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0\nM END\n" + # the MOL version is also a valid regexp to validate arbitrary name in the openbabel-generated version + self.mol_str = "\n OpenBabel[0-9]{11}D\n\n 1 0 0 0 0 0 0 0 0 0999 V2000\n 1.0000 0.0000 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0\nM END\n" def test_mol2smi(self): self.assertEqual(mol2smi(self.mol_str), self.smiles_str) - def test_smi2mol(self): - self.assertEqual(smi2mol(self.smiles_str), self.mol_str) + def test_smi2mol2smi(self): + self.assertTrue(re.compile(self.mol_str).match(smi2mol(self.smiles_str))) class FingerPrinterTestCase(TestCase):