Esempio n. 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())
Esempio n. 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())
Esempio n. 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))
Esempio n. 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
Esempio n. 5
0
 def testAdapterLookupErrorHandling(self):
     obj = self.conn.root()['obj'] = Length()
     transaction.commit()
     state = ZodbObjectState(obj)
     self.assertRegex(state.getError(), '^ComponentLookupError: ')
Esempio n. 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')
Esempio n. 7
0
 def test(self):
     state = ZodbObjectState(self.obj)
     self.assertEqual(state.getError(), None)
Esempio n. 8
0
 def testAdapterLookupErrorHandling(self):
     obj = self.conn.root()['obj'] = Length()
     transaction.commit()
     state = ZodbObjectState(obj)
     self.assertRegex(state.getError(), '^ComponentLookupError: ')
Esempio n. 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')
Esempio n. 10
0
 def test(self):
     state = ZodbObjectState(self.obj)
     self.assertEqual(state.getError(), None)