<s> import sys <EOL> import mock <EOL> from oslo_config import cfg <EOL> from neutron . _i18n import _ <EOL> from neutron . agent . l3 import agent <EOL> from neutron . agent . l3 import namespaces <EOL> from neutron . agent import l3_agent <EOL> class L3NATAgentForTest ( agent . L3NATAgentWithStateReport ) : <EOL> def __init__ ( self , host , conf = None ) : <EOL> ns_suffix = '<STR_LIT>' % cfg . CONF . test_namespace_suffix <EOL> orig_build_ns_name = namespaces . build_ns_name <EOL> def build_ns_name ( prefix , identifier ) : <EOL> return "<STR_LIT>" % ( orig_build_ns_name ( prefix , identifier ) , ns_suffix ) <EOL> build_ns = mock . patch . object ( namespaces , '<STR_LIT>' ) . start ( ) <EOL> build_ns . side_effect = build_ns_name <EOL> orig_get_prefix = namespaces . get_prefix_from_ns_name <EOL> def get_prefix_from_ns_name ( ns_name ) : <EOL> if ns_name . endswith ( ns_suffix ) : <EOL> return orig_get_prefix ( ns_name [ : - len ( ns_suffix ) ] ) <EOL> parse_prefix = mock . patch . object ( namespaces , <EOL> '<STR_LIT>' ) . start ( ) <EOL> parse_prefix . side_effect = get_prefix_from_ns_name <EOL> orig_get_id = namespaces . get_id_from_ns_name <EOL> def get_id_from_ns_name ( ns_name ) : <EOL> if ns_name . endswith ( ns_suffix ) : <EOL> return orig_get_id ( ns_name [ : - len ( ns_suffix ) ] ) <EOL> parse_id = mock . patch . object ( namespaces , '<STR_LIT>' ) . start ( ) <EOL> parse_id . side_effect = get_id_from_ns_name <EOL> super ( L3NATAgentForTest , self ) . __init__ ( host , conf ) <EOL> OPTS = [ <EOL> cfg . StrOpt ( '<STR_LIT>' , default = '<STR_LIT>' , <EOL> help = _ ( "<STR_LIT>" ) ) , <EOL> ] <EOL> def register_opts ( conf ) : <EOL> conf . register_opts ( OPTS ) <EOL> def main ( manager = '<STR_LIT>' ) : <EOL> register_opts ( cfg . CONF ) <EOL> l3_agent . main ( manager = manager ) <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> sys . exit ( main ( ) ) </s>
