def testLazyFieldComputation(self):
    '\n        Demonstrate that an item that is saved in the database without\n        derived fields (like lowerName or baseParentId) get those values\n        computed at load() time.\n        '
    item = Item().createItem('My Item Name', creator=self.users[0], folder=self.publicFolder)
    self.assertEqual(item['lowerName'], 'my item name')
    self.assertEqual(item['baseParentId'], self.users[0]['_id'])
    del item['lowerName']
    del item['baseParentType']
    item = Item().save(item, validate=False)
    item = Item().find({'_id': item['_id']})[0]
    self.assertNotHasKeys(item, ('lowerName', 'baseParentType'))
    Item().load(item['_id'], force=True)
    item = Item().find({'_id': item['_id']})[0]
    self.assertHasKeys(item, ('lowerName', 'baseParentType'))
    self.assertEqual(item['lowerName'], 'my item name')
    self.assertEqual(item['baseParentType'], 'user')
    self.assertEqual(item['baseParentId'], self.users[0]['_id'])
    item = Item().createItem('My Item Name', creator=self.users[0], folder=self.publicFolder, description=None)
    self.assertEqual(item['description'], '')
    item['description'] = 1
    item = Item().save(item)
    item = Item().findOne({'_id': item['_id']})
    self.assertEqual(item['description'], '1')
    self.assertEqual(item['lowerName'], 'my item name (1)')
    del item['lowerName']
    item = Item().save(item, validate=False)
    item = Item().findOne({'_id': item['_id']})
    self.assertNotHasKeys(item, ('lowerName',))
    Item().load(item['_id'], force=True)
    item = Item().findOne({'_id': item['_id']})
    self.assertHasKeys(item, ('lowerName',))
    self.assertEqual(item['lowerName'], 'my item name (1)')
Demonstrate that an item that is saved in the database without
derived fields (like lowerName or baseParentId) get those values
computed at load() time.
def testLazyFieldComputation(self):
    '\n        Demonstrate that an item that is saved in the database without\n        derived fields (like lowerName or baseParentId) get those values\n        computed at load() time.\n        '
    item = Item().createItem('My Item Name', creator=self.users[0], folder=self.publicFolder)
    self.assertEqual(item['lowerName'], 'my item name')
    self.assertEqual(item['baseParentId'], self.users[0]['_id'])
    del item['lowerName']
    del item['baseParentType']
    item = Item().save(item, validate=False)
    item = Item().find({'_id': item['_id']})[0]
    self.assertNotHasKeys(item, ('lowerName', 'baseParentType'))
    Item().load(item['_id'], force=True)
    item = Item().find({'_id': item['_id']})[0]
    self.assertHasKeys(item, ('lowerName', 'baseParentType'))
    self.assertEqual(item['lowerName'], 'my item name')
    self.assertEqual(item['baseParentType'], 'user')
    self.assertEqual(item['baseParentId'], self.users[0]['_id'])
    item = Item().createItem('My Item Name', creator=self.users[0], folder=self.publicFolder, description=None)
    self.assertEqual(item['description'], )
    item['description'] = 1
    item = Item().save(item)
    item = Item().findOne({'_id': item['_id']})
    self.assertEqual(item['description'], '1')
    self.assertEqual(item['lowerName'], 'my item name (1)')
    del item['lowerName']
    item = Item().save(item, validate=False)
    item = Item().findOne({'_id': item['_id']})
    self.assertNotHasKeys(item, ('lowerName',))
    Item().load(item['_id'], force=True)
    item = Item().findOne({'_id': item['_id']})
    self.assertHasKeys(item, ('lowerName',))
    self.assertEqual(item['lowerName'], 'my item name (1)')