Fix unit tests

This commit is contained in:
Elena Ezhova 2015-05-21 17:00:17 +03:00
parent e20363d67e
commit 47d6f01abb
15 changed files with 64 additions and 28 deletions

33
oslo_service/_i18n.py Normal file
View File

@ -0,0 +1,33 @@
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
"""oslo.i18n integration module.
See http://docs.openstack.org/developer/oslo.i18n/usage.html .
"""
import oslo_i18n
_translators = oslo_i18n.TranslatorFactory(domain='oslo.log')
# The primary translation function using the well-known name "_"
_ = _translators.primary
# Translators for log levels.
#
# The abbreviated names are meant to reflect the usual use of a short
# name like '_'. The "L" is for "log" and the other letter comes from
# the level.
_LI = _translators.log_info
_LW = _translators.log_warning
_LE = _translators.log_error
_LC = _translators.log_critical

View File

@ -30,7 +30,7 @@ import eventlet.backdoor
import greenlet
from oslo_config import cfg
from openstack.common._i18n import _LI
from oslo_service._i18n import _LI
help_for_backdoor_port = (
"Acceptable values are 0, <port>, and <start>:<end>, where 0 results "

View File

@ -22,7 +22,7 @@ import time
from eventlet import event
from eventlet import greenthread
from openstack.common._i18n import _LE, _LW
from oslo_service._i18n import _LE, _LW
LOG = logging.getLogger(__name__)

View File

@ -19,7 +19,7 @@ import time
from oslo_config import cfg
import six
from openstack.common._i18n import _, _LE, _LI
from oslo_service._i18n import _, _LE, _LI
periodic_opts = [

View File

@ -30,10 +30,10 @@ import eventlet
from eventlet import event
from oslo_config import cfg
from openstack.common import eventlet_backdoor
from openstack.common._i18n import _LE, _LI, _LW
from openstack.common import systemd
from openstack.common import threadgroup
from oslo_service import eventlet_backdoor
from oslo_service._i18n import _LE, _LI, _LW
from oslo_service import systemd
from oslo_service import threadgroup
CONF = cfg.CONF

View File

@ -18,7 +18,7 @@ import ssl
from oslo_config import cfg
from openstack.common._i18n import _
from oslo_service._i18n import _
ssl_opts = [

View File

@ -23,7 +23,7 @@ import greenlet
from oslo_config import cfg
from openstack.common import service
from oslo_service import service
CONF = cfg.CONF

View File

@ -25,7 +25,7 @@ from oslo_config import fixture as config
from oslotest import base as test_base
from oslotest import moxstubout
from openstack.common import eventlet_backdoor
from oslo_service import eventlet_backdoor
class BackdoorPortTest(test_base.BaseTestCase):

View File

@ -18,7 +18,7 @@ from eventlet import greenthread
from mox3 import mox
from oslotest import base as test_base
from openstack.common import loopingcall
from oslo_service import loopingcall
class LoopingCallTestCase(test_base.BaseTestCase):

View File

@ -23,7 +23,7 @@ from oslo_config import fixture as config
from oslotest import base as test_base
from testtools import matchers
from openstack.common import periodic_task
from oslo_service import periodic_task
class AnException(Exception):

View File

@ -42,8 +42,8 @@ from oslotest import base as test_base
from oslotest import moxstubout
from six.moves import queue
from openstack.common import eventlet_backdoor
from openstack.common import service
from oslo_service import eventlet_backdoor
from oslo_service import service
LOG = logging.getLogger(__name__)
@ -355,7 +355,7 @@ class LauncherTest(test_base.BaseTestCase):
# unit test fixtures in nova bug #1199315)
launcher.stop()
@mock.patch('oslo_service.ServiceLauncher.launch_service')
@mock.patch('oslo_service.service.ServiceLauncher.launch_service')
def _test_launch_single(self, workers, mock_launch):
svc = service.Service()
service.launch(svc, workers=workers)
@ -367,7 +367,7 @@ class LauncherTest(test_base.BaseTestCase):
def test_launch_one_worker(self):
self._test_launch_single(1)
@mock.patch('oslo_service.ProcessLauncher.launch_service')
@mock.patch('oslo_service.service.ProcessLauncher.launch_service')
def test_multiple_worker(self, mock_launch):
svc = service.Service()
service.launch(svc, workers=3)
@ -383,7 +383,7 @@ class ProcessLauncherTest(test_base.BaseTestCase):
self.assertTrue(launcher.running)
launcher.children = [22, 222]
with mock.patch('oslo_service.os.kill') as mock_kill:
with mock.patch('oslo_service.service.os.kill') as mock_kill:
with mock.patch.object(launcher, '_wait_child') as _wait_child:
_wait_child.side_effect = lambda: launcher.children.pop()
launcher.stop()
@ -395,7 +395,7 @@ class ProcessLauncherTest(test_base.BaseTestCase):
mock_kill.mock_calls)
@mock.patch(
"oslo_service.ProcessLauncher._signal_handlers_set",
"oslo_service.service.ProcessLauncher._signal_handlers_set",
new_callable=lambda: set())
def test__signal_handlers_set(self, signal_handlers_set_mock):
callables = set()
@ -409,7 +409,7 @@ class ProcessLauncherTest(test_base.BaseTestCase):
service.ProcessLauncher._signal_handlers_set)
@mock.patch(
"oslo_service.ProcessLauncher._signal_handlers_set",
"oslo_service.service.ProcessLauncher._signal_handlers_set",
new_callable=lambda: set())
def test__handle_class_signals(self, signal_handlers_set_mock):
signal_handlers_set_mock.update([mock.Mock(), mock.Mock()])
@ -418,13 +418,13 @@ class ProcessLauncherTest(test_base.BaseTestCase):
m.assert_called_once_with()
@mock.patch("os.kill")
@mock.patch("oslo_service.ProcessLauncher.stop")
@mock.patch("oslo_service.ProcessLauncher._respawn_children")
@mock.patch("oslo_service.ProcessLauncher.handle_signal")
@mock.patch("oslo_service.service.ProcessLauncher.stop")
@mock.patch("oslo_service.service.ProcessLauncher._respawn_children")
@mock.patch("oslo_service.service.ProcessLauncher.handle_signal")
@mock.patch("oslo_config.cfg.CONF.log_opt_values")
@mock.patch("openstack.common.systemd.notify_once")
@mock.patch("oslo_service.systemd.notify_once")
@mock.patch("oslo_config.cfg.CONF.reload_config_files")
@mock.patch("oslo_service._is_sighup_and_daemon")
@mock.patch("oslo_service.service._is_sighup_and_daemon")
def test_parent_process_reload_config(self,
is_sighup_and_daemon_mock,
reload_config_files_mock,

View File

@ -18,7 +18,7 @@ import socket
from oslotest import base as test_base
from oslotest import moxstubout
from openstack.common import systemd
from oslo_service import systemd
class SystemdTestCase(test_base.BaseTestCase):

View File

@ -21,7 +21,7 @@ import time
from oslotest import base as test_base
from openstack.common import threadgroup
from oslo_service import threadgroup
class ThreadGroupTestCase(test_base.BaseTestCase):

View File

@ -17,8 +17,8 @@ import threading
import eventlet
from eventlet import greenpool
from openstack.common._i18n import _LE
from openstack.common import loopingcall
from oslo_service._i18n import _LE
from oslo_service import loopingcall
LOG = logging.getLogger(__name__)

View File

@ -3,3 +3,6 @@
# process, which may cause wedges in the gate later.
Babel>=0.9.6
eventlet>=0.17.3
oslo.config>=1.11.0 # Apache-2.0
oslo.i18n>=1.5.0 # Apache-2.0