From aeae320c6db745f17803104a0dccf3213b2f9fc9 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Herv=C3=A9=20=20MENAGER?= <herve.menager@pasteur.fr>
Date: Wed, 5 Sep 2018 10:11:25 +0200
Subject: [PATCH] handle arbitrary MOL headers from OpenBabel in conversion
 tests

for #83


Former-commit-id: 4cfe727da7da6c926d681be67edfe780b3d14d73
---
 ippisite/ippidb/tests.py | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/ippisite/ippidb/tests.py b/ippisite/ippidb/tests.py
index 89e0da3b..13e1978a 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):
-- 
GitLab