<s> """<STR_LIT>""" <EOL> from test_repo . database . fixtures import DBaaSFixture <EOL> class test_usage_retention ( DBaaSFixture ) : <EOL> mgmt_client = None <EOL> @ classmethod <EOL> def setUpClass ( cls ) : <EOL> """<STR_LIT>""" <EOL> super ( test_usage_retention , cls ) . setUpClass ( ) <EOL> cls . mgmt_client = cls . dbaas_provider . mgmt_client . reddwarfclient <EOL> cls . mgmt_client . authenticate ( ) <EOL> @ classmethod <EOL> def tearDownClass ( cls ) : <EOL> """<STR_LIT>""" <EOL> pass <EOL> def test_listusage_all ( self ) : <EOL> listOfRetentionObj = self . mgmt_client . usage . index ( ) . items <EOL> self . assertIsNotNone ( listOfRetentionObj , "<STR_LIT>" ) <EOL> def test_listusage_allwlimit ( self ) : <EOL> lt = <NUM_LIT:50> <EOL> listOfRetentionObj = self . mgmt_client . usage . index ( limit = lt ) . items <EOL> count = <NUM_LIT:0> <EOL> for ro in listOfRetentionObj : <EOL> count += <NUM_LIT:1> <EOL> self . assertEqual ( count , lt , <EOL> "<STR_LIT>" ) <EOL> def test_listusage_instance ( self ) : <EOL> listOfRetentionObj = self . mgmt_client . usage . index ( limit = <NUM_LIT:1> ) . items <EOL> length_of_records = len ( listOfRetentionObj ) <EOL> self . assertEqual ( length_of_records , <NUM_LIT:1> , <EOL> "<STR_LIT>" <EOL> % ( <NUM_LIT:1> , length_of_records ) ) <EOL> retention_record = listOfRetentionObj [ <NUM_LIT:0> ] <EOL> resource_Id = retention_record . resourceId <EOL> self . assertIsNotNone ( resource_Id , "<STR_LIT>" ) <EOL> retention = self . mgmt_client . usage . instance ( resource_Id ) . items <EOL> self . assertIsNotNone ( retention , "<STR_LIT>" ) <EOL> def test_listusage_instance_limit ( self ) : <EOL> listOfRetentionObj = self . mgmt_client . usage . index ( limit = <NUM_LIT:1> ) . items <EOL> length_of_records = len ( listOfRetentionObj ) <EOL> self . assertEqual ( length_of_records , <NUM_LIT:1> , <EOL> "<STR_LIT>" <EOL> % ( <NUM_LIT:1> , length_of_records ) ) <EOL> resource_id = listOfRetentionObj [ <NUM_LIT:0> ] . id <EOL> retention = self . mgmt_client . usage . instance ( resource_id , <EOL> limit = <NUM_LIT:50> ) . items <EOL> self . assertIsNotNone ( retention , "<STR_LIT>" ) <EOL> def test_listusage_user ( self ) : <EOL> listOfRetentionObj = self . mgmt_client . usage . index ( limit = <NUM_LIT:1> ) . items <EOL> length_of_records = len ( listOfRetentionObj ) <EOL> self . assertEqual ( length_of_records , <NUM_LIT:1> , <EOL> "<STR_LIT>" <EOL> % ( <NUM_LIT:1> , length_of_records ) ) <EOL> user = listOfRetentionObj [ <NUM_LIT:0> ] . tenantId <EOL> self . assertIsNotNone ( user , "<STR_LIT>" ) <EOL> retention = self . mgmt_client . usage . account ( user ) . items <EOL> self . assertIsNotNone ( retention , "<STR_LIT>" ) <EOL> def test_listusage_user_limit ( self ) : <EOL> listOfRetentionObj = self . mgmt_client . usage . index ( limit = <NUM_LIT:1> ) . items <EOL> user = listOfRetentionObj [ <NUM_LIT:0> ] . tenantId <EOL> retention = self . mgmt_client . usage . account ( user , limit = <NUM_LIT:50> ) . items <EOL> self . assertIsNotNone ( retention , "<STR_LIT>" ) <EOL> def test_listusage_badlimit ( self ) : <EOL> try : <EOL> self . mgmt_client . usage . index ( limit = - <NUM_LIT:5> ) <EOL> except Exception as e : <EOL> http_code = self . behavior . get_last_response_code ( self . mgmt_client ) <EOL> self . assertEqual ( http_code , '<STR_LIT>' , e . message ) <EOL> def test_listusage_badmarker ( self ) : <EOL> try : <EOL> self . mgmt_client . usage . index ( marker = "<STR_LIT:foo>" ) <EOL> except Exception as e : <EOL> http_code = self . behavior . get_last_response_code ( self . mgmt_client ) <EOL> self . assertEqual ( http_code , '<STR_LIT>' , e . message ) </s>
