<s> """<STR_LIT>""" <EOL> import ast <EOL> import unittest <EOL> from uuid import uuid4 <EOL> from cloudcafe . networking . networks . extensions . floating_ips . constants import FloatingIPStates <EOL> from cloudcafe . networking . networks . extensions . floating_ips . models . request import FloatingIPRequest , FloatingIPUpdate <EOL> from cloudcafe . networking . networks . extensions . floating_ips . models . response import FloatingIPInfo , FloatingIPInfoList <EOL> class CreateFloatingIPAssociation ( unittest . TestCase ) : <EOL> """<STR_LIT>""" <EOL> @ classmethod <EOL> def setUpClass ( cls ) : <EOL> tenant_id = uuid4 ( ) . urn [ <NUM_LIT:9> : ] <EOL> floating_network_id = uuid4 ( ) . urn [ <NUM_LIT:9> : ] <EOL> port_id = uuid4 ( ) . urn [ <NUM_LIT:9> : ] <EOL> floating_ip_address = '<STR_LIT>' <EOL> fixed_ip_address = '<STR_LIT>' <EOL> floating_ip_args = { <EOL> '<STR_LIT>' : floating_network_id , <EOL> '<STR_LIT>' : floating_ip_address , <EOL> '<STR_LIT>' : tenant_id , <EOL> '<STR_LIT>' : fixed_ip_address , <EOL> '<STR_LIT>' : port_id , <EOL> } <EOL> cls . floating_ip_obj = FloatingIPRequest ( ** floating_ip_args ) <EOL> cls . expected_json = ( <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' ) . format ( <EOL> root_tag = FloatingIPRequest . ROOT_TAG , ** floating_ip_args ) <EOL> def test_create_request_obj_to_json_translation ( self ) : <EOL> obj_to_json = ast . literal_eval ( <EOL> self . floating_ip_obj . _obj_to_json ( ) ) <EOL> expected_json = ast . literal_eval ( self . expected_json ) <EOL> self . assertEqual ( obj_to_json , expected_json ) <EOL> class UpdateFloatingIPAssociation ( unittest . TestCase ) : <EOL> """<STR_LIT>""" <EOL> @ classmethod <EOL> def setUpClass ( cls ) : <EOL> port_id = uuid4 ( ) . urn [ <NUM_LIT:9> : ] <EOL> floating_ip_args = { '<STR_LIT>' : port_id } <EOL> cls . floating_ip_obj = FloatingIPUpdate ( ** floating_ip_args ) <EOL> cls . expected_json = ( <EOL> '<STR_LIT>' ) . format ( <EOL> root_tag = FloatingIPRequest . ROOT_TAG , ** floating_ip_args ) <EOL> def test_update_request_obj_to_json_translation ( self ) : <EOL> obj_to_json = ast . literal_eval ( self . floating_ip_obj . _obj_to_json ( ) ) <EOL> expected_json = ast . literal_eval ( self . expected_json ) <EOL> self . assertEqual ( obj_to_json , expected_json ) <EOL> class FloatingIPInfoListResponse ( unittest . TestCase ) : <EOL> """<STR_LIT>""" <EOL> MODEL = FloatingIPInfoList <EOL> LIST_ELEMENT_MODEL = FloatingIPInfo <EOL> RESPONSE_FORMAT = '<STR_LIT>' <EOL> NUM_OF_FLIPS = <NUM_LIT:10> <EOL> @ classmethod <EOL> def setUpClass ( cls ) : <EOL> cls . expected_response_obj = [ ] <EOL> cls . json_parts = [ ] <EOL> json_part_format = """<STR_LIT>""" <EOL> for index in xrange ( cls . NUM_OF_FLIPS ) : <EOL> port_id = uuid4 ( ) . urn [ <NUM_LIT:9> : ] <EOL> tenant_id = uuid4 ( ) . urn [ <NUM_LIT:9> : ] <EOL> router_id = uuid4 ( ) . urn [ <NUM_LIT:9> : ] <EOL> floating_network_id = uuid4 ( ) . urn [ <NUM_LIT:9> : ] <EOL> id_ = uuid4 ( ) . urn [ <NUM_LIT:9> : ] <EOL> fixed_ip_address = '<STR_LIT>' <EOL> floating_ip_address = '<STR_LIT>' <EOL> status = FloatingIPStates . ACTIVE <EOL> floating_ip_args = { <EOL> '<STR_LIT>' : tenant_id , '<STR_LIT>' : router_id , '<STR_LIT>' : id_ , <EOL> '<STR_LIT>' : fixed_ip_address , '<STR_LIT:status>' : status , <EOL> '<STR_LIT>' : floating_ip_address , '<STR_LIT>' : port_id , <EOL> '<STR_LIT>' : floating_network_id , <EOL> } <EOL> cls . expected_response_obj . append ( <EOL> cls . LIST_ELEMENT_MODEL ( ** floating_ip_args ) ) <EOL> cls . json_parts . append ( json_part_format . format ( ** floating_ip_args ) ) <EOL> list_body = '<STR_LIT:U+002C>' . join ( cls . json_parts ) <EOL> cls . json_response = '<STR_LIT>' . format ( <EOL> root_tag = cls . MODEL . ROOT_TAG , body = list_body ) <EOL> def test_deserialize_flip_info_list_response_into_obj ( self ) : <EOL> response_obj = self . MODEL . deserialize ( self . json_response , <EOL> self . RESPONSE_FORMAT ) <EOL> self . assertEqual ( response_obj , self . expected_response_obj ) <EOL> class FloatingIPInfoResponse ( unittest . TestCase ) : <EOL> """<STR_LIT>""" <EOL> MODEL = FloatingIPInfo <EOL> RESPONSE_FORMAT = '<STR_LIT>' <EOL> @ classmethod <EOL> def setUpClass ( cls ) : <EOL> port_id = uuid4 ( ) . urn [ <NUM_LIT:9> : ] <EOL> tenant_id = uuid4 ( ) . urn [ <NUM_LIT:9> : ] <EOL> router_id = uuid4 ( ) . urn [ <NUM_LIT:9> : ] <EOL> floating_network_id = uuid4 ( ) . urn [ <NUM_LIT:9> : ] <EOL> id_ = uuid4 ( ) . urn [ <NUM_LIT:9> : ] <EOL> fixed_ip_address = '<STR_LIT>' <EOL> floating_ip_address = '<STR_LIT>' <EOL> status = FloatingIPStates . ACTIVE <EOL> floating_ip_args = { <EOL> '<STR_LIT>' : tenant_id , '<STR_LIT>' : router_id , '<STR_LIT>' : id_ , <EOL> '<STR_LIT>' : fixed_ip_address , '<STR_LIT:status>' : status , <EOL> '<STR_LIT>' : floating_ip_address , '<STR_LIT>' : port_id , <EOL> '<STR_LIT>' : floating_network_id , <EOL> } <EOL> cls . floating_ip_info_obj = cls . MODEL ( ** floating_ip_args ) <EOL> cls . json_response = """<STR_LIT>""" . format ( root_tag = cls . MODEL . ROOT_TAG , ** floating_ip_args ) <EOL> def test_deserialize_flip_info_response_into_obj ( self ) : <EOL> response_obj = FloatingIPInfo . deserialize ( self . json_response , <EOL> self . RESPONSE_FORMAT ) <EOL> self . assertEqual ( response_obj , self . floating_ip_info_obj ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> unittest . main ( ) </s>
