Esempio n. 1
0
 def testTempDictionary(self):
     inst = Instrument(name = 'erz12', type = 'future', ccy = 'EUR').save()
     self.assertTrue('cleaned_data' in inst._dbdata)
     p = pickle.dumps(inst)
     inst2 = pickle.loads(p)
     self.assertFalse('cleaned_data' in inst2._dbdata)
     inst2.save()
     self.assertTrue('cleaned_data' in inst._dbdata)
Esempio n. 2
0
 def dumps(self, x, logger = None):
     if x is not None:
         try:
             return pickle.dumps(x,self.protocol)
         except:
             if logger:
                 logger.error('Could not serialize {0}'.format(x),
                              exc_info = True)
Esempio n. 3
0
 def testSimple(self):
     inst = Instrument(name='erz12', type='future', ccy='EUR').save()
     p = pickle.dumps(inst)
     inst2 = pickle.loads(p)
     self.assertEqual(inst,inst2)
     self.assertEqual(inst.name,inst2.name)
     self.assertEqual(inst.type,inst2.type)
     self.assertEqual(inst.ccy,inst2.ccy)
Esempio n. 4
0
 def testPickle(self):
     a = Interval(4,6)
     s = pickle.dumps(a)
     b = pickle.loads(s)
     self.assertEqual(type(b),tuple)
     self.assertEqual(len(b),2)
     self.assertEqual(b[0],4)
     self.assertEqual(b[1],6)
Esempio n. 5
0
 def testTempDictionary(self):
     inst = Instrument(name = 'erz12', type = 'future', ccy = 'EUR').save()
     self.assertTrue(inst._temp)
     p = pickle.dumps(inst)
     inst2 = pickle.loads(p)
     self.assertFalse(hasattr(inst2,'_temp'))
     inst2.save()
     self.assertTrue(inst._temp)
Esempio n. 6
0
 def testSimple(self):
     inst = yield self.session().add(
                     Instrument(name='erz12', type='future', ccy='EUR'))
     p = pickle.dumps(inst)
     inst2 = pickle.loads(p)
     self.assertEqual(inst, inst2)
     self.assertEqual(inst.name, inst2.name)
     self.assertEqual(inst.type, inst2.type)
     self.assertEqual(inst.ccy, inst2.ccy)
Esempio n. 7
0
 def testSimple(self):
     inst = yield self.session().add(
         Instrument(name='erz12', type='future', ccy='EUR'))
     p = pickle.dumps(inst)
     inst2 = pickle.loads(p)
     self.assertEqual(inst, inst2)
     self.assertEqual(inst.name, inst2.name)
     self.assertEqual(inst.type, inst2.type)
     self.assertEqual(inst.ccy, inst2.ccy)
Esempio n. 8
0
 def testTempDictionary(self):
     session = self.session()
     inst = yield session.add(
                     Instrument(name='erz17', type='future', ccy='EUR'))
     self.assertTrue('cleaned_data' in inst._dbdata)
     p = pickle.dumps(inst)
     inst2 = pickle.loads(p)
     self.assertFalse('cleaned_data' in inst2._dbdata)
     yield session.add(inst2)
     self.assertTrue('cleaned_data' in inst._dbdata)
Esempio n. 9
0
 def testTempDictionary(self):
     session = self.session()
     inst = yield session.add(
         Instrument(name='erz17', type='future', ccy='EUR'))
     self.assertTrue('cleaned_data' in inst._dbdata)
     p = pickle.dumps(inst)
     inst2 = pickle.loads(p)
     self.assertFalse('cleaned_data' in inst2._dbdata)
     yield session.add(inst2)
     self.assertTrue('cleaned_data' in inst._dbdata)
Esempio n. 10
0
 def testPickleIntervals(self):
     a = self.intervals()
     s = pickle.dumps(a)
     b = pickle.loads(s)
     self.assertEqual(type(b),list)
     self.assertEqual(len(b),len(a))
Esempio n. 11
0
 def dumps(self, x):
     if x is not None:
         try:
             return pickle.dumps(x, self.protocol)
         except:
             LOGGER.exception('Could not pickle %s', x)
Esempio n. 12
0
 def dumps(self, x):
     if x is not None:
         try:
             return pickle.dumps(x, self.protocol)
         except:
             LOGGER.exception('Could not pickle %s', x)