#NEWLINE# def _test_usage_csv( self , nova_stu_enabled = True ) : #NEWLINE# #INDENT# now = timezone . now ( ) #NEWLINE# usage_obj = api . nova . NovaUsage ( self . usages . first ( ) ) #NEWLINE# self . _stub_nova_api_calls ( nova_stu_enabled ) #NEWLINE# api . nova . extension_supported ( 'SimpleTenantUsage' , IsA ( http . HttpRequest ) ) . AndReturn ( nova_stu_enabled ) #NEWLINE# start = datetime . datetime ( now . year , now . month , 1 , 0 , 0 , 0 , 0 ) #NEWLINE# end = datetime . datetime ( now . year , now . month , now . day , 23 , 59 , 59 , 0 ) #NEWLINE# if nova_stu_enabled : #NEWLINE# #INDENT# api . nova . usage_get ( IsA ( http . HttpRequest ) , self . tenant . id , start , end ) . AndReturn ( usage_obj ) #NEWLINE# #UNINDENT# api . nova . tenant_absolute_limits ( IsA ( http . HttpRequest ) ) . AndReturn ( self . limits [ 'absolute' ] ) #NEWLINE# api . cinder . tenant_absolute_limits ( IsA ( http . HttpRequest ) ) . AndReturn ( self . cinder_limits [ 'absolute' ] ) #NEWLINE# self . _stub_neutron_api_calls ( ) #NEWLINE# self . mox . ReplayAll ( ) #NEWLINE# project_id = self . tenants . first ( ) . id #NEWLINE# csv_url = ( reverse ( 'horizon:identity:projects:usage' , args = [ project_id ] ) + '?format=csv' ) #NEWLINE# res = self . client . get ( csv_url ) #NEWLINE# self . assertTemplateUsed ( res , 'project/overview/usage.csv' ) #NEWLINE# self . assertTrue ( isinstance ( res . context [ 'usage' ] , usage . ProjectUsage ) ) #NEWLINE# hdr = 'Instance Name,VCPUs,RAM (MB),Disk (GB),Usage (Hours),Uptime (Seconds),State' #NEWLINE# self . assertContains ( res , ( '%s\r\n' % hdr ) )