def test_main_no_candidates(self):
        namespaces = ['ns1', 'ns2']
        with mock.patch('neutron.agent.linux.ip_lib.IPWrapper') as ip_wrap:
            ip_wrap.get_namespaces.return_value = namespaces

            with mock.patch('eventlet.sleep') as eventlet_sleep:
                conf = mock.Mock()
                conf.force = False
                methods_to_mock = dict(
                    eligible_for_deletion=mock.DEFAULT,
                    destroy_namespace=mock.DEFAULT,
                    setup_conf=mock.DEFAULT)

                with mock.patch.multiple(util, **methods_to_mock) as mocks:
                    mocks['eligible_for_deletion'].return_value = False
                    mocks['setup_conf'].return_value = conf
                    with mock.patch('neutron.common.config.setup_logging'):
                        util.main()

                        ip_wrap.assert_has_calls(
                            [mock.call.get_namespaces(conf.AGENT.root_helper)])

                        mocks['eligible_for_deletion'].assert_has_calls(
                            [mock.call(conf, 'ns1', False),
                             mock.call(conf, 'ns2', False)])

                        self.assertFalse(mocks['destroy_namespace'].called)

                        self.assertFalse(eventlet_sleep.called)
    def test_main_no_candidates(self):
        namespaces = ['ns1', 'ns2']
        with mock.patch('neutron.agent.linux.ip_lib.IPWrapper') as ip_wrap:
            ip_wrap.get_namespaces.return_value = namespaces

            with mock.patch('eventlet.sleep') as eventlet_sleep:
                conf = mock.Mock()
                conf.force = False
                methods_to_mock = dict(
                    eligible_for_deletion=mock.DEFAULT,
                    destroy_namespace=mock.DEFAULT,
                    setup_conf=mock.DEFAULT)

                with mock.patch.multiple(util, **methods_to_mock) as mocks:
                    mocks['eligible_for_deletion'].return_value = False
                    mocks['setup_conf'].return_value = conf
                    with mock.patch('neutron.common.config.setup_logging'):
                        util.main()

                        ip_wrap.assert_has_calls(
                            [mock.call.get_namespaces(conf.AGENT.root_helper)])

                        mocks['eligible_for_deletion'].assert_has_calls(
                            [mock.call(conf, 'ns1', False),
                             mock.call(conf, 'ns2', False)])

                        self.assertFalse(mocks['destroy_namespace'].called)

                        self.assertFalse(eventlet_sleep.called)