#NEWLINE# @ mock . patch ( 'nova.db.instance_extra_update_by_uuid' ) #NEWLINE# def test_save_migration_context_model( self , mock_update ) : #NEWLINE# #INDENT# inst = fake_instance . fake_instance_obj ( self . context ) #NEWLINE# inst . migration_context = test_mig_ctxt . get_fake_migration_context_obj ( self . context ) #NEWLINE# inst . save ( ) #NEWLINE# self . assertTrue ( mock_update . called ) #NEWLINE# self . assertEqual ( 1 , mock_update . call_count ) #NEWLINE# actual_args = mock_update . call_args #NEWLINE# self . assertEqual ( self . context , actual_args [ 0 ] [ 0 ] ) #NEWLINE# self . assertEqual ( inst . uuid , actual_args [ 0 ] [ 1 ] ) #NEWLINE# self . assertEqual ( [ 'migration_context' ] , list ( actual_args [ 0 ] [ 2 ] . keys ( ) ) ) #NEWLINE# self . assertIsInstance ( objects . MigrationContext . obj_from_db_obj ( actual_args [ 0 ] [ 2 ] [ 'migration_context' ] ) , objects . MigrationContext ) #NEWLINE# mock_update . reset_mock ( ) #NEWLINE# inst . migration_context = None #NEWLINE# inst . save ( ) #NEWLINE# mock_update . assert_called_once_with ( mock_update . context , inst . uuid , { #NEWLINE# #INDENT# 'migration_context' : None , #NEWLINE# #UNINDENT# } )