コード例 #1
0
 def test_change_lazy(self):
     _lazy.enable_lazy(True)
     tf = _factory.TranslatorFactory('domain')
     r = tf.primary('some text')
     self.assertIsInstance(r, _message.Message)
     _lazy.enable_lazy(False)
     r = tf.primary('some text')
     self.assertNotIsInstance(r, _message.Message)
コード例 #2
0
 def test_change_lazy(self):
     _lazy.enable_lazy(True)
     tf = _factory.TranslatorFactory('domain')
     r = tf.primary('some text')
     self.assertIsInstance(r, _message.Message)
     _lazy.enable_lazy(False)
     r = tf.primary('some text')
     self.assertNotIsInstance(r, _message.Message)
コード例 #3
0
ファイル: test_factory.py プロジェクト: hmonika/oslo.i18n
 def test_change_lazy(self):
     _lazy.enable_lazy(True)
     tf = _factory.TranslatorFactory('domain')
     r = tf.primary('some text')
     self.assertIsInstance(r, _message.Message)
     _lazy.enable_lazy(False)
     r = tf.primary('some text')
     # Python 2.6 doesn't have assertNotIsInstance().
     self.assertFalse(isinstance(r, _message.Message))
コード例 #4
0
    def test__gettextutils_install(self):
        _gettextutils.install('blaa')
        _lazy.enable_lazy(False)
        self.assertTrue(isinstance(self.t.primary('A String'), six.text_type))

        _gettextutils.install('blaa')
        _lazy.enable_lazy(True)
        self.assertTrue(
            isinstance(self.t.primary('A Message'), _message.Message))
コード例 #5
0
ファイル: test_factory.py プロジェクト: varunarya10/oslo.i18n
 def test_change_lazy(self):
     _lazy.enable_lazy(True)
     tf = _factory.TranslatorFactory('domain')
     r = tf.primary('some text')
     self.assertIsInstance(r, _message.Message)
     _lazy.enable_lazy(False)
     r = tf.primary('some text')
     # Python 2.6 doesn't have assertNotIsInstance().
     self.assertFalse(isinstance(r, _message.Message))
コード例 #6
0
 def test_py3(self):
     _lazy.enable_lazy(False)
     with mock.patch.object(six, "PY3", True):
         with mock.patch("gettext.translation") as translation:
             trans = mock.Mock()
             translation.return_value = trans
             trans.ugettext.side_effect = AssertionError("should have called gettext")
             tf = _factory.TranslatorFactory("domain")
             tf.primary("some text")
             trans.gettext.assert_called_with("some text")
コード例 #7
0
    def test__gettextutils_install(self):
        _gettextutils.install('blaa')
        _lazy.enable_lazy(False)
        self.assertTrue(isinstance(self.t.primary('A String'),
                                   six.text_type))

        _gettextutils.install('blaa')
        _lazy.enable_lazy(True)
        self.assertTrue(isinstance(self.t.primary('A Message'),
                                   _message.Message))
コード例 #8
0
ファイル: test_factory.py プロジェクト: varunarya10/oslo.i18n
 def test_py3(self):
     _lazy.enable_lazy(False)
     with mock.patch.object(six, 'PY3', True):
         with mock.patch('gettext.translation') as translation:
             trans = mock.Mock()
             translation.return_value = trans
             trans.ugettext.side_effect = AssertionError(
                 'should have called gettext')
             tf = _factory.TranslatorFactory('domain')
             tf.primary('some text')
             trans.gettext.assert_called_with('some text')
コード例 #9
0
 def test_plural_form_py2(self):
     _lazy.enable_lazy(False)
     with mock.patch.object(six, 'PY3', False):
         with mock.patch('gettext.translation') as translation:
             trans = mock.Mock()
             translation.return_value = trans
             trans.ngettext.side_effect = AssertionError(
                 'should have called ungettext')
             tf = _factory.TranslatorFactory('domain')
             tf.plural_form('single', 'plural', 1)
             trans.ungettext.assert_called_with('single', 'plural', 1)
コード例 #10
0
ファイル: test_factory.py プロジェクト: hmonika/oslo.i18n
 def test_py2(self):
     _lazy.enable_lazy(False)
     with mock.patch.object(six, 'PY3', False):
         with mock.patch('gettext.translation') as translation:
             trans = mock.Mock()
             translation.return_value = trans
             trans.gettext.side_effect = AssertionError(
                 'should have called ugettext')
             tf = _factory.TranslatorFactory('domain')
             tf.primary('some text')
             trans.ugettext.assert_called_with('some text')
コード例 #11
0
ファイル: test_factory.py プロジェクト: hmonika/oslo.i18n
 def test_plural_form_py3(self):
     _lazy.enable_lazy(False)
     with mock.patch.object(six, 'PY3', True):
         with mock.patch('gettext.translation') as translation:
             trans = mock.Mock()
             translation.return_value = trans
             trans.ungettext.side_effect = AssertionError(
                 'should have called ngettext')
             tf = _factory.TranslatorFactory('domain')
             tf.plural_form('single', 'plural', 1)
             trans.ngettext.assert_called_with(
                 'single', 'plural', 1)
コード例 #12
0
 def test_contextual_form_py2(self):
     _lazy.enable_lazy(False)
     with mock.patch.object(six, 'PY3', False):
         with mock.patch('gettext.translation') as translation:
             trans = mock.Mock()
             translation.return_value = trans
             trans.gettext.side_effect = AssertionError(
                 'should have called ugettext')
             trans.ugettext.return_value = "some text"
             tf = _factory.TranslatorFactory('domain')
             tf.contextual_form('context', 'some text')
             trans.ugettext.assert_called_with(
                 "%s%s%s" % ('context', CONTEXT_SEPARATOR, 'some text'))
コード例 #13
0
ファイル: test_factory.py プロジェクト: hmonika/oslo.i18n
 def test_contextual_form_py2(self):
     _lazy.enable_lazy(False)
     with mock.patch.object(six, 'PY3', False):
         with mock.patch('gettext.translation') as translation:
             trans = mock.Mock()
             translation.return_value = trans
             trans.gettext.side_effect = AssertionError(
                 'should have called ugettext')
             trans.ugettext.return_value = "some text"
             tf = _factory.TranslatorFactory('domain')
             tf.contextual_form('context', 'some text')
             trans.ugettext.assert_called_with(
                 "%s%s%s" % ('context', CONTEXT_SEPARATOR, 'some text'))
コード例 #14
0
 def test_lazy(self):
     _lazy.enable_lazy(True)
     with mock.patch.object(_message, "Message") as msg:
         tf = _factory.TranslatorFactory("domain")
         tf.primary("some text")
         msg.assert_called_with("some text", domain="domain")
コード例 #15
0
ファイル: fixture.py プロジェクト: HoratiusTang/oslo.i18n
 def _restore_original(self):
     _lazy.enable_lazy(self._original_value)
コード例 #16
0
ファイル: fixture.py プロジェクト: HoratiusTang/oslo.i18n
 def setUp(self):
     super(ToggleLazy, self).setUp()
     self.addCleanup(self._restore_original)
     _lazy.enable_lazy(self._enabled)
コード例 #17
0
#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
#    License for the specific language governing permissions and limitations
#    under the License.

"""
Senlin Engine Server.
"""
from oslo_config import cfg
from oslo_i18n import _lazy
from oslo_log import log as logging
from oslo_service import service

from senlin.common import consts
from senlin.common import messaging

_lazy.enable_lazy()

LOG = logging.getLogger('senlin.engine')


def main():
    logging.register_options(cfg.CONF)
    cfg.CONF(project='senlin', prog='senlin-engine')
    logging.setup(cfg.CONF, 'senlin-engine')
    logging.set_defaults()
    messaging.setup()

    from senlin.engine import service as engine

    srv = engine.EngineService(cfg.CONF.host, consts.ENGINE_TOPIC)
    launcher = service.launch(cfg.CONF, srv,
コード例 #18
0
 def _restore_original(self):
     _lazy.enable_lazy(self._original_value)
コード例 #19
0
 def setUp(self):
     super(ToggleLazy, self).setUp()
     self.addCleanup(self._restore_original)
     _lazy.enable_lazy(self._enabled)
コード例 #20
0
ファイル: test_lazy.py プロジェクト: bdrich/neutron-lbaas
 def test_enable_lazy(self):
     _lazy.USE_LAZY = False
     _lazy.enable_lazy()
     self.assertTrue(_lazy.USE_LAZY)
コード例 #21
0
 def test_enable_lazy(self):
     _lazy.USE_LAZY = False
     _lazy.enable_lazy()
     self.assertTrue(_lazy.USE_LAZY)
コード例 #22
0
 def test_disable_lazy(self):
     _lazy.USE_LAZY = True
     _lazy.enable_lazy(False)
     self.assertFalse(_lazy.USE_LAZY)
コード例 #23
0
ファイル: test_factory.py プロジェクト: hmonika/oslo.i18n
 def test_not_lazy(self):
     _lazy.enable_lazy(False)
     with mock.patch.object(_message, 'Message') as msg:
         msg.side_effect = AssertionError('should not use Message')
         tf = _factory.TranslatorFactory('domain')
         tf.primary('some text')
コード例 #24
0
ファイル: test_factory.py プロジェクト: hmonika/oslo.i18n
 def test_lazy(self):
     _lazy.enable_lazy(True)
     with mock.patch.object(_message, 'Message') as msg:
         tf = _factory.TranslatorFactory('domain')
         tf.primary('some text')
         msg.assert_called_with('some text', domain='domain')
コード例 #25
0
ファイル: test_factory.py プロジェクト: varunarya10/oslo.i18n
 def test_lazy(self):
     _lazy.enable_lazy(True)
     with mock.patch.object(_message, 'Message') as msg:
         tf = _factory.TranslatorFactory('domain')
         tf.primary('some text')
         msg.assert_called_with('some text', domain='domain')
コード例 #26
0
ファイル: test_lazy.py プロジェクト: bdrich/neutron-lbaas
 def test_disable_lazy(self):
     _lazy.USE_LAZY = True
     _lazy.enable_lazy(False)
     self.assertFalse(_lazy.USE_LAZY)
コード例 #27
0
ファイル: api.py プロジェクト: MountainWei/miper
                                   os.pardir),)
if os.path.exists(os.path.join(possible_topdir, 'miper', '__init__.py')):
    sys.path.insert(0, possible_topdir)

from oslo_config import cfg
from oslo_i18n import _lazy
from oslo_log import log as logging
from oslo_service import systemd
import six
from paste import deploy

from miper.common.i18n import _LI
from miper.common import wsgi
from miper.common import rpc

_lazy.enable_lazy()

LOG = logging.getLogger('miper.api')

if __name__ == '__main__':
    try:
        logging.register_options(cfg.CONF)
        cfg.CONF(project='miper', prog='miper-api',
                 version='0.0.2')
        logging.setup(cfg.CONF, 'miper-api')

        # messaging configuration
        rpc.set_defaults(control_exchange='miper')
        rpc.init(cfg.CONF)

        conf_file = os.path.join(possible_topdir, "etc", "api-paste.ini")
コード例 #28
0
ファイル: test_factory.py プロジェクト: varunarya10/oslo.i18n
 def test_not_lazy(self):
     _lazy.enable_lazy(False)
     with mock.patch.object(_message, 'Message') as msg:
         msg.side_effect = AssertionError('should not use Message')
         tf = _factory.TranslatorFactory('domain')
         tf.primary('some text')