def test_delete(self): db = self.env.get_db_cnx() cursor = db.cursor() cursor.execute("INSERT INTO bitten_report " "(build,step,category,generator) VALUES (%s,%s,%s,%s)", (1, 'test', 'test', 'unittest')) report_id = db.get_last_id(cursor, 'bitten_report') cursor.executemany("INSERT INTO bitten_report_item " "(report,item,name,value) VALUES (%s,%s,%s,%s)", [(report_id, 0, 'file', 'tests/foo.c'), (report_id, 0, 'result', 'failure'), (report_id, 1, 'file', 'tests/bar.c'), (report_id, 1, 'result', 'success')]) report = Report.fetch(self.env, report_id, db=db) report.delete(db=db) self.assertEqual(False, report.exists) report = Report.fetch(self.env, report_id, db=db) self.assertEqual(None, report)
def test_fetch(self): db = self.env.get_db_cnx() cursor = db.cursor() cursor.execute("INSERT INTO bitten_report " "(build,step,category,generator) VALUES (%s,%s,%s,%s)", (1, 'test', 'test', 'unittest')) report_id = db.get_last_id(cursor, 'bitten_report') cursor.executemany("INSERT INTO bitten_report_item " "(report,item,name,value) VALUES (%s,%s,%s,%s)", [(report_id, 0, 'file', 'tests/foo.c'), (report_id, 0, 'result', 'failure'), (report_id, 1, 'file', 'tests/bar.c'), (report_id, 1, 'result', 'success')]) report = Report.fetch(self.env, report_id) self.assertEquals(report_id, report.id) self.assertEquals('test', report.step) self.assertEquals('test', report.category) self.assertEquals('unittest', report.generator) self.assertEquals(2, len(report.items)) assert {'file': 'tests/foo.c', 'result': 'failure'} in report.items assert {'file': 'tests/bar.c', 'result': 'success'} in report.items