def test_it_will_not_write_if_given_dry_run(self): data = [ PdbInfo(pdb_id='0000'), PdbInfo(pdb_id='000A'), PdbInfo(pdb_id='000B') ] self.assertEquals(0, self.store_and_count('0000', data, dry_run=True))
def test_it_adds_all_entries(self): data = [ PdbInfo(pdb_id='0000'), PdbInfo(pdb_id='000A'), PdbInfo(pdb_id='000B') ] self.assertEquals(3, self.store_and_count('0000', data))
def test_it_can_merge_if_requested(self): saver = DatabaseSaver(CONFIG, Session) saver.merge = True saver('0000', PdbInfo(pdb_id='0000', resolution=10)) saver('0000', PdbInfo(pdb_id='0000', resolution=9)) with self.saver.session() as session: result = session.query(PdbInfo.resolution).\ filter_by(pdb_id='0000').one() self.assertEquals(9, result.resolution)
def test_it_always_commits(self): with self.session() as session: session.add(PdbInfo(pdb_id='0000')) with self.session() as session: count = session.query(PdbInfo).filter_by(pdb_id='0000').count() self.assertEquals(1, count)
def func(): with self.session() as session: session.add(PdbInfo(pdb_id='0000')) raise ValueError("Stop")
def data(): for index, id in enumerate(['0000', '000A', '000B', '000C']): if index == 1: raise ValueError() yield PdbInfo(pdb_id=id)
def data(): for id in ['0000', '000A', '000B', '000C']: yield PdbInfo(pdb_id=id)
def test_it_can_add_one_entry(self): val = self.store_and_count('0000', PdbInfo(pdb_id='0000')) self.assertEquals(1, val)