示例#1
0
    def test_gettextutils_install(self):
        gettextutils.install('blaa')
        self.assertTrue(isinstance(_('A String'), six.text_type))  # noqa

        gettextutils.install('blaa', lazy=True)
        self.assertTrue(isinstance(_('A Message'),  # noqa
                                   gettextutils.Message))
示例#2
0
    def test_gettextutils_install_with_enable(self):
        gettextutils.install('blaa')
        self.assertTrue(isinstance(_('A String'), six.text_type))  # noqa

        gettextutils.enable_lazy()
        self.assertTrue(isinstance(_('A Message'),  # noqa
                                   gettextutils.Message))
示例#3
0
    def test_gettextutils_install(self):
        gettextutils.install('blaa')
        self.assertTrue(isinstance(_('A String'), unicode))  # noqa

        gettextutils.install('blaa', lazy=True)
        self.assertTrue(
            isinstance(
                _('A Message'),  # noqa
                gettextutils.Message))
示例#4
0
def prepare_service(argv=None):
    gettextutils.install('openstack')
    gettextutils.enable_lazy()
    log_levels = (cfg.CONF.default_log_levels)
    cfg.set_defaults(log.log_opts, default_log_levels=log_levels)
    if argv is None:
        argv = sys.argv
    cfg.CONF(argv[1:], project='monasca-anomaly')
    log.setup('monasca-anomaly')
    LOG.info('Service has started!')
示例#5
0
def prepare_service(argv=None):
    gettextutils.install('openstack')
    gettextutils.enable_lazy()
    log_levels = (cfg.CONF.default_log_levels)
    cfg.set_defaults(log.log_opts, default_log_levels=log_levels)
    if argv is None:
        argv = sys.argv
    cfg.CONF(argv[1:], project='persister')
    log.setup('persister')
    LOG.info('Service has started!')
示例#6
0
    def test_gettext_install_looks_up_localedir(self):
        with mock.patch('os.environ.get') as environ_get:
            with mock.patch('gettext.install') as gettext_install:
                environ_get.return_value = '/foo/bar'

                gettextutils.install('blaa')

                environ_get.assert_called_once_with('BLAA_LOCALEDIR')
                gettext_install.assert_called_once_with('blaa',
                                                        localedir='/foo/bar',
                                                        unicode=True)
示例#7
0
    def test_gettext_install_looks_up_localedir(self):
        with mock.patch('os.environ.get') as environ_get:
            with mock.patch('gettext.install') as gettext_install:
                environ_get.return_value = '/foo/bar'

                gettextutils.install('blaa')

                environ_get.assert_called_once_with('BLAA_LOCALEDIR')
                gettext_install.assert_called_once_with('blaa',
                                                        localedir='/foo/bar',
                                                        unicode=True)
示例#8
0
    def test_gettext_install_looks_up_localedir(self):
        with mock.patch("os.environ.get") as environ_get:
            with mock.patch("gettext.install") as gettext_install:
                environ_get.return_value = "/foo/bar"

                gettextutils.install("blaa")

                environ_get.assert_called_once_with("BLAA_LOCALEDIR")
                if six.PY3:
                    gettext_install.assert_called_once_with("blaa", localedir="/foo/bar")
                else:
                    gettext_install.assert_called_once_with("blaa", localedir="/foo/bar", unicode=True)
示例#9
0
from __future__ import print_function

import imp
import os
import re
import socket
import sys
import textwrap

from oslo.config import cfg

from openstack.common import gettextutils
from openstack.common import importutils

gettextutils.install('oslo')

STROPT = "StrOpt"
BOOLOPT = "BoolOpt"
INTOPT = "IntOpt"
FLOATOPT = "FloatOpt"
LISTOPT = "ListOpt"
MULTISTROPT = "MultiStrOpt"

OPT_TYPES = {
    STROPT: 'string value',
    BOOLOPT: 'boolean value',
    INTOPT: 'integer value',
    FLOATOPT: 'floating point value',
    LISTOPT: 'list value',
    MULTISTROPT: 'multi valued',
示例#10
0
from __future__ import print_function

import imp
import os
import re
import socket
import sys
import textwrap

from oslo.config import cfg

from openstack.common import gettextutils
from openstack.common import importutils

gettextutils.install("oslo")

STROPT = "StrOpt"
BOOLOPT = "BoolOpt"
INTOPT = "IntOpt"
FLOATOPT = "FloatOpt"
LISTOPT = "ListOpt"
MULTISTROPT = "MultiStrOpt"

OPT_TYPES = {
    STROPT: "string value",
    BOOLOPT: "boolean value",
    INTOPT: "integer value",
    FLOATOPT: "floating point value",
    LISTOPT: "list value",
    MULTISTROPT: "multi valued",
示例#11
0
from __future__ import print_function

import imp
import os
import re
import socket
import sys
import textwrap

from oslo.config import cfg

from openstack.common import gettextutils
from openstack.common import importutils

gettextutils.install('oslo')

STROPT = "StrOpt"
BOOLOPT = "BoolOpt"
INTOPT = "IntOpt"
FLOATOPT = "FloatOpt"
LISTOPT = "ListOpt"
MULTISTROPT = "MultiStrOpt"

OPT_TYPES = {
    STROPT: 'string value',
    BOOLOPT: 'boolean value',
    INTOPT: 'integer value',
    FLOATOPT: 'floating point value',
    LISTOPT: 'list value',
    MULTISTROPT: 'multi valued',
示例#12
0
    def test_gettextutils_install(self):
        gettextutils.install("blaa")
        self.assertTrue(isinstance(_("A String"), six.text_type))  # noqa

        gettextutils.install("blaa", lazy=True)
        self.assertTrue(isinstance(_("A Message"), gettextutils.Message))  # noqa
示例#13
0
 def test_gettextutils_install(self):
     gettextutils.install('blaa')
     self.assertTrue(isinstance(_('A String'), six.text_type))  # noqa