#NEWLINE# @ test . create_stubs ( { #NEWLINE# #INDENT# api . neutron : ( 'network_get' , 'subnet_list' , 'port_list' , 'is_extension_supported' ) , #NEWLINE# quotas : ( 'tenant_quota_usages' , ) , #NEWLINE# #UNINDENT# } ) #NEWLINE# def test_subnet_create_button_disabled_when_quota_exceeded_detail( self ) : #NEWLINE# #INDENT# network_id = self . networks . first ( ) . id #NEWLINE# quota_data = self . quota_usages . first ( ) #NEWLINE# quota_data [ 'subnets' ] [ 'available' ] = 0 #NEWLINE# api . neutron . network_get ( IsA ( http . HttpRequest ) , network_id ) . MultipleTimes ( ) . AndReturn ( self . networks . first ( ) ) #NEWLINE# api . neutron . subnet_list ( IsA ( http . HttpRequest ) , network_id = network_id ) . AndReturn ( self . subnets . list ( ) ) #NEWLINE# api . neutron . port_list ( IsA ( http . HttpRequest ) , network_id = network_id ) . AndReturn ( [ self . ports . first ( ) ] ) #NEWLINE# api . neutron . is_extension_supported ( IsA ( http . HttpRequest ) , 'mac-learning' ) . AndReturn ( False ) #NEWLINE# quotas . tenant_quota_usages ( IsA ( http . HttpRequest ) ) . MultipleTimes ( ) . AndReturn ( quota_data ) #NEWLINE# self . mox . ReplayAll ( ) #NEWLINE# res = self . client . get ( reverse ( 'horizon:project:networks:detail' , args = [ network_id ] ) ) #NEWLINE# self . assertTemplateUsed ( res , 'project/networks/detail.html' ) #NEWLINE# subnets = res . context [ 'subnets_table' ] . data #NEWLINE# self . assertItemsEqual ( subnets , self . subnets . list ( ) ) #NEWLINE# class FakeTable ( ) : #NEWLINE# #INDENT# kwargs = { #NEWLINE# #INDENT# 'network_id' : network_id , #NEWLINE# #UNINDENT# } #NEWLINE# #UNINDENT# create_link = subnets_tables . CreateSubnet ( ) #NEWLINE# create_link . table = FakeTable ( ) #NEWLINE# url = create_link . get_link_url ( ) #NEWLINE# classes = ( list ( create_link . get_default_classes ( ) ) + list ( create_link . classes ) ) #NEWLINE# link_name = ( '%s (%s)' % ( unicode ( create_link . verbose_name ) , 'Quota exceeded' ) ) #NEWLINE# expected_string = ( "<a href='%s' title='%s'  class='%s disabled' id='subnets__action_create'><span class='fa fa-plus'></span>%s</a>" % ( url , link_name , ' ' . join ( classes ) , link_name ) ) #NEWLINE# self . assertContains ( res , expected_string , html = True , msg_prefix = 'The create button is not disabled' )