From 044db2f67b1920a2586314c0d82ac3a07b2f786f Mon Sep 17 00:00:00 2001
From: Stefan Bienert <stefan.bienert@unibas.ch>
Date: Wed, 24 Feb 2016 15:58:42 +0100
Subject: [PATCH] Proper testing of existance of compounds lib

---
 modules/conop/tests/test_compound.py | 43 ++++++++++++++++------------
 1 file changed, 25 insertions(+), 18 deletions(-)

diff --git a/modules/conop/tests/test_compound.py b/modules/conop/tests/test_compound.py
index 700f52b28..80e9ac8b6 100644
--- a/modules/conop/tests/test_compound.py
+++ b/modules/conop/tests/test_compound.py
@@ -1,30 +1,37 @@
 import unittest
+import os
+from ost import GetSharedDataPath, SetPrefixPath
 from ost import mol
 from ost import conop
 
+def setUpModule():
+    SetPrefixPath(os.path.abspath(os.path.join(conop.__path__[0], os.pardir,
+                                               os.pardir, os.pardir,
+                                               os.pardir, os.pardir)))
+    compound_lib_path = os.path.join(GetSharedDataPath(),
+                                     'compounds.chemlib')
+    compound_lib = conop.CompoundLib.Load(compound_lib_path)
+    conop.SetDefaultLib(compound_lib)
+
 class TestCompound(unittest.TestCase):
-  
-  def setUp(self):
-    self.compound_lib=conop.GetDefaultLib()
+    def setUp(self):
+        self.compound_lib=conop.GetDefaultLib()
 
-  def testFindCompound(self):
-    compound=self.compound_lib.FindCompound('***')
-    self.assertEqual(compound, None)
-    compound=self.compound_lib.FindCompound('ALA')
-    self.assertNotEqual(compound, None)
-    self.assertEqual(compound.id, 'ALA')
-    self.assertEqual(compound.three_letter_code, 'ALA')
-    self.assertEqual(compound.one_letter_code, 'A')
-    self.assertTrue(compound.IsPeptideLinking())
-    self.assertEqual(compound.dialect, 'PDB')
-    self.assertEqual(compound.formula, 'C3 H7 N O2')
-    self.assertEqual(compound.chem_class, mol.L_PEPTIDE_LINKING)
+    def testFindCompound(self):
+        compound=self.compound_lib.FindCompound('***')
+        self.assertEqual(compound, None)
+        compound=self.compound_lib.FindCompound('ALA')
+        self.assertNotEqual(compound, None)
+        self.assertEqual(compound.id, 'ALA')
+        self.assertEqual(compound.three_letter_code, 'ALA')
+        self.assertEqual(compound.one_letter_code, 'A')
+        self.assertTrue(compound.IsPeptideLinking())
+        self.assertEqual(compound.dialect, 'PDB')
+        self.assertEqual(compound.formula, 'C3 H7 N O2')
+        self.assertEqual(compound.chem_class, mol.L_PEPTIDE_LINKING)
 
      
 if __name__=='__main__':
-  if not conop.GetDefaultLib():
-    print 'No compound library available. ignoring compound unit tests'
-  else:
     from ost import testutils
     testutils.RunTests()
 
-- 
GitLab