def test4(self): cmd = 'select * from ten_elements_dups' resultSet = DbResultSet(self.curs, self.conn, cmd) r = [obj for obj in resultSet] self.assertEqual(len(r), 20) resultSet = DbResultSet(self.curs, self.conn, cmd, removeDups=0) r = [obj for obj in resultSet] self.assertEqual(len(r), 10)
def test3(self): cmd = 'select * from ten_elements' resultSet = DbResultSet(self.curs, self.conn, cmd) r = [obj for obj in resultSet] self.assertEqual(len(r), 10) # Test iterator resultSet = DbResultSet(self.curs, self.conn, cmd) self.assertEqual(next(resultSet), (0, 11)) self.assertEqual(len(list(resultSet)), 10)
def test6(self): """ """ cmd = 'select * from ten_elements_dups' set = DbResultSet(self.curs, self.conn, cmd, removeDups=0) r = [] for thing in set: r.append(thing) assert len(r) == 10
def test3(self): """ """ cmd = 'select * from ten_elements' set = DbResultSet(self.curs, self.conn, cmd) r = [] for thing in set: r.append(thing) assert len(r) == 10
def test_ForwardDbMolSupplier(self): cmd = 'select * from simple_mols order by ID' results = DbResultSet(self.curs, self.conn, cmd) expected = list(results) results = DbResultSet(self.curs, self.conn, cmd) supp = ForwardDbMolSupplier(results) self.assertEqual(supp.GetColumnNames(), ('ID', )) for smiles, mol in zip(expected, supp): self.assertEqual(Chem.MolToSmiles(Chem.MolFromSmiles(smiles[0])), Chem.MolToSmiles(mol)) self.assertEqual(smiles[1], mol.GetProp('ID')) self.assertRaises(StopIteration, next, supp) # We can not use an index for ForwardDbMolSupplier with self.assertRaises(TypeError): supp[0]
def test_general(self): # Check for a molecule column cmd = 'select * from ten_elements' results = DbResultSet(self.curs, self.conn, cmd) self.assertRaises(ValueError, ForwardDbMolSupplier, results)