def test_main_dont_fork(self):
        with mock.patch.object(ns_proxy, "ProxyDaemon") as daemon:
            with mock.patch.object(ns_proxy, "config") as config:
                with mock.patch.object(ns_proxy, "cfg") as cfg:
                    with mock.patch.object(utils, "cfg") as utils_cfg:
                        cfg.CONF.router_id = "router_id"
                        cfg.CONF.network_id = None
                        cfg.CONF.metadata_port = 9697
                        cfg.CONF.pid_file = "pidfile"
                        cfg.CONF.daemonize = False
                        utils_cfg.CONF.log_opt_values.return_value = None
                        ns_proxy.main()

                        self.assertTrue(config.setup_logging.called)
                        daemon.assert_has_calls(
                            [mock.call("pidfile", 9697, router_id="router_id", network_id=None), mock.call().run()]
                        )
    def test_main(self):
        with mock.patch.object(ns_proxy, 'ProxyDaemon') as daemon:
            with mock.patch.object(ns_proxy, 'config') as config:
                with mock.patch.object(ns_proxy, 'cfg') as cfg:
                    with mock.patch.object(utils, 'cfg') as utils_cfg:
                        cfg.CONF.router_id = 'router_id'
                        cfg.CONF.network_id = None
                        cfg.CONF.metadata_port = 9697
                        cfg.CONF.pid_file = 'pidfile'
                        cfg.CONF.daemonize = True
                        utils_cfg.CONF.log_opt_values.return_value = None
                        ns_proxy.main()

                        self.assertTrue(config.setup_logging.called)
                        daemon.assert_has_calls([
                            mock.call('pidfile', 9697,
                                      router_id='router_id',
                                      network_id=None),
                            mock.call().start()]
                        )
示例#3
0
    def test_main_dont_fork(self):
        with mock.patch.object(ns_proxy, 'ProxyDaemon') as daemon:
            with mock.patch.object(ns_proxy, 'config') as config:
                with mock.patch.object(ns_proxy, 'cfg') as cfg:
                    with mock.patch.object(utils, 'cfg') as utils_cfg:
                        cfg.CONF.router_id = 'router_id'
                        cfg.CONF.network_id = None
                        cfg.CONF.metadata_port = 9697
                        cfg.CONF.pid_file = 'pidfile'
                        cfg.CONF.daemonize = False
                        utils_cfg.CONF.log_opt_values.return_value = None
                        ns_proxy.main()

                        self.assertTrue(config.setup_logging.called)
                        daemon.assert_has_calls([
                            mock.call('pidfile',
                                      9697,
                                      router_id='router_id',
                                      network_id=None),
                            mock.call().run()
                        ])
示例#4
0
def main():
    namespace_proxy.main()