<s> from tempest . lib . common . utils import data_utils <EOL> from tempest import test <EOL> from neutron . tests . tempest . api import base <EOL> class ExtraDHCPOptionsTestJSON ( base . BaseNetworkTest ) : <EOL> """<STR_LIT>""" <EOL> @ classmethod <EOL> @ test . requires_ext ( extension = "<STR_LIT>" , service = "<STR_LIT>" ) <EOL> def resource_setup ( cls ) : <EOL> super ( ExtraDHCPOptionsTestJSON , cls ) . resource_setup ( ) <EOL> cls . network = cls . create_network ( ) <EOL> cls . subnet = cls . create_subnet ( cls . network ) <EOL> cls . port = cls . create_port ( cls . network ) <EOL> cls . ip_tftp = ( '<STR_LIT>' if cls . _ip_version == <NUM_LIT:4> <EOL> else '<STR_LIT>' ) <EOL> cls . ip_server = ( '<STR_LIT>' if cls . _ip_version == <NUM_LIT:4> <EOL> else '<STR_LIT>' ) <EOL> cls . extra_dhcp_opts = [ <EOL> { '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT>' } , <EOL> { '<STR_LIT>' : cls . ip_tftp , '<STR_LIT>' : '<STR_LIT>' } , <EOL> { '<STR_LIT>' : cls . ip_server , '<STR_LIT>' : '<STR_LIT>' } <EOL> ] <EOL> @ test . idempotent_id ( '<STR_LIT>' ) <EOL> def test_create_list_port_with_extra_dhcp_options ( self ) : <EOL> body = self . client . create_port ( <EOL> network_id = self . network [ '<STR_LIT:id>' ] , <EOL> extra_dhcp_opts = self . extra_dhcp_opts ) <EOL> port_id = body [ '<STR_LIT:port>' ] [ '<STR_LIT:id>' ] <EOL> self . addCleanup ( self . client . delete_port , port_id ) <EOL> body = self . client . list_ports ( ) <EOL> ports = body [ '<STR_LIT>' ] <EOL> port = [ p for p in ports if p [ '<STR_LIT:id>' ] == port_id ] <EOL> self . assertTrue ( port ) <EOL> self . _confirm_extra_dhcp_options ( port [ <NUM_LIT:0> ] , self . extra_dhcp_opts ) <EOL> @ test . idempotent_id ( '<STR_LIT>' ) <EOL> def test_update_show_port_with_extra_dhcp_options ( self ) : <EOL> name = data_utils . rand_name ( '<STR_LIT>' ) <EOL> body = self . client . update_port ( <EOL> self . port [ '<STR_LIT:id>' ] , <EOL> name = name , <EOL> extra_dhcp_opts = self . extra_dhcp_opts ) <EOL> body = self . client . show_port ( self . port [ '<STR_LIT:id>' ] ) <EOL> self . _confirm_extra_dhcp_options ( body [ '<STR_LIT:port>' ] , self . extra_dhcp_opts ) <EOL> def _confirm_extra_dhcp_options ( self , port , extra_dhcp_opts ) : <EOL> retrieved = port [ '<STR_LIT>' ] <EOL> self . assertEqual ( len ( retrieved ) , len ( extra_dhcp_opts ) ) <EOL> for retrieved_option in retrieved : <EOL> for option in extra_dhcp_opts : <EOL> if ( retrieved_option [ '<STR_LIT>' ] == option [ '<STR_LIT>' ] and <EOL> retrieved_option [ '<STR_LIT>' ] == option [ '<STR_LIT>' ] ) : <EOL> break <EOL> else : <EOL> self . fail ( '<STR_LIT>' % <EOL> str ( retrieved_option ) ) <EOL> class ExtraDHCPOptionsIpV6TestJSON ( ExtraDHCPOptionsTestJSON ) : <EOL> _ip_version = <NUM_LIT:6> </s>
