#NEWLINE# def test_create_and_update_inventory( self ) : #NEWLINE# #INDENT# resource_provider = objects . ResourceProvider ( context = self . context , uuid = uuidsentinel . inventory_resource_provider ) #NEWLINE# resource_provider . create ( ) #NEWLINE# resource_class = fields . ResourceClass . DISK_GB #NEWLINE# disk_inventory = objects . Inventory ( context = self . context , resource_provider = resource_provider , resource_class = resource_class , ** DISK_INVENTORY ) #NEWLINE# disk_inventory . create ( ) #NEWLINE# self . assertEqual ( resource_class , disk_inventory . resource_class ) #NEWLINE# self . assertEqual ( resource_provider , disk_inventory . resource_provider ) #NEWLINE# self . assertEqual ( DISK_INVENTORY [ 'allocation_ratio' ] , disk_inventory . allocation_ratio ) #NEWLINE# self . assertEqual ( DISK_INVENTORY [ 'total' ] , disk_inventory . total ) #NEWLINE# disk_inventory . total = 32 #NEWLINE# disk_inventory . save ( ) #NEWLINE# inventories = objects . InventoryList . get_all_by_resource_provider_uuid ( self . context , resource_provider . uuid ) #NEWLINE# self . assertEqual ( 1 , len ( inventories ) ) #NEWLINE# self . assertEqual ( 32 , inventories [ 0 ] . total ) #NEWLINE# inventories [ 0 ] . total = 33 #NEWLINE# inventories [ 0 ] . save ( ) #NEWLINE# reloaded_inventories = objects . InventoryList . get_all_by_resource_provider_uuid ( self . context , resource_provider . uuid ) #NEWLINE# self . assertEqual ( 33 , reloaded_inventories [ 0 ] . total )