<s> """<STR_LIT>""" <EOL> from cloudcafe . common . tools . datagen import rand_name <EOL> from cloudcafe . glance . common . constants import Messages <EOL> from cloudroast . glance . fixtures import ImagesFixture <EOL> class ImageTagOperationsActions ( ImagesFixture ) : <EOL> @ classmethod <EOL> def setUpClass ( cls ) : <EOL> super ( ImageTagOperationsActions , cls ) . setUpClass ( ) <EOL> cls . tag = rand_name ( '<STR_LIT>' ) <EOL> created_images = cls . images . behaviors . create_images_via_task ( <EOL> image_properties = { <EOL> '<STR_LIT:name>' : rand_name ( '<STR_LIT>' ) } , <EOL> count = <NUM_LIT:2> ) <EOL> cls . add_image_tag_image = created_images . pop ( ) <EOL> cls . delete_image_tag_image = created_images . pop ( ) <EOL> cls . images . client . add_image_tag ( <EOL> cls . delete_image_tag_image . id_ , cls . tag ) <EOL> @ classmethod <EOL> def tearDownClass ( cls ) : <EOL> cls . images . behaviors . resources . release ( ) <EOL> super ( ImageTagOperationsActions , cls ) . tearDownClass ( ) <EOL> def test_add_single_image_tag ( self ) : <EOL> """<STR_LIT>""" <EOL> get_image = self . _add_delete_image_tag ( self . add_image_tag_image . id_ ) <EOL> self . assertIn ( <EOL> self . tag , get_image . tags , <EOL> msg = ( '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' ) . format ( self . add_image_tag_image . id_ , self . tag , <EOL> get_image . tags ) ) <EOL> def test_delete_single_image_tag ( self ) : <EOL> """<STR_LIT>""" <EOL> get_image = self . _add_delete_image_tag ( <EOL> self . delete_image_tag_image . id_ , '<STR_LIT>' ) <EOL> self . assertNotIn ( <EOL> self . tag , get_image . tags , <EOL> msg = ( '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' ) . format ( self . delete_image_tag_image . id_ , <EOL> self . tag , get_image . tags ) ) <EOL> def _add_delete_image_tag ( self , image_id , api = '<STR_LIT>' ) : <EOL> """<STR_LIT>""" <EOL> if api . lower ( ) == '<STR_LIT>' : <EOL> resp = self . images . client . delete_image_tag ( image_id , self . tag ) <EOL> elif api . lower ( ) == '<STR_LIT>' : <EOL> resp = self . images . client . add_image_tag ( image_id , self . tag ) <EOL> else : <EOL> self . fail ( '<STR_LIT>' <EOL> '<STR_LIT>' . format ( api ) ) <EOL> self . assertEqual ( <EOL> resp . status_code , <NUM_LIT> , <EOL> Messages . STATUS_CODE_MSG . format ( <NUM_LIT> , resp . status_code ) ) <EOL> resp = self . images . client . get_image_details ( image_id ) <EOL> self . assertTrue ( resp . ok , Messages . OK_RESP_MSG . format ( resp . status_code ) ) <EOL> return resp . entity </s>
