<s> import mock <EOL> import testtools <EOL> from openstack . network . v2 import router <EOL> IDENTIFIER = '<STR_LIT>' <EOL> EXAMPLE = { <EOL> '<STR_LIT>' : True , <EOL> '<STR_LIT>' : { '<STR_LIT:2>' : '<STR_LIT:3>' } , <EOL> '<STR_LIT:id>' : IDENTIFIER , <EOL> '<STR_LIT:name>' : '<STR_LIT:4>' , <EOL> '<STR_LIT>' : '<STR_LIT:5>' , <EOL> '<STR_LIT:status>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : [ ] , <EOL> '<STR_LIT>' : [ ] , <EOL> '<STR_LIT>' : [ ] , <EOL> '<STR_LIT:description>' : '<STR_LIT>' , <EOL> } <EOL> EXAMPLE_WITH_OPTIONAL = { <EOL> '<STR_LIT>' : False , <EOL> '<STR_LIT>' : { '<STR_LIT>' : '<STR_LIT:1>' , <EOL> '<STR_LIT>' : True , <EOL> '<STR_LIT>' : [ ] } , <EOL> '<STR_LIT:id>' : IDENTIFIER , <EOL> '<STR_LIT:name>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT:2>' , <EOL> '<STR_LIT:status>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : [ { '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT>' } ] , <EOL> '<STR_LIT>' : True , <EOL> '<STR_LIT>' : True , <EOL> '<STR_LIT>' : [ '<STR_LIT>' , '<STR_LIT>' ] , <EOL> '<STR_LIT>' : [ '<STR_LIT>' ] , <EOL> '<STR_LIT:description>' : '<STR_LIT:description>' , <EOL> } <EOL> class TestRouter ( testtools . TestCase ) : <EOL> def test_basic ( self ) : <EOL> sot = router . Router ( ) <EOL> self . assertEqual ( '<STR_LIT>' , sot . resource_key ) <EOL> self . assertEqual ( '<STR_LIT>' , sot . resources_key ) <EOL> self . assertEqual ( '<STR_LIT>' , sot . base_path ) <EOL> self . assertEqual ( '<STR_LIT>' , sot . service . service_type ) <EOL> self . assertTrue ( sot . allow_create ) <EOL> self . assertTrue ( sot . allow_retrieve ) <EOL> self . assertTrue ( sot . allow_update ) <EOL> self . assertTrue ( sot . allow_delete ) <EOL> self . assertTrue ( sot . allow_list ) <EOL> def test_make_it ( self ) : <EOL> sot = router . Router ( EXAMPLE ) <EOL> self . assertTrue ( sot . is_admin_state_up ) <EOL> self . assertEqual ( EXAMPLE [ '<STR_LIT>' ] , <EOL> sot . external_gateway_info ) <EOL> self . assertEqual ( EXAMPLE [ '<STR_LIT:id>' ] , sot . id ) <EOL> self . assertEqual ( EXAMPLE [ '<STR_LIT:name>' ] , sot . name ) <EOL> self . assertEqual ( EXAMPLE [ '<STR_LIT>' ] , sot . project_id ) <EOL> self . assertEqual ( EXAMPLE [ '<STR_LIT:status>' ] , sot . status ) <EOL> self . assertFalse ( sot . is_ha ) <EOL> self . assertFalse ( sot . is_distributed ) <EOL> self . assertEqual ( EXAMPLE [ '<STR_LIT>' ] , sot . routes ) <EOL> self . assertEqual ( EXAMPLE [ '<STR_LIT>' ] , <EOL> sot . availability_zone_hints ) <EOL> self . assertEqual ( EXAMPLE [ '<STR_LIT>' ] , <EOL> sot . availability_zones ) <EOL> self . assertEqual ( EXAMPLE [ '<STR_LIT:description>' ] , sot . description ) <EOL> def test_make_it_with_optional ( self ) : <EOL> sot = router . Router ( EXAMPLE_WITH_OPTIONAL ) <EOL> self . assertFalse ( sot . is_admin_state_up ) <EOL> self . assertEqual ( EXAMPLE_WITH_OPTIONAL [ '<STR_LIT>' ] , <EOL> sot . external_gateway_info ) <EOL> self . assertEqual ( EXAMPLE_WITH_OPTIONAL [ '<STR_LIT:id>' ] , sot . id ) <EOL> self . assertEqual ( EXAMPLE_WITH_OPTIONAL [ '<STR_LIT:name>' ] , sot . name ) <EOL> self . assertEqual ( EXAMPLE_WITH_OPTIONAL [ '<STR_LIT>' ] , sot . project_id ) <EOL> self . assertEqual ( EXAMPLE_WITH_OPTIONAL [ '<STR_LIT:status>' ] , sot . status ) <EOL> self . assertTrue ( sot . is_ha ) <EOL> self . assertTrue ( sot . is_distributed ) <EOL> self . assertEqual ( EXAMPLE_WITH_OPTIONAL [ '<STR_LIT>' ] , sot . routes ) <EOL> self . assertEqual ( EXAMPLE_WITH_OPTIONAL [ '<STR_LIT>' ] , <EOL> sot . availability_zone_hints ) <EOL> self . assertEqual ( EXAMPLE_WITH_OPTIONAL [ '<STR_LIT>' ] , <EOL> sot . availability_zones ) <EOL> self . assertEqual ( EXAMPLE_WITH_OPTIONAL [ '<STR_LIT:description>' ] , <EOL> sot . description ) <EOL> def test_add_interface_subnet ( self ) : <EOL> sot = router . Router ( EXAMPLE ) <EOL> response = mock . Mock ( ) <EOL> response . body = { "<STR_LIT>" : "<STR_LIT:3>" , "<STR_LIT>" : "<STR_LIT:2>" } <EOL> response . json = mock . Mock ( return_value = response . body ) <EOL> sess = mock . Mock ( ) <EOL> sess . put = mock . Mock ( return_value = response ) <EOL> body = { "<STR_LIT>" : "<STR_LIT:3>" } <EOL> self . assertEqual ( response . body , sot . add_interface ( sess , ** body ) ) <EOL> url = '<STR_LIT>' <EOL> sess . put . assert_called_with ( url , endpoint_filter = sot . service , <EOL> json = body ) <EOL> def test_add_interface_port ( self ) : <EOL> sot = router . Router ( EXAMPLE ) <EOL> response = mock . Mock ( ) <EOL> response . body = { "<STR_LIT>" : "<STR_LIT:3>" , "<STR_LIT>" : "<STR_LIT:3>" } <EOL> response . json = mock . Mock ( return_value = response . body ) <EOL> sess = mock . Mock ( ) <EOL> sess . put = mock . Mock ( return_value = response ) <EOL> body = { "<STR_LIT>" : "<STR_LIT:3>" } <EOL> self . assertEqual ( response . body , sot . add_interface ( sess , ** body ) ) <EOL> url = '<STR_LIT>' <EOL> sess . put . assert_called_with ( url , endpoint_filter = sot . service , <EOL> json = body ) <EOL> def test_remove_interface_subnet ( self ) : <EOL> sot = router . Router ( EXAMPLE ) <EOL> response = mock . Mock ( ) <EOL> response . body = { "<STR_LIT>" : "<STR_LIT:3>" , "<STR_LIT>" : "<STR_LIT:2>" } <EOL> response . json = mock . Mock ( return_value = response . body ) <EOL> sess = mock . Mock ( ) <EOL> sess . put = mock . Mock ( return_value = response ) <EOL> body = { "<STR_LIT>" : "<STR_LIT:3>" } <EOL> self . assertEqual ( response . body , sot . remove_interface ( sess , ** body ) ) <EOL> url = '<STR_LIT>' <EOL> sess . put . assert_called_with ( url , endpoint_filter = sot . service , <EOL> json = body ) <EOL> def test_remove_interface_port ( self ) : <EOL> sot = router . Router ( EXAMPLE ) <EOL> response = mock . Mock ( ) <EOL> response . body = { "<STR_LIT>" : "<STR_LIT:3>" , "<STR_LIT>" : "<STR_LIT:3>" } <EOL> response . json = mock . Mock ( return_value = response . body ) <EOL> sess = mock . Mock ( ) <EOL> sess . put = mock . Mock ( return_value = response ) <EOL> body = { "<STR_LIT>" : "<STR_LIT:3>" } <EOL> self . assertEqual ( response . body , sot . remove_interface ( sess , ** body ) ) <EOL> url = '<STR_LIT>' <EOL> sess . put . assert_called_with ( url , endpoint_filter = sot . service , <EOL> json = body ) </s>
