#NEWLINE# @ test . create_stubs ( { #NEWLINE# #INDENT# api . nova : ( 'usage_list' , 'tenant_absolute_limits' ) , #NEWLINE# api . keystone : ( 'tenant_list' , ) , #NEWLINE# api . neutron : ( 'is_extension_supported' , ) , #NEWLINE# api . network : ( 'tenant_floating_ip_list' , 'security_group_list' ) , #NEWLINE# #UNINDENT# } ) #NEWLINE# def test_usage( self ) : #NEWLINE# #INDENT# now = timezone . now ( ) #NEWLINE# usage_obj = api . nova . NovaUsage ( self . usages . first ( ) ) #NEWLINE# api . keystone . tenant_list ( IsA ( http . HttpRequest ) ) . AndReturn ( [ self . tenants . list ( ) , False ] ) #NEWLINE# api . nova . usage_list ( IsA ( http . HttpRequest ) , datetime . datetime ( now . year , now . month , now . day , 0 , 0 , 0 , 0 ) , datetime . datetime ( now . year , now . month , now . day , 23 , 59 , 59 , 0 ) ) . AndReturn ( [ res ] ) #NEWLINE# api . nova . tenant_absolute_limits ( IsA ( http . HttpRequest ) ) . AndReturn ( self . limits [ 'absolute' ] ) #NEWLINE# api . neutron . is_extension_supported ( IsA ( http . HttpRequest ) , 'security-group' ) . AndReturn ( True ) #NEWLINE# api . network . tenant_floating_ip_list ( IsA ( http . HttpRequest ) ) . AndReturn ( self . floating_ips . list ( ) ) #NEWLINE# api . network . security_group_list ( IsA ( http . HttpRequest ) ) . AndReturn ( self . q_secgroups . list ( ) ) #NEWLINE# self . mox . ReplayAll ( ) #NEWLINE# res = self . client . get ( reverse ( 'horizon:admin:overview:index' ) ) #NEWLINE# self . assertTemplateUsed ( res , 'admin/overview/usage.html' ) #NEWLINE# self . assertTrue ( isinstance ( res . context [ 'usage' ] , usage . GlobalUsage ) ) #NEWLINE# self . assertContains ( res , ( '<td class="sortable normal_column">test_tenant</td><td class="sortable normal_column">%s</td><td class="sortable normal_column">%s</td><td class="sortable normal_column">%s</td><td class="sortable normal_column">%.2f</td><td class="sortable normal_column">%.2f</td>' % ( usage_obj . vcpus , usage_obj . disk_gb_hours , sizeformat . mbformat ( usage_obj . memory_mb ) , usage_obj . vcpu_hours , usage_obj . total_local_gb_usage ) ) )