Пример #1
0
    def test_mapped_tacker_error_localized(self, mock_translation):
        gettextutils.install('blaa', lazy=True)
        msg_translation = 'Translated error'
        mock_translation.return_value = msg_translation
        msg = _('Unmapped error')

        class TestException(n_exc.TackerException):
            message = msg

        controller = mock.MagicMock()
        controller.test.side_effect = TestException()
        faults = {TestException: exc.HTTPGatewayTimeout}
        resource = webtest.TestApp(
            wsgi_resource.Resource(controller, faults=faults))

        environ = {
            'wsgiorg.routing_args': (None, {
                'action': 'test',
                'format': 'json'
            })
        }

        res = resource.get('', extra_environ=environ, expect_errors=True)
        self.assertEqual(res.status_int, exc.HTTPGatewayTimeout.code)
        self.assertIn(msg_translation,
                      str(wsgi.JSONDeserializer().deserialize(res.body)))
Пример #2
0
    def test_unmapped_tacker_error_localized(self, mock_translation):
        gettextutils.install('blaa', lazy=True)
        msg_translation = 'Translated error'
        mock_translation.return_value = msg_translation
        msg = _('Unmapped error')

        class TestException(n_exc.TackerException):
            message = msg

        controller = mock.MagicMock()
        controller.test.side_effect = TestException()
        resource = webtest.TestApp(wsgi_resource.Resource(controller))

        environ = {'wsgiorg.routing_args': (None, {'action': 'test',
                                                   'format': 'json'})}

        res = resource.get('', extra_environ=environ, expect_errors=True)
        self.assertEqual(res.status_int, exc.HTTPInternalServerError.code)
        self.assertIn(msg_translation,
                      str(wsgi.JSONDeserializer().deserialize(res.body)))
Пример #3
0
# If ../tacker/__init__.py exists, add ../ to Python search path, so that
# it will override what happens to be installed in /usr/(local/)lib/python...

import sys

import eventlet
eventlet.monkey_patch()
from oslo_config import cfg

from tacker.common import config
from tacker.openstack.common import gettextutils
from tacker.openstack.common import log as logging
from tacker.openstack.common import service as common_service
from tacker import service
gettextutils.install('tacker', lazy=True)

LOG = logging.getLogger(__name__)


def main():
    # the configuration will be read into the cfg.CONF global data structure
    config.init(sys.argv[1:])
    if not cfg.CONF.config_file:
        sys.exit(_("ERROR: Unable to find configuration file via the default"
                   " search paths (~/.tacker/, ~/, /etc/tacker/, /etc/) and"
                   " the '--config-file' option!"))

    try:
        tacker_api = service.serve_wsgi(service.TackerApiService)
        launcher = common_service.launch(tacker_api,
Пример #4
0
#    under the License.

# If ../tacker/__init__.py exists, add ../ to Python search path, so that
# it will override what happens to be installed in /usr/(local/)lib/python...

import sys

import eventlet
eventlet.monkey_patch()
from oslo_config import cfg

from tacker.common import config
from tacker.openstack.common import gettextutils
from tacker.openstack.common import service as common_service
from tacker import service
gettextutils.install('tacker', lazy=True)


def main():
    # the configuration will be read into the cfg.CONF global data structure
    config.init(sys.argv[1:])
    if not cfg.CONF.config_file:
        sys.exit(
            _("ERROR: Unable to find configuration file via the default"
              " search paths (~/.tacker/, ~/, /etc/tacker/, /etc/) and"
              " the '--config-file' option!"))

    try:
        tacker_api = service.serve_wsgi(service.TackerApiService)
        launcher = common_service.launch(tacker_api,
                                         workers=cfg.CONF.api_workers)
Пример #5
0
import sys

import eventlet

eventlet.monkey_patch()

from oslo_config import cfg

from tacker.common import config
from tacker.openstack.common import service as common_service
from tacker import service

from tacker.openstack.common import gettextutils
from tacker.openstack.common import log as logging

gettextutils.install("tacker", lazy=True)

LOG = logging.getLogger(__name__)


def main():
    # the configuration will be read into the cfg.CONF global data structure
    config.init(sys.argv[1:])
    if not cfg.CONF.config_file:
        sys.exit(
            _(
                "ERROR: Unable to find configuration file via the default"
                " search paths (~/.tacker/, ~/, /etc/tacker/, /etc/) and"
                " the '--config-file' option!"
            )
        )