<s> import uuid <EOL> from gnocchiclient . tests . functional import base <EOL> from gnocchiclient import utils <EOL> class ResourceClientTest ( base . ClientTestBase ) : <EOL> RESOURCE_ID = str ( uuid . uuid4 ( ) ) <EOL> RAW_RESOURCE_ID2 = str ( uuid . uuid4 ( ) ) + "<STR_LIT>" <EOL> RESOURCE_ID2 = utils . encode_resource_id ( RAW_RESOURCE_ID2 ) <EOL> PROJECT_ID = str ( uuid . uuid4 ( ) ) <EOL> def test_help ( self ) : <EOL> self . gnocchi ( "<STR_LIT>" , params = "<STR_LIT>" ) <EOL> self . gnocchi ( "<STR_LIT>" , params = "<STR_LIT>" ) <EOL> self . gnocchi ( "<STR_LIT>" , params = "<STR_LIT>" ) <EOL> def test_resource_scenario ( self ) : <EOL> apname = str ( uuid . uuid4 ( ) ) <EOL> self . gnocchi ( <EOL> u'<STR_LIT>' , params = u"<STR_LIT>" <EOL> u"<STR_LIT>" % apname ) <EOL> result = self . gnocchi ( <EOL> u'<STR_LIT>' , params = u"<STR_LIT>" % <EOL> self . RESOURCE_ID ) <EOL> resource = self . details_multiple ( result ) [ <NUM_LIT:0> ] <EOL> self . assertEqual ( self . RESOURCE_ID , resource [ "<STR_LIT:id>" ] ) <EOL> self . assertEqual ( '<STR_LIT:None>' , resource [ "<STR_LIT>" ] ) <EOL> self . assertNotEqual ( '<STR_LIT:None>' , resource [ "<STR_LIT>" ] ) <EOL> result = self . gnocchi ( '<STR_LIT>' , <EOL> params = "<STR_LIT>" % <EOL> self . RESOURCE_ID , <EOL> fail_ok = True , merge_stderr = True ) <EOL> self . assertFirstLineStartsWith ( <EOL> result . split ( '<STR_LIT:\n>' ) , <EOL> "<STR_LIT>" % self . RESOURCE_ID ) <EOL> result = self . gnocchi ( <EOL> '<STR_LIT>' , params = ( "<STR_LIT>" <EOL> "<STR_LIT>" % <EOL> ( self . RESOURCE_ID , self . PROJECT_ID , apname ) ) ) <EOL> resource_updated = self . details_multiple ( result ) [ <NUM_LIT:0> ] <EOL> self . assertEqual ( self . RESOURCE_ID , resource_updated [ "<STR_LIT:id>" ] ) <EOL> self . assertEqual ( self . PROJECT_ID , resource_updated [ "<STR_LIT>" ] ) <EOL> self . assertEqual ( resource [ "<STR_LIT>" ] , <EOL> resource_updated [ "<STR_LIT>" ] ) <EOL> self . assertIn ( "<STR_LIT>" , resource_updated [ "<STR_LIT>" ] ) <EOL> result = self . gnocchi ( <EOL> '<STR_LIT>' , params = "<STR_LIT>" % self . RESOURCE_ID ) <EOL> resource_got = self . details_multiple ( result ) [ <NUM_LIT:0> ] <EOL> self . assertEqual ( self . RESOURCE_ID , resource_got [ "<STR_LIT:id>" ] ) <EOL> self . assertEqual ( self . PROJECT_ID , resource_got [ "<STR_LIT>" ] ) <EOL> self . assertEqual ( resource [ "<STR_LIT>" ] , resource_got [ "<STR_LIT>" ] ) <EOL> self . assertIn ( "<STR_LIT>" , resource_got [ "<STR_LIT>" ] ) <EOL> result = self . gnocchi ( <EOL> '<STR_LIT>' , params = "<STR_LIT>" % self . RESOURCE_ID ) <EOL> resource_history = self . parser . listing ( result ) <EOL> self . assertEqual ( <NUM_LIT:2> , len ( resource_history ) ) <EOL> self . assertEqual ( self . RESOURCE_ID , resource_history [ <NUM_LIT:0> ] [ "<STR_LIT:id>" ] ) <EOL> self . assertEqual ( self . RESOURCE_ID , resource_history [ <NUM_LIT:1> ] [ "<STR_LIT:id>" ] ) <EOL> self . assertEqual ( "<STR_LIT:None>" , resource_history [ <NUM_LIT:0> ] [ "<STR_LIT>" ] ) <EOL> self . assertEqual ( self . PROJECT_ID , resource_history [ <NUM_LIT:1> ] [ "<STR_LIT>" ] ) <EOL> result = self . gnocchi ( '<STR_LIT>' , params = "<STR_LIT>" ) <EOL> self . assertIn ( self . RESOURCE_ID , <EOL> [ r [ '<STR_LIT:id>' ] for r in self . parser . listing ( result ) ] ) <EOL> resource_list = [ r for r in self . parser . listing ( result ) <EOL> if r [ '<STR_LIT:id>' ] == self . RESOURCE_ID ] [ <NUM_LIT:0> ] <EOL> self . assertEqual ( self . RESOURCE_ID , resource_list [ "<STR_LIT:id>" ] ) <EOL> self . assertEqual ( self . PROJECT_ID , resource_list [ "<STR_LIT>" ] ) <EOL> self . assertEqual ( resource [ "<STR_LIT>" ] , resource_list [ "<STR_LIT>" ] ) <EOL> result = self . gnocchi ( '<STR_LIT>' , <EOL> params = ( "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> ) % self . PROJECT_ID ) <EOL> resource_list = self . parser . listing ( result ) [ <NUM_LIT:0> ] <EOL> self . assertEqual ( self . RESOURCE_ID , resource_list [ "<STR_LIT:id>" ] ) <EOL> self . assertEqual ( self . PROJECT_ID , resource_list [ "<STR_LIT>" ] ) <EOL> self . assertEqual ( resource [ "<STR_LIT>" ] , resource_list [ "<STR_LIT>" ] ) <EOL> result = self . gnocchi ( <EOL> '<STR_LIT>' , params = ( "<STR_LIT>" <EOL> "<STR_LIT>" % <EOL> ( self . RESOURCE_ID , self . PROJECT_ID ) ) ) <EOL> resource_updated = self . details_multiple ( result ) [ <NUM_LIT:0> ] <EOL> self . assertNotIn ( "<STR_LIT>" , resource_updated [ "<STR_LIT>" ] ) <EOL> result = self . gnocchi ( <EOL> '<STR_LIT>' , params = ( "<STR_LIT>" % self . RESOURCE_ID ) , <EOL> fail_ok = True , merge_stderr = True ) <EOL> self . assertFirstLineStartsWith ( <EOL> result . split ( '<STR_LIT:\n>' ) , <EOL> "<STR_LIT>" ) <EOL> result = self . gnocchi ( <EOL> '<STR_LIT>' , params = ( "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> ) % ( self . RAW_RESOURCE_ID2 , self . PROJECT_ID ) ) <EOL> resource2 = self . details_multiple ( result ) [ <NUM_LIT:0> ] <EOL> self . assertEqual ( self . RESOURCE_ID2 , resource2 [ "<STR_LIT:id>" ] ) <EOL> self . assertEqual ( self . RAW_RESOURCE_ID2 , <EOL> resource2 [ "<STR_LIT>" ] ) <EOL> self . assertEqual ( self . PROJECT_ID , resource2 [ "<STR_LIT>" ] ) <EOL> self . assertNotEqual ( '<STR_LIT:None>' , resource2 [ "<STR_LIT>" ] ) <EOL> result = self . gnocchi ( '<STR_LIT>' , <EOL> params = ( "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> ) % ( self . PROJECT_ID , self . RESOURCE_ID ) ) <EOL> resource_limit = self . parser . listing ( result ) [ <NUM_LIT:0> ] <EOL> self . assertEqual ( self . RESOURCE_ID2 , resource_limit [ "<STR_LIT:id>" ] ) <EOL> self . assertEqual ( self . PROJECT_ID , resource_limit [ "<STR_LIT>" ] ) <EOL> self . assertEqual ( resource2 [ "<STR_LIT>" ] , resource_limit [ "<STR_LIT>" ] ) <EOL> result = self . gnocchi ( '<STR_LIT>' , <EOL> params = "<STR_LIT>" % self . RESOURCE_ID ) <EOL> self . assertEqual ( "<STR_LIT>" , result ) <EOL> result = self . gnocchi ( '<STR_LIT>' , <EOL> params = "<STR_LIT>" % self . RESOURCE_ID2 ) <EOL> self . assertEqual ( "<STR_LIT>" , result ) <EOL> result = self . gnocchi ( '<STR_LIT>' , <EOL> params = "<STR_LIT>" % <EOL> self . RESOURCE_ID , <EOL> fail_ok = True , merge_stderr = True ) <EOL> self . assertFirstLineStartsWith ( <EOL> result . split ( '<STR_LIT:\n>' ) , <EOL> "<STR_LIT>" % self . RESOURCE_ID ) <EOL> result = self . gnocchi ( '<STR_LIT>' , <EOL> params = "<STR_LIT>" % self . RESOURCE_ID , <EOL> fail_ok = True , merge_stderr = True ) <EOL> self . assertFirstLineStartsWith ( <EOL> result . split ( '<STR_LIT:\n>' ) , <EOL> "<STR_LIT>" % self . RESOURCE_ID ) <EOL> result = self . gnocchi ( '<STR_LIT>' , params = "<STR_LIT>" ) <EOL> resource_ids = [ r [ '<STR_LIT:id>' ] for r in self . parser . listing ( result ) ] <EOL> self . assertNotIn ( self . RESOURCE_ID , resource_ids ) <EOL> self . assertNotIn ( self . RESOURCE_ID2 , resource_ids ) <EOL> result = self . gnocchi ( <EOL> '<STR_LIT>' , params = "<STR_LIT>" ) <EOL> r = self . parser . listing ( result ) <EOL> self . assertIn ( { <EOL> '<STR_LIT>' : <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' <EOL> } , r ) </s>
