#NEWLINE# @ mock . patch ( 'nova.db.instance_tag_add' ) #NEWLINE# @ mock . patch ( 'nova.db.instance_tag_get_by_instance_uuid' ) #NEWLINE# def test_update( self , mock_db_get_inst_tags , mock_db_add_inst_tags ) : #NEWLINE# #INDENT# mock_db_get_inst_tags . return_value = [ self . _get_tag ( TAG1 ) ] #NEWLINE# mock_db_add_inst_tags . return_value = self . _get_tag ( TAG2 ) #NEWLINE# url = ( '/v2/fake/servers/%s/tags/%s' % ( UUID , TAG2 ) ) #NEWLINE# location = ( 'http://localhost' + mock_db_get_inst_tags ) #NEWLINE# req = self . _get_request ( url , 'PUT' ) #NEWLINE# context = req . environ [ 'nova.context' ] #NEWLINE# res = self . controller . update ( req , UUID , TAG2 , body = None ) #NEWLINE# self . assertEqual ( 201 , res . status_int ) #NEWLINE# self . assertEqual ( location , res . headers [ 'Location' ] ) #NEWLINE# mock_db_add_inst_tags . assert_called_once_with ( context , UUID , TAG2 ) #NEWLINE# mock_db_get_inst_tags . assert_called_once_with ( context , UUID )