<s> """<STR_LIT>""" <EOL> import shade <EOL> from shade . tests . functional import base <EOL> class TestGroup ( base . BaseFunctionalTestCase ) : <EOL> def setUp ( self ) : <EOL> super ( TestGroup , self ) . setUp ( ) <EOL> i_ver = self . operator_cloud . cloud_config . get_api_version ( '<STR_LIT>' ) <EOL> if i_ver in ( '<STR_LIT:2>' , '<STR_LIT>' ) : <EOL> self . skipTest ( '<STR_LIT>' ) <EOL> self . group_prefix = self . getUniqueString ( '<STR_LIT>' ) <EOL> self . addCleanup ( self . _cleanup_groups ) <EOL> def _cleanup_groups ( self ) : <EOL> exception_list = list ( ) <EOL> for group in self . operator_cloud . list_groups ( ) : <EOL> if group [ '<STR_LIT:name>' ] . startswith ( self . group_prefix ) : <EOL> try : <EOL> self . operator_cloud . delete_group ( group [ '<STR_LIT:id>' ] ) <EOL> except Exception as e : <EOL> exception_list . append ( str ( e ) ) <EOL> continue <EOL> if exception_list : <EOL> raise shade . OpenStackCloudException ( '<STR_LIT:\n>' . join ( exception_list ) ) <EOL> def test_create_group ( self ) : <EOL> group_name = self . group_prefix + '<STR_LIT>' <EOL> group = self . operator_cloud . create_group ( group_name , '<STR_LIT>' ) <EOL> for key in ( '<STR_LIT:id>' , '<STR_LIT:name>' , '<STR_LIT:description>' , '<STR_LIT>' ) : <EOL> self . assertIn ( key , group ) <EOL> self . assertEqual ( group_name , group [ '<STR_LIT:name>' ] ) <EOL> self . assertEqual ( '<STR_LIT>' , group [ '<STR_LIT:description>' ] ) <EOL> def test_delete_group ( self ) : <EOL> group_name = self . group_prefix + '<STR_LIT>' <EOL> group = self . operator_cloud . create_group ( group_name , '<STR_LIT>' ) <EOL> self . assertIsNotNone ( group ) <EOL> self . assertTrue ( self . operator_cloud . delete_group ( group_name ) ) <EOL> results = self . operator_cloud . search_groups ( <EOL> filters = dict ( name = group_name ) ) <EOL> self . assertEqual ( <NUM_LIT:0> , len ( results ) ) <EOL> def test_delete_group_not_exists ( self ) : <EOL> self . assertFalse ( self . operator_cloud . delete_group ( '<STR_LIT>' ) ) <EOL> def test_search_groups ( self ) : <EOL> group_name = self . group_prefix + '<STR_LIT>' <EOL> results = self . operator_cloud . search_groups ( <EOL> filters = dict ( name = group_name ) ) <EOL> self . assertEqual ( <NUM_LIT:0> , len ( results ) ) <EOL> group = self . operator_cloud . create_group ( group_name , '<STR_LIT>' ) <EOL> self . assertEqual ( group_name , group [ '<STR_LIT:name>' ] ) <EOL> results = self . operator_cloud . search_groups ( <EOL> filters = dict ( name = group_name ) ) <EOL> self . assertEqual ( <NUM_LIT:1> , len ( results ) ) <EOL> self . assertEqual ( group_name , results [ <NUM_LIT:0> ] [ '<STR_LIT:name>' ] ) <EOL> def test_update_group ( self ) : <EOL> group_name = self . group_prefix + '<STR_LIT>' <EOL> group_desc = '<STR_LIT>' <EOL> group = self . operator_cloud . create_group ( group_name , group_desc ) <EOL> self . assertEqual ( group_name , group [ '<STR_LIT:name>' ] ) <EOL> self . assertEqual ( group_desc , group [ '<STR_LIT:description>' ] ) <EOL> updated_group_name = group_name + '<STR_LIT>' <EOL> updated_group_desc = group_desc + '<STR_LIT>' <EOL> updated_group = self . operator_cloud . update_group ( <EOL> group_name , <EOL> name = updated_group_name , <EOL> description = updated_group_desc ) <EOL> self . assertEqual ( updated_group_name , updated_group [ '<STR_LIT:name>' ] ) <EOL> self . assertEqual ( updated_group_desc , updated_group [ '<STR_LIT:description>' ] ) </s>
