def test_db_corruption(self): '''Detection of DB file corruption''' try: (fd, db) = tempfile.mkstemp() os.close(fd) self.crashes.init_duplicate_db(db) self.assertEqual(self.crashes.check_duplicate(0), None) self.assertEqual( self.crashes._duplicate_db_dump(), {self.crashes.download(0).crash_signature(): (0, None)}) self.crashes.duplicate_db_fixed(0, '42') self.assertEqual( self.crashes._duplicate_db_dump(), {self.crashes.download(0).crash_signature(): (0, '42')}) del self.crashes # damage file f = open(db, 'r+') f.truncate(os.path.getsize(db) * 2 / 3) f.close() self.crashes = CrashDatabase(None, {}) self.assertRaises(Exception, self.crashes.init_duplicate_db, db) finally: os.unlink(db)
def setUp(self): self.workdir = tempfile.mkdtemp() self.dupdb_dir = os.path.join(self.workdir, 'dupdb') self.crashes = CrashDatabase(None, {'dummy_data': '1', 'dupdb_url': 'file://' + self.dupdb_dir}) self.assertEqual(self.crashes.get_comment_url(self.crashes.download(0), 0), 'http://foo.bugs.example.com/0') # test-suite internal consistency check: Python signatures are # indeed equal and exist assert self.crashes.download(3).crash_signature(), \ 'test-suite internal check: Python crash sigs exist' self.assertEqual(self.crashes.download(3).crash_signature(), self.crashes.download(4).crash_signature()) # we should have 5 crashes self.assertEqual(self.crashes.latest_id(), 4)
def test_no_dummy_data(self): '''No dummy data is added by default''' self.crashes = CrashDatabase(None, {}) self.assertEqual(self.crashes.latest_id(), -1) self.assertRaises(IndexError, self.crashes.download, 0)