@@ -69,6 +69,40 @@ def setUp(self):
6969 ['C1C=CC=C1' , 2 , 32.5 , 65.5 , 18.16 , 24.71 , 30.25 , 34.7 , 41.25 , 45.83 , 52.61 ],
7070 ]
7171
72+ def testPickle (self ):
73+ """
74+ Test that a ThermoDatabase object can be successfully pickled and
75+ unpickled with no loss of information.
76+ """
77+ import cPickle
78+ thermodb0 = cPickle .loads (cPickle .dumps (self .database ))
79+
80+ self .assertEqual (thermodb0 .libraryOrder , self .database .libraryOrder )
81+ self .assertEqual (sorted (thermodb0 .depository .keys ()), \
82+ sorted (self .database .depository .keys ()))
83+
84+ self .assertEqual (sorted (thermodb0 .libraries .keys ()), \
85+ sorted (self .database .libraries .keys ()))
86+ self .assertEqual (sorted (thermodb0 .groups .keys ()), \
87+ sorted (self .database .groups .keys ()))
88+
89+ for key , depository0 in thermodb0 .depository .iteritems ():
90+ depository = self .database .depository [key ]
91+ self .assertTrue (type (depository0 ), type (depository ))
92+ self .assertEqual (sorted (depository0 .entries .keys ()), sorted (depository .entries .keys ()))
93+
94+ for key , library0 in thermodb0 .libraries .iteritems ():
95+ library = self .database .libraries [key ]
96+ self .assertTrue (type (library0 ), type (library ))
97+ self .assertEqual (sorted (library0 .entries .keys ()), sorted (library .entries .keys ()))
98+
99+ for key , group0 in thermodb0 .groups .iteritems ():
100+ group = self .database .groups [key ]
101+ self .assertTrue (type (group0 ), type (group ))
102+ self .assertEqual (sorted (group0 .entries .keys ()), sorted (group .entries .keys ()))
103+
104+
105+
72106 @work_in_progress
73107 def testNewThermoGeneration (self ):
74108 """
@@ -108,7 +142,6 @@ def testSymmetryContributionRadicals(self):
108142 thermoData_ga = self .database .getThermoDataFromGroups (spc )
109143
110144 self .assertAlmostEqual (thermoData_lib .getEntropy (298. ), thermoData_ga .getEntropy (298. ), 0 )
111-
112145
113146 @work_in_progress
114147 def testSymmetryNumberGeneration (self ):
@@ -613,6 +646,22 @@ def testConvertRingToSubMolecule(self):
613646 self .assertEqual (len (bonds2 ), 11 )
614647 self .assertEqual (len (bonds3 ), 15 )
615648
649+ def testGetCopyForOneRing (self ):
650+ """
651+ This method tests the getCopyForOneRing method, which returns
652+ an atom object list that contains deep copies of the atoms
653+ """
654+
655+ testAtomList = Molecule (SMILES = 'C1CCCCC1' ).atoms
656+ copiedAtomList = getCopyForOneRing (testAtomList )
657+
658+ testMolecule = Molecule (atoms = testAtomList )
659+ copiedMolecule = Molecule (atoms = copiedAtomList )
660+
661+ self .assertTrue (testAtomList != copiedAtomList )
662+ self .assertTrue (len (testAtomList )== len (copiedAtomList ))
663+ self .assertTrue (testMolecule .is_equal (copiedMolecule ))
664+
616665 def testToFailCombineTwoRingsIntoSubMolecule (self ):
617666 """
618667 Test that if two non-overlapped rings lead to AssertionError
@@ -833,6 +882,17 @@ def testBicyclicDecompositionForPolyringUsingAlkaneTricyclic(self):
833882 expectedAromaticBondNumInBicyclics = [0 , 0 , 0 ]
834883 self .assertEqual (aromaticBondNumInBicyclics , expectedAromaticBondNumInBicyclics )
835884
885+ def testCombineCycles (self ):
886+ """
887+ This method tests the combineCycles method, which simply joins two lists
888+ together without duplication.
889+ """
890+ mainCycle = Molecule (SMILES = 'C1CCC2CCCCC2C1' ).atoms
891+ testCycle1 = mainCycle [0 :8 ]
892+ testCycle2 = mainCycle [6 :]
893+ joinedCycle = combineCycles (testCycle1 ,testCycle2 )
894+ self .assertTrue (sorted (mainCycle )== sorted (joinedCycle ))
895+
836896
837897################################################################################
838898
0 commit comments