<s> """<STR_LIT>""" <EOL> import unittest <EOL> from cloudcafe . networking . networks . common . models . request . port import PortRequest <EOL> from cloudcafe . networking . networks . common . models . response . port import Port , Ports <EOL> PORT_TAG = Port . PORT <EOL> PORTS_TAG = Ports . PORTS <EOL> class CreatePortTest ( unittest . TestCase ) : <EOL> """<STR_LIT>""" <EOL> @ classmethod <EOL> def setUpClass ( cls ) : <EOL> create_attrs = dict ( <EOL> network_id = '<STR_LIT>' , <EOL> name = '<STR_LIT>' , admin_state_up = True ) <EOL> cls . subnet_model = PortRequest ( ** create_attrs ) <EOL> create_attrs_all = dict ( <EOL> network_id = '<STR_LIT>' , name = '<STR_LIT>' , admin_state_up = False , <EOL> mac_address = '<STR_LIT>' , fixed_ips = [ { '<STR_LIT>' : <EOL> '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT>' } , <EOL> { '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : <EOL> '<STR_LIT>' } ] , device_id = '<STR_LIT>' , <EOL> device_owner = '<STR_LIT>' , tenant_id = '<STR_LIT>' , <EOL> security_groups = [ [ { '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT>' } , { '<STR_LIT>' : <EOL> '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT>' } ] ] ) <EOL> cls . subnet_model_all = PortRequest ( ** create_attrs_all ) <EOL> def test_json_request ( self ) : <EOL> """<STR_LIT>""" <EOL> expected_json_output = ( <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' ) . format ( <EOL> tag = PORT_TAG ) <EOL> request_body = self . subnet_model . _obj_to_json ( ) <EOL> msg = ( '<STR_LIT>' <EOL> '<STR_LIT>' . format ( expected_json_output , request_body ) ) <EOL> self . assertEqual ( request_body , expected_json_output , msg ) <EOL> def test_json_request_all_attrs ( self ) : <EOL> """<STR_LIT>""" <EOL> expected_json_output = ( <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' ) . format ( tag = PORT_TAG ) <EOL> request_body = self . subnet_model_all . _obj_to_json ( ) <EOL> msg = ( '<STR_LIT>' <EOL> '<STR_LIT>' . format ( expected_json_output , request_body ) ) <EOL> self . assertEqual ( request_body , expected_json_output , msg ) <EOL> class UpdatePortTest ( unittest . TestCase ) : <EOL> """<STR_LIT>""" <EOL> @ classmethod <EOL> def setUpClass ( cls ) : <EOL> update_attrs = dict ( <EOL> name = '<STR_LIT>' , admin_state_up = True , <EOL> fixed_ips = [ { '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : <EOL> '<STR_LIT>' } , { '<STR_LIT>' : <EOL> '<STR_LIT>' , '<STR_LIT>' : <EOL> '<STR_LIT>' } ] , <EOL> device_id = '<STR_LIT>' , device_owner = '<STR_LIT>' , <EOL> security_groups = [ [ { '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : <EOL> '<STR_LIT>' } , { '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : <EOL> '<STR_LIT>' } ] ] ) <EOL> cls . subnet_model = PortRequest ( ** update_attrs ) <EOL> def test_json_request ( self ) : <EOL> """<STR_LIT>""" <EOL> expected_json_output = ( <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' ) . format ( tag = PORT_TAG ) <EOL> request_body = self . subnet_model . _obj_to_json ( ) <EOL> msg = ( '<STR_LIT>' <EOL> '<STR_LIT>' . format ( expected_json_output , request_body ) ) <EOL> self . assertEqual ( request_body , expected_json_output , msg ) <EOL> class ShowPortTest ( unittest . TestCase ) : <EOL> """<STR_LIT>""" <EOL> @ classmethod <EOL> def setUpClass ( cls ) : <EOL> """<STR_LIT>""" <EOL> show_attrs = dict ( <EOL> status = "<STR_LIT>" , name = "<STR_LIT>" , <EOL> allowed_address_pairs = [ ] , admin_state_up = True , <EOL> network_id = "<STR_LIT>" , <EOL> tenant_id = "<STR_LIT>" , <EOL> extra_dhcp_opts = [ ] , <EOL> device_owner = "<STR_LIT>" , <EOL> mac_address = "<STR_LIT>" , <EOL> fixed_ips = [ { "<STR_LIT>" : <EOL> "<STR_LIT>" , "<STR_LIT>" : "<STR_LIT>" } ] , <EOL> id_ = "<STR_LIT>" , security_groups = [ ] , <EOL> device_id = "<STR_LIT>" ) <EOL> cls . expected_response = Port ( ** show_attrs ) <EOL> def test_json_response ( self ) : <EOL> api_json_resp = ( <EOL> """<STR_LIT>""" ) . format ( tag = PORT_TAG ) <EOL> response_obj = Port ( ) . _json_to_obj ( api_json_resp ) <EOL> self . assertEqual ( response_obj , self . expected_response , <EOL> '<STR_LIT>' ) <EOL> class ShowMultiplePortTest ( unittest . TestCase ) : <EOL> """<STR_LIT>""" <EOL> @ classmethod <EOL> def setUpClass ( cls ) : <EOL> """<STR_LIT>""" <EOL> show_attrs_1 = dict ( <EOL> status = '<STR_LIT>' , name = '<STR_LIT>' , admin_state_up = True , <EOL> network_id = '<STR_LIT>' , tenant_id = '<STR_LIT>' , <EOL> mac_address = '<STR_LIT>' , <EOL> device_owner = '<STR_LIT>' , <EOL> fixed_ips = [ { u'<STR_LIT>' : u'<STR_LIT>' , <EOL> u'<STR_LIT>' : u'<STR_LIT>' } ] , <EOL> id_ = '<STR_LIT>' , security_groups = [ ] , <EOL> device_id = '<STR_LIT>' ) <EOL> show_attrs_2 = dict ( <EOL> status = '<STR_LIT>' , name = '<STR_LIT>' , admin_state_up = True , <EOL> network_id = '<STR_LIT>' , <EOL> tenant_id = '<STR_LIT>' , <EOL> mac_address = '<STR_LIT>' , <EOL> device_owner = '<STR_LIT>' , fixed_ips = [ { u'<STR_LIT>' : <EOL> u'<STR_LIT>' , u'<STR_LIT>' : <EOL> u'<STR_LIT>' } ] , id_ = '<STR_LIT>' , <EOL> security_groups = [ ] , <EOL> device_id = '<STR_LIT>' , ) <EOL> sub1 = Port ( ** show_attrs_1 ) <EOL> sub2 = Port ( ** show_attrs_2 ) <EOL> cls . expected_response = [ sub1 , sub2 ] <EOL> def test_json_response ( self ) : <EOL> api_json_resp = ( <EOL> """<STR_LIT>""" ) . format ( tag = PORTS_TAG ) <EOL> response_obj = Ports ( ) . _json_to_obj ( api_json_resp ) <EOL> self . assertEqual ( response_obj , self . expected_response , <EOL> '<STR_LIT>' ) <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> unittest . main ( ) </s>
