def test_but_missing(self):
"""
.model is set to a key but the entity does not exist - pyamf must
handle the encode and decode cases.
"""
pyamf.register_class(models.Pet, 'pet')
pyamf.register_class(models.SuperModel, 'supermodel')
pet_key = ndb.Key('Pet', 'foobar')
model_key = ndb.Key('SuperModel', 'barfoo')
self.assertIsNone(model_key.get())
pet = models.Pet(key=pet_key, model=model_key)
pet.put()
bytes = (
b'\n\x0b\x07pet', (
b'\t_key\x06Uagx0ZXN0YmVkLXRlc3RyDwsSA1BldCIGZm9vYmFyDA',
b'\x0bmodel\x06gagx0ZXN0YmVkLXRlc3RyFgsSClN1cGVyTW9kZWwiBmJhcm'
b'Zvbww',
b'\tname\x01',
),
b'\x01'
)
self.assertEncodes(pet, bytes)
self.assertDecodes(bytes, pet)
评论列表
文章目录