Beispiel #1
0
 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())
Beispiel #2
0
 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())
Beispiel #3
0
 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))
Beispiel #4
0
 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
Beispiel #5
0
 def testAdapterLookupErrorHandling(self):
     obj = self.conn.root()['obj'] = Length()
     transaction.commit()
     state = ZodbObjectState(obj)
     self.assertRegex(state.getError(), '^ComponentLookupError: ')
Beispiel #6
0
 def testUnpickleErrorHandling(self):
     obj = self.conn.root()['obj'] = PersistentObject()
     obj.attribute = CrashOnUnpickling()
     transaction.commit()
     state = ZodbObjectState(obj)
     self.assertEqual(state.getError(), 'Exception: oops')
Beispiel #7
0
 def test(self):
     state = ZodbObjectState(self.obj)
     self.assertEqual(state.getError(), None)
Beispiel #8
0
 def testAdapterLookupErrorHandling(self):
     obj = self.conn.root()['obj'] = Length()
     transaction.commit()
     state = ZodbObjectState(obj)
     self.assertRegex(state.getError(), '^ComponentLookupError: ')
Beispiel #9
0
 def testUnpickleErrorHandling(self):
     obj = self.conn.root()['obj'] = PersistentObject()
     obj.attribute = CrashOnUnpickling()
     transaction.commit()
     state = ZodbObjectState(obj)
     self.assertEqual(state.getError(), 'Exception: oops')
Beispiel #10
0
 def test(self):
     state = ZodbObjectState(self.obj)
     self.assertEqual(state.getError(), None)