예제 #1
0
파일: meta.py 프로젝트: kuno/python-stdnet
 def testHash(self):
     '''Test model instance hash'''
     inst = Instrument(name = 'erz12', type = 'future', ccy = 'EUR')
     self.assertRaises(TypeError,hash, inst)
     inst.save()
     h = hash(inst)
     self.assertTrue(h)
예제 #2
0
 def testUniqueId(self):
     '''Test model instance unique id across different model'''
     inst = Instrument(name = 'erz12', type = 'future', ccy = 'EUR')
     self.assertRaises(inst.DoesNotExist, lambda : inst.uuid)
     inst.save()
     v = inst.uuid.split('.') # <<model hash>>.<<instance id>>
     self.assertEqual(len(v),2)
     self.assertEqual(v[0],inst._meta.hash)
     self.assertEqual(v[1],str(inst.id))
예제 #3
0
 def testHash(self):
     '''Test model instance hash'''
     inst = Instrument(name='erz12', type='future', ccy='EUR')
     h0 = hash(inst)
     self.assertTrue(h0)
     inst.save()
     h = hash(inst)
     self.assertTrue(h)
     self.assertNotEqual(h, h0)