def testZodbObjectState(self): state = ZodbObjectState(self.obj) self.assertEqual(state.getError(), None) self.assertEqual(state.listItems(), None) self.assertEqual( list(state.listAttributes())[0][0], '_SampleContainer__data') self.assertEqual(state.getParent(), None) self.assertEqual(state.getParentState(), None) self.assertEqual(state.getName(), None) self.assertTrue('_SampleContainer__data' in state.asDict().keys())
def testZodbObjectState(self): state = ZodbObjectState(self.obj) self.assertEqual(state.getError(), None) self.assertEqual(state.listItems(), None) self.assertEqual(list(state.listAttributes())[0][0], '_SampleContainer__data') self.assertEqual(state.getParent(), None) self.assertEqual(state.getParentState(), None) self.assertEqual(state.getName(), None) self.assertTrue('_SampleContainer__data' in state.asDict().keys())
def _loadHistoricalState(self): results = [] for d in self.history: try: interp = ZodbObjectState(self.obj, d['tid'], _history=self.history) state = interp.asDict() error = interp.getError() except Exception, e: state = {} error = '%s: %s' % (e.__class__.__name__, e) results.append(dict(state=state, error=error))
def _loadHistoricalState(self): results = [] for d in self.history: try: interp = ZodbObjectState(self.obj, d['tid'], _history=self.history) state = interp.asDict() error = interp.getError() except Exception as e: state = {} error = '%s: %s' % (e.__class__.__name__, e) results.append(dict(state=state, error=error)) results.append(dict(state={}, error=None)) return results
def testAdapterLookupErrorHandling(self): obj = self.conn.root()['obj'] = Length() transaction.commit() state = ZodbObjectState(obj) self.assertRegex(state.getError(), '^ComponentLookupError: ')
def testUnpickleErrorHandling(self): obj = self.conn.root()['obj'] = PersistentObject() obj.attribute = CrashOnUnpickling() transaction.commit() state = ZodbObjectState(obj) self.assertEqual(state.getError(), 'Exception: oops')
def test(self): state = ZodbObjectState(self.obj) self.assertEqual(state.getError(), None)