Best Python code snippet using avocado_python
kegg_compound_test.py
Source:kegg_compound_test.py
1#!/usr/bin/python2import unittest3import json4from pygibbs import kegg_compound5from pygibbs import pseudoisomer6class TestKeggCompound(unittest.TestCase):7 8 def setUp(self):9 self.cid = 132310 self.str_cid = str(self.cid)11 self.name = 'Glyxolaterium-monohysterianase'12 self.names = ['Glyxolaterium-monohysterianase',13 'GMH']14 self.mass = '60.99'15 self.formula = 'H2CO3'16 self.inchi = 'InChI=1S/C2H2O2/c3-1-2-4/h1-2H' # inchi for glyoxal17 18 self.test_compound = kegg_compound.Compound(19 cid=self.cid, name=self.name, all_names=self.names,20 mass=self.mass, formula=self.formula, inchi=self.inchi)21 22 def testProperties(self):23 self.assertEqual(self.cid, self.test_compound.cid)24 self.assertEqual(self.name, self.test_compound.name)25 self.assertEqual(self.names, self.test_compound.all_names)26 self.assertEqual(self.mass, self.test_compound.mass)27 self.assertEqual(self.formula, self.test_compound.formula)28 self.assertEqual(self.inchi, self.test_compound.inchi)29 self.assertTrue(self.test_compound.from_kegg)30 31 kegg_link = self.test_compound.kegg_link32 self.assertNotEqual(-1, kegg_link.find(self.str_cid))33 34 def testSimpleGetters(self):35 molecule = self.test_compound.GetMolecule()36 self.assertTrue(molecule is not None)37 38 smiles = self.test_compound.get_smiles()39 self.assertTrue(smiles is not None)40 41 self.assertEqual(self.inchi, self.test_compound.get_inchi())42 self.assertNotEqual(-1, self.test_compound.get_string_cid().find(self.str_cid))43 44 # We call these methods to make sure they don't error.45 self.test_compound.get_atom_bag()46 self.test_compound.get_nH_and_charge()47 self.test_compound.get_num_electrons()48 49 def testAddThermodynamicData(self):50 pmap = pseudoisomer.PseudoisomerMap(nH=8, z=0, nMg=0, dG0=18.8)51 source_string = 'Noor, Bar-Even 2011'52 self.test_compound.AddThermodynamicData(pmap,53 source_string=source_string,54 priority=2)55 pmap = self.test_compound.pmaps[-1]56 self.assertEqual(source_string, pmap['source'])57 self.assertEqual(2, pmap['priority']) 58 59 def testSetThermodynamicError(self):60 error = 'Group contribution failed to solve your problems.'61 self.test_compound.SetThermodynamicError(error)62 self.assertEqual(error, self.test_compound.pmap_error)63 64 def testJSONDict(self):65 json_dict = self.test_compound.ToJSONDict()66 67 key_set = set(json_dict.keys())68 expected_keys = set(['CID', 'mass', 'formula', 'name',69 'names', 'InChI', 'num_electrons', 'from_kegg'])70 self.assertEqual(expected_keys, key_set)71 72 self.assertEqual(self.test_compound.get_string_cid(), json_dict['CID'])73 self.assertEqual(self.mass, json_dict['mass'])74 self.assertEqual(self.formula, json_dict['formula'])75 self.assertEqual(self.names[0], json_dict['name'])76 self.assertEqual(sorted(self.names), json_dict['names'])77 self.assertEqual(self.inchi, json_dict['InChI'])78 self.assertTrue(json_dict['num_electrons'] is not None)79 80 def testToDBRow(self):81 expected_row = [self.cid, self.name, json.dumps(self.names),82 self.mass, self.formula, self.inchi,83 self.test_compound.get_num_electrons(),84 self.test_compound.from_kegg,85 self.test_compound.pubchem_id,86 self.test_compound.cas]87 db_row = self.test_compound.ToDBRow()88 self.assertEqual(expected_row, db_row)89 90def Suite():91 return unittest.makeSuite(TestKeggCompound,'test')92 93if __name__ == '__main__':...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!