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)
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))
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)