<s> from neutron import context as n_ctx <EOL> from sqlalchemy . orm import exc as orm_exc <EOL> from gbpservice . neutron . db . grouppolicy . extensions import group_proxy_db <EOL> from gbpservice . neutron . tests . unit . services . grouppolicy import ( <EOL> test_extension_driver_api as test_ext_base ) <EOL> class ExtensionDriverTestCaseMixin ( object ) : <EOL> def test_proxy_group_extension ( self ) : <EOL> l3p = self . create_l3_policy ( ) [ '<STR_LIT>' ] <EOL> self . assertEqual ( '<STR_LIT>' , l3p [ '<STR_LIT>' ] ) <EOL> self . assertEqual ( <NUM_LIT> , l3p [ '<STR_LIT>' ] ) <EOL> l2p = self . create_l2_policy ( l3_policy_id = l3p [ '<STR_LIT:id>' ] ) [ '<STR_LIT>' ] <EOL> ptg = self . create_policy_target_group ( <EOL> l2_policy_id = l2p [ '<STR_LIT:id>' ] ) [ '<STR_LIT>' ] <EOL> self . assertIsNone ( ptg [ '<STR_LIT>' ] ) <EOL> self . assertIsNone ( ptg [ '<STR_LIT>' ] ) <EOL> self . assertIsNone ( ptg [ '<STR_LIT>' ] ) <EOL> l3p = self . show_l3_policy ( l3p [ '<STR_LIT:id>' ] ) [ '<STR_LIT>' ] <EOL> self . assertEqual ( '<STR_LIT>' , l3p [ '<STR_LIT>' ] ) <EOL> self . assertEqual ( <NUM_LIT> , l3p [ '<STR_LIT>' ] ) <EOL> ptg_proxy = self . create_policy_target_group ( <EOL> proxied_group_id = ptg [ '<STR_LIT:id>' ] ) [ '<STR_LIT>' ] <EOL> self . assertIsNone ( ptg_proxy [ '<STR_LIT>' ] ) <EOL> self . assertEqual ( ptg [ '<STR_LIT:id>' ] , ptg_proxy [ '<STR_LIT>' ] ) <EOL> self . assertEqual ( '<STR_LIT>' , ptg_proxy [ '<STR_LIT>' ] ) <EOL> ptg = self . show_policy_target_group ( ptg [ '<STR_LIT:id>' ] ) [ '<STR_LIT>' ] <EOL> self . assertEqual ( ptg_proxy [ '<STR_LIT:id>' ] , ptg [ '<STR_LIT>' ] ) <EOL> self . assertIsNone ( ptg [ '<STR_LIT>' ] ) <EOL> pt = self . create_policy_target ( <EOL> policy_target_group_id = ptg_proxy [ '<STR_LIT:id>' ] ) [ '<STR_LIT>' ] <EOL> self . assertFalse ( pt [ '<STR_LIT>' ] ) <EOL> self . assertFalse ( pt [ '<STR_LIT>' ] ) <EOL> pt = self . create_policy_target ( <EOL> policy_target_group_id = ptg_proxy [ '<STR_LIT:id>' ] , <EOL> proxy_gateway = True , group_default_gateway = True ) [ '<STR_LIT>' ] <EOL> self . assertTrue ( pt [ '<STR_LIT>' ] ) <EOL> self . assertTrue ( pt [ '<STR_LIT>' ] ) <EOL> pt = self . show_policy_target ( pt [ '<STR_LIT:id>' ] ) [ '<STR_LIT>' ] <EOL> self . assertTrue ( pt [ '<STR_LIT>' ] ) <EOL> self . assertTrue ( pt [ '<STR_LIT>' ] ) <EOL> def test_preexisting_pt ( self ) : <EOL> ptg = self . create_policy_target_group ( ) [ '<STR_LIT>' ] <EOL> pt = self . create_policy_target ( <EOL> policy_target_group_id = ptg [ '<STR_LIT:id>' ] ) [ '<STR_LIT>' ] <EOL> self . assertTrue ( '<STR_LIT>' in pt ) <EOL> self . assertTrue ( '<STR_LIT>' in pt ) <EOL> admin_context = n_ctx . get_admin_context ( ) <EOL> mapping = admin_context . session . query ( <EOL> group_proxy_db . ProxyGatewayMapping ) . filter_by ( <EOL> policy_target_id = pt [ '<STR_LIT:id>' ] ) . one ( ) <EOL> admin_context . session . delete ( mapping ) <EOL> query = admin_context . session . query ( <EOL> group_proxy_db . ProxyGatewayMapping ) . filter_by ( <EOL> policy_target_id = pt [ '<STR_LIT:id>' ] ) <EOL> self . assertRaises ( orm_exc . NoResultFound , query . one ) <EOL> pt = self . show_policy_target ( pt [ '<STR_LIT:id>' ] , <EOL> expected_res_status = <NUM_LIT:200> ) [ '<STR_LIT>' ] <EOL> self . assertFalse ( '<STR_LIT>' in pt ) <EOL> self . assertFalse ( '<STR_LIT>' in pt ) <EOL> pt = self . update_policy_target ( <EOL> pt [ '<STR_LIT:id>' ] , name = '<STR_LIT>' , <EOL> expected_res_status = <NUM_LIT:200> ) [ '<STR_LIT>' ] <EOL> self . assertEqual ( '<STR_LIT>' , pt [ '<STR_LIT:name>' ] ) <EOL> self . assertFalse ( '<STR_LIT>' in pt ) <EOL> self . assertFalse ( '<STR_LIT>' in pt ) <EOL> def test_proxy_group_multiple_proxies ( self ) : <EOL> ptg = self . create_policy_target_group ( ) [ '<STR_LIT>' ] <EOL> self . create_policy_target_group ( proxied_group_id = ptg [ '<STR_LIT:id>' ] ) <EOL> res = self . create_policy_target_group ( proxied_group_id = ptg [ '<STR_LIT:id>' ] , <EOL> expected_res_status = <NUM_LIT> ) <EOL> self . assertEqual ( '<STR_LIT>' , res [ '<STR_LIT>' ] [ '<STR_LIT:type>' ] ) <EOL> def test_proxy_group_chain_proxy ( self ) : <EOL> ptg0 = self . create_policy_target_group ( ) [ '<STR_LIT>' ] <EOL> ptg1 = self . create_policy_target_group ( <EOL> proxied_group_id = ptg0 [ '<STR_LIT:id>' ] , <EOL> expected_res_status = <NUM_LIT> ) [ '<STR_LIT>' ] <EOL> self . create_policy_target_group ( proxied_group_id = ptg1 [ '<STR_LIT:id>' ] , <EOL> expected_res_status = <NUM_LIT> ) <EOL> def test_proxy_group_no_update ( self ) : <EOL> ptg0 = self . create_policy_target_group ( ) [ '<STR_LIT>' ] <EOL> ptg1 = self . create_policy_target_group ( ) [ '<STR_LIT>' ] <EOL> ptg_proxy = self . create_policy_target_group ( <EOL> proxied_group_id = ptg0 [ '<STR_LIT:id>' ] ) [ '<STR_LIT>' ] <EOL> self . update_policy_target_group ( <EOL> ptg_proxy [ '<STR_LIT:id>' ] , proxied_group_id = ptg1 [ '<STR_LIT:id>' ] , <EOL> expected_res_status = <NUM_LIT> ) <EOL> def test_different_proxy_type ( self ) : <EOL> ptg = self . create_policy_target_group ( ) [ '<STR_LIT>' ] <EOL> ptg_proxy = self . create_policy_target_group ( <EOL> proxied_group_id = ptg [ '<STR_LIT:id>' ] , proxy_type = '<STR_LIT>' ) [ '<STR_LIT>' ] <EOL> self . assertEqual ( '<STR_LIT>' , ptg_proxy [ '<STR_LIT>' ] ) <EOL> ptg_proxy = self . show_policy_target_group ( <EOL> ptg_proxy [ '<STR_LIT:id>' ] ) [ '<STR_LIT>' ] <EOL> self . assertEqual ( '<STR_LIT>' , ptg_proxy [ '<STR_LIT>' ] ) <EOL> def test_proxy_type_fails ( self ) : <EOL> ptg = self . create_policy_target_group ( ) [ '<STR_LIT>' ] <EOL> res = self . create_policy_target_group ( proxy_type = '<STR_LIT>' , <EOL> expected_res_status = <NUM_LIT> ) <EOL> self . assertEqual ( '<STR_LIT>' , <EOL> res [ '<STR_LIT>' ] [ '<STR_LIT:type>' ] ) <EOL> self . create_policy_target_group ( proxied_group_id = ptg [ '<STR_LIT:id>' ] , <EOL> proxy_type = '<STR_LIT>' , <EOL> expected_res_status = <NUM_LIT> ) <EOL> def test_proxy_gateway_no_proxy ( self ) : <EOL> ptg = self . create_policy_target_group ( ) [ '<STR_LIT>' ] <EOL> res = self . create_policy_target ( <EOL> policy_target_group_id = ptg [ '<STR_LIT:id>' ] , proxy_gateway = True , <EOL> expected_res_status = <NUM_LIT> ) <EOL> self . assertEqual ( '<STR_LIT>' , <EOL> res [ '<STR_LIT>' ] [ '<STR_LIT:type>' ] ) <EOL> def test_proxy_pool_invalid_prefix_length ( self ) : <EOL> l3p = self . create_l3_policy ( proxy_subnet_prefix_length = <NUM_LIT> ) [ '<STR_LIT>' ] <EOL> res = self . update_l3_policy ( l3p [ '<STR_LIT:id>' ] , proxy_subnet_prefix_length = <NUM_LIT:32> , <EOL> expected_res_status = <NUM_LIT> ) <EOL> self . assertEqual ( '<STR_LIT>' , <EOL> res [ '<STR_LIT>' ] [ '<STR_LIT:type>' ] ) <EOL> l3p = self . show_l3_policy ( l3p [ '<STR_LIT:id>' ] ) [ '<STR_LIT>' ] <EOL> self . assertEqual ( <NUM_LIT> , l3p [ '<STR_LIT>' ] ) <EOL> res = self . create_l3_policy ( <EOL> proxy_subnet_prefix_length = <NUM_LIT:32> , expected_res_status = <NUM_LIT> ) <EOL> self . assertEqual ( '<STR_LIT>' , <EOL> res [ '<STR_LIT>' ] [ '<STR_LIT:type>' ] ) <EOL> def test_proxy_pool_invalid_version ( self ) : <EOL> res = self . create_l3_policy ( ip_version = <NUM_LIT:6> , ip_pool = '<STR_LIT>' , <EOL> proxy_ip_pool = '<STR_LIT>' , <EOL> expected_res_status = <NUM_LIT> ) <EOL> self . assertEqual ( '<STR_LIT>' , res [ '<STR_LIT>' ] [ '<STR_LIT:type>' ] ) <EOL> class ExtensionDriverTestCase ( test_ext_base . ExtensionDriverTestBase , <EOL> ExtensionDriverTestCaseMixin ) : <EOL> _extension_drivers = [ '<STR_LIT>' ] <EOL> _extension_path = None </s>
