<s> import mock <EOL> from oslo_utils import timeutils <EOL> from nova import objects <EOL> from nova . tests . unit . objects import test_objects <EOL> NOW = timeutils . utcnow ( ) . replace ( microsecond = <NUM_LIT:0> ) <EOL> fake_vol_usage = { <EOL> '<STR_LIT>' : NOW , <EOL> '<STR_LIT>' : None , <EOL> '<STR_LIT>' : None , <EOL> '<STR_LIT>' : <NUM_LIT:0> , <EOL> '<STR_LIT:id>' : <NUM_LIT:1> , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : None , <EOL> '<STR_LIT>' : None , <EOL> '<STR_LIT>' : <NUM_LIT:0> , <EOL> '<STR_LIT>' : <NUM_LIT:0> , <EOL> '<STR_LIT>' : <NUM_LIT:0> , <EOL> '<STR_LIT>' : <NUM_LIT:0> , <EOL> '<STR_LIT>' : NOW , <EOL> '<STR_LIT>' : <NUM_LIT:10> , <EOL> '<STR_LIT>' : <NUM_LIT:20> , <EOL> '<STR_LIT>' : <NUM_LIT:30> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> } <EOL> class _TestVolumeUsage ( object ) : <EOL> @ mock . patch ( '<STR_LIT>' , return_value = fake_vol_usage ) <EOL> def test_save ( self , mock_upd ) : <EOL> vol_usage = objects . VolumeUsage ( self . context ) <EOL> vol_usage . volume_id = '<STR_LIT>' <EOL> vol_usage . instance_uuid = '<STR_LIT>' <EOL> vol_usage . project_id = '<STR_LIT>' <EOL> vol_usage . user_id = '<STR_LIT>' <EOL> vol_usage . availability_zone = None <EOL> vol_usage . curr_reads = <NUM_LIT:10> <EOL> vol_usage . curr_read_bytes = <NUM_LIT:20> <EOL> vol_usage . curr_writes = <NUM_LIT:30> <EOL> vol_usage . curr_write_bytes = <NUM_LIT> <EOL> vol_usage . save ( ) <EOL> mock_upd . assert_called_once_with ( <EOL> self . context , '<STR_LIT>' , <NUM_LIT:10> , <NUM_LIT:20> , <NUM_LIT:30> , <NUM_LIT> , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , None , update_totals = False ) <EOL> self . compare_obj ( vol_usage , fake_vol_usage ) <EOL> @ mock . patch ( '<STR_LIT>' , return_value = fake_vol_usage ) <EOL> def test_save_update_totals ( self , mock_upd ) : <EOL> vol_usage = objects . VolumeUsage ( self . context ) <EOL> vol_usage . volume_id = '<STR_LIT>' <EOL> vol_usage . instance_uuid = '<STR_LIT>' <EOL> vol_usage . project_id = '<STR_LIT>' <EOL> vol_usage . user_id = '<STR_LIT>' <EOL> vol_usage . availability_zone = None <EOL> vol_usage . curr_reads = <NUM_LIT:10> <EOL> vol_usage . curr_read_bytes = <NUM_LIT:20> <EOL> vol_usage . curr_writes = <NUM_LIT:30> <EOL> vol_usage . curr_write_bytes = <NUM_LIT> <EOL> vol_usage . save ( update_totals = True ) <EOL> mock_upd . assert_called_once_with ( <EOL> self . context , '<STR_LIT>' , <NUM_LIT:10> , <NUM_LIT:20> , <NUM_LIT:30> , <NUM_LIT> , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , None , update_totals = True ) <EOL> self . compare_obj ( vol_usage , fake_vol_usage ) <EOL> class TestVolumeUsage ( test_objects . _LocalTest , _TestVolumeUsage ) : <EOL> pass <EOL> class TestRemoteVolumeUsage ( test_objects . _RemoteTest , _TestVolumeUsage ) : <EOL> pass </s>
