Begin moving bits to osc_lib
* command * commandmanager * exceptions * logs * parseractions * session * timing * utils * test fakes, utils
This commit is contained in:
parent
99fddaccdc
commit
2bcf7396d8
@ -2,7 +2,7 @@
|
|||||||
test_command=OS_STDOUT_CAPTURE=${OS_STDOUT_CAPTURE:-1} \
|
test_command=OS_STDOUT_CAPTURE=${OS_STDOUT_CAPTURE:-1} \
|
||||||
OS_STDERR_CAPTURE=${OS_STDERR_CAPTURE:-1} \
|
OS_STDERR_CAPTURE=${OS_STDERR_CAPTURE:-1} \
|
||||||
OS_TEST_TIMEOUT=${OS_TEST_TIMEOUT:-60} \
|
OS_TEST_TIMEOUT=${OS_TEST_TIMEOUT:-60} \
|
||||||
${PYTHON:-python} -m subunit.run discover -t ./ ${OS_TEST_PATH:-./openstackclient/tests} $LISTOPT $IDOPTION
|
${PYTHON:-python} -m subunit.run discover -t ./ ${OS_TEST_PATH:-./osc_lib/tests} $LISTOPT $IDOPTION
|
||||||
|
|
||||||
test_id_option=--load-list $IDFILE
|
test_id_option=--load-list $IDFILE
|
||||||
test_list_option=--list
|
test_list_option=--list
|
||||||
|
20
README.rst
20
README.rst
@ -39,3 +39,23 @@ Getting Started
|
|||||||
osc-lib can be installed from PyPI using pip::
|
osc-lib can be installed from PyPI using pip::
|
||||||
|
|
||||||
pip install osc-lib
|
pip install osc-lib
|
||||||
|
|
||||||
|
Transition From OpenStackclient
|
||||||
|
===============================
|
||||||
|
|
||||||
|
This library was extracted from the main OSC repo after the OSC 2.4.0 release.
|
||||||
|
The following are the changes to imports that will cover the majority of
|
||||||
|
transition to using osc-lib:
|
||||||
|
|
||||||
|
* openstackclient.common.parseractions -> osc_lib.cli.parseractions
|
||||||
|
* openstackclient.common.command -> osc_lib.command.command
|
||||||
|
* openstackclient.common.exceptions -> osc_lib.exceptions
|
||||||
|
* openstackclient.common.logs -> osc_lib.logs
|
||||||
|
* openstackclient.common.session -> osc_lib.session
|
||||||
|
* openstackclient.common.utils -> osc_lib.utils
|
||||||
|
* openstackclient.i18n -> osc_lib.i18n
|
||||||
|
|
||||||
|
Also, some of the test fixtures and modules may be used:
|
||||||
|
|
||||||
|
* openstackclient.tests.fakes -> osc_lib.tests.fakes
|
||||||
|
* openstackclient.tests.utils -> osc_lib.tests.utils
|
||||||
|
@ -22,7 +22,7 @@ from keystoneclient.auth import base
|
|||||||
|
|
||||||
from openstackclient.common import exceptions as exc
|
from openstackclient.common import exceptions as exc
|
||||||
from openstackclient.common import utils
|
from openstackclient.common import utils
|
||||||
from openstackclient.i18n import _
|
from osc_lib.i18n import _
|
||||||
|
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
22
osc_lib/__init__.py
Normal file
22
osc_lib/__init__.py
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
# 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.
|
||||||
|
#
|
||||||
|
|
||||||
|
__all__ = ['__version__']
|
||||||
|
|
||||||
|
import pbr.version
|
||||||
|
|
||||||
|
version_info = pbr.version.VersionInfo('python-openstackclient')
|
||||||
|
try:
|
||||||
|
__version__ = version_info.version_string()
|
||||||
|
except AttributeError:
|
||||||
|
__version__ = None
|
0
osc_lib/cli/__init__.py
Normal file
0
osc_lib/cli/__init__.py
Normal file
@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
|
|
||||||
from openstackclient.i18n import _
|
from osc_lib.i18n import _
|
||||||
|
|
||||||
|
|
||||||
class KeyValueAction(argparse.Action):
|
class KeyValueAction(argparse.Action):
|
0
osc_lib/command/__init__.py
Normal file
0
osc_lib/command/__init__.py
Normal file
@ -13,7 +13,7 @@
|
|||||||
|
|
||||||
"""Timing Implementation"""
|
"""Timing Implementation"""
|
||||||
|
|
||||||
from openstackclient.common import command
|
from osc_lib.command import command
|
||||||
|
|
||||||
|
|
||||||
class Timing(command.Lister):
|
class Timing(command.Lister):
|
@ -15,7 +15,7 @@
|
|||||||
|
|
||||||
import oslo_i18n
|
import oslo_i18n
|
||||||
|
|
||||||
_translators = oslo_i18n.TranslatorFactory(domain='openstackclient')
|
_translators = oslo_i18n.TranslatorFactory(domain='osc_lib')
|
||||||
|
|
||||||
# The primary translation function using the well-known name "_"
|
# The primary translation function using the well-known name "_"
|
||||||
_ = _translators.primary
|
_ = _translators.primary
|
0
osc_lib/tests/__init__.py
Normal file
0
osc_lib/tests/__init__.py
Normal file
0
osc_lib/tests/cli/__init__.py
Normal file
0
osc_lib/tests/cli/__init__.py
Normal file
@ -15,8 +15,8 @@
|
|||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
|
|
||||||
from openstackclient.common import parseractions
|
from osc_lib.cli import parseractions
|
||||||
from openstackclient.tests import utils
|
from osc_lib.tests import utils
|
||||||
|
|
||||||
|
|
||||||
class TestKeyValueAction(utils.TestCase):
|
class TestKeyValueAction(utils.TestCase):
|
0
osc_lib/tests/command/__init__.py
Normal file
0
osc_lib/tests/command/__init__.py
Normal file
@ -14,8 +14,8 @@
|
|||||||
|
|
||||||
import mock
|
import mock
|
||||||
|
|
||||||
from openstackclient.common import command
|
from osc_lib.command import command
|
||||||
from openstackclient.tests import utils as test_utils
|
from osc_lib.tests import utils as test_utils
|
||||||
|
|
||||||
|
|
||||||
class FakeCommand(command.Command):
|
class FakeCommand(command.Command):
|
||||||
@ -29,5 +29,7 @@ class TestCommand(test_utils.TestCase):
|
|||||||
def test_command_has_logger(self):
|
def test_command_has_logger(self):
|
||||||
cmd = FakeCommand(mock.Mock(), mock.Mock())
|
cmd = FakeCommand(mock.Mock(), mock.Mock())
|
||||||
self.assertTrue(hasattr(cmd, 'log'))
|
self.assertTrue(hasattr(cmd, 'log'))
|
||||||
self.assertEqual('openstackclient.tests.common.test_command.'
|
self.assertEqual(
|
||||||
'FakeCommand', cmd.log.name)
|
'osc_lib.tests.command.test_command.FakeCommand',
|
||||||
|
cmd.log.name,
|
||||||
|
)
|
@ -15,8 +15,8 @@
|
|||||||
|
|
||||||
import mock
|
import mock
|
||||||
|
|
||||||
from openstackclient.common import commandmanager
|
from osc_lib.command import commandmanager
|
||||||
from openstackclient.tests import utils
|
from osc_lib.tests import utils
|
||||||
|
|
||||||
|
|
||||||
class FakeCommand(object):
|
class FakeCommand(object):
|
@ -15,9 +15,9 @@
|
|||||||
|
|
||||||
import datetime
|
import datetime
|
||||||
|
|
||||||
from openstackclient.common import timing
|
from osc_lib.command import timing
|
||||||
from openstackclient.tests import fakes
|
from osc_lib.tests import fakes
|
||||||
from openstackclient.tests import utils
|
from osc_lib.tests import utils
|
||||||
|
|
||||||
|
|
||||||
timing_url = 'GET http://localhost:5000'
|
timing_url = 'GET http://localhost:5000'
|
@ -14,8 +14,8 @@
|
|||||||
import logging
|
import logging
|
||||||
import mock
|
import mock
|
||||||
|
|
||||||
from openstackclient.common import logs
|
from osc_lib import logs
|
||||||
from openstackclient.tests import utils
|
from osc_lib.tests import utils
|
||||||
|
|
||||||
|
|
||||||
class TestContext(utils.TestCase):
|
class TestContext(utils.TestCase):
|
||||||
@ -121,7 +121,7 @@ class TestLogConfigurator(utils.TestCase):
|
|||||||
|
|
||||||
@mock.patch('logging.StreamHandler')
|
@mock.patch('logging.StreamHandler')
|
||||||
@mock.patch('logging.getLogger')
|
@mock.patch('logging.getLogger')
|
||||||
@mock.patch('openstackclient.common.logs.set_warning_filter')
|
@mock.patch('osc_lib.logs.set_warning_filter')
|
||||||
def test_init(self, warning_filter, getLogger, handle):
|
def test_init(self, warning_filter, getLogger, handle):
|
||||||
getLogger.side_effect = self.loggers
|
getLogger.side_effect = self.loggers
|
||||||
console_logger = mock.Mock()
|
console_logger = mock.Mock()
|
||||||
@ -142,7 +142,7 @@ class TestLogConfigurator(utils.TestCase):
|
|||||||
self.assertFalse(configurator.dump_trace)
|
self.assertFalse(configurator.dump_trace)
|
||||||
|
|
||||||
@mock.patch('logging.getLogger')
|
@mock.patch('logging.getLogger')
|
||||||
@mock.patch('openstackclient.common.logs.set_warning_filter')
|
@mock.patch('osc_lib.logs.set_warning_filter')
|
||||||
def test_init_no_debug(self, warning_filter, getLogger):
|
def test_init_no_debug(self, warning_filter, getLogger):
|
||||||
getLogger.side_effect = self.loggers
|
getLogger.side_effect = self.loggers
|
||||||
self.options.debug = True
|
self.options.debug = True
|
||||||
@ -155,8 +155,8 @@ class TestLogConfigurator(utils.TestCase):
|
|||||||
|
|
||||||
@mock.patch('logging.FileHandler')
|
@mock.patch('logging.FileHandler')
|
||||||
@mock.patch('logging.getLogger')
|
@mock.patch('logging.getLogger')
|
||||||
@mock.patch('openstackclient.common.logs.set_warning_filter')
|
@mock.patch('osc_lib.logs.set_warning_filter')
|
||||||
@mock.patch('openstackclient.common.logs._FileFormatter')
|
@mock.patch('osc_lib.logs._FileFormatter')
|
||||||
def test_init_log_file(self, formatter, warning_filter, getLogger, handle):
|
def test_init_log_file(self, formatter, warning_filter, getLogger, handle):
|
||||||
getLogger.side_effect = self.loggers
|
getLogger.side_effect = self.loggers
|
||||||
self.options.log_file = '/tmp/log_file'
|
self.options.log_file = '/tmp/log_file'
|
||||||
@ -176,8 +176,8 @@ class TestLogConfigurator(utils.TestCase):
|
|||||||
|
|
||||||
@mock.patch('logging.FileHandler')
|
@mock.patch('logging.FileHandler')
|
||||||
@mock.patch('logging.getLogger')
|
@mock.patch('logging.getLogger')
|
||||||
@mock.patch('openstackclient.common.logs.set_warning_filter')
|
@mock.patch('osc_lib.logs.set_warning_filter')
|
||||||
@mock.patch('openstackclient.common.logs._FileFormatter')
|
@mock.patch('osc_lib.logs._FileFormatter')
|
||||||
def test_configure(self, formatter, warning_filter, getLogger, handle):
|
def test_configure(self, formatter, warning_filter, getLogger, handle):
|
||||||
getLogger.side_effect = self.loggers
|
getLogger.side_effect = self.loggers
|
||||||
configurator = logs.LogConfigurator(self.options)
|
configurator = logs.LogConfigurator(self.options)
|
@ -18,10 +18,10 @@ import uuid
|
|||||||
|
|
||||||
import mock
|
import mock
|
||||||
|
|
||||||
from openstackclient.common import exceptions
|
from osc_lib import exceptions
|
||||||
from openstackclient.common import utils
|
from osc_lib.tests import fakes
|
||||||
from openstackclient.tests import fakes
|
from osc_lib.tests import utils as test_utils
|
||||||
from openstackclient.tests import utils as test_utils
|
from osc_lib import utils
|
||||||
|
|
||||||
PASSWORD = "Pa$$w0rd"
|
PASSWORD = "Pa$$w0rd"
|
||||||
WASSPORD = "Wa$$p0rd"
|
WASSPORD = "Wa$$p0rd"
|
@ -19,7 +19,7 @@ import os
|
|||||||
import fixtures
|
import fixtures
|
||||||
import testtools
|
import testtools
|
||||||
|
|
||||||
from openstackclient.tests import fakes
|
from osc_lib.tests import fakes
|
||||||
|
|
||||||
|
|
||||||
class ParserException(Exception):
|
class ParserException(Exception):
|
@ -23,7 +23,7 @@ import time
|
|||||||
|
|
||||||
from oslo_utils import importutils
|
from oslo_utils import importutils
|
||||||
|
|
||||||
from openstackclient.common import exceptions
|
from osc_lib import exceptions
|
||||||
|
|
||||||
|
|
||||||
def find_resource(manager, name_or_id, **kwargs):
|
def find_resource(manager, name_or_id, **kwargs):
|
2
tox.ini
2
tox.ini
@ -19,7 +19,7 @@ commands = {posargs}
|
|||||||
|
|
||||||
[testenv:cover]
|
[testenv:cover]
|
||||||
commands =
|
commands =
|
||||||
python setup.py test --coverage --testr-args='{posargs}'
|
python setup.py test --coverage --coverage-package-name=osc_lib --testr-args='{posargs}'
|
||||||
coverage report
|
coverage report
|
||||||
|
|
||||||
[testenv:debug]
|
[testenv:debug]
|
||||||
|
Loading…
Reference in New Issue
Block a user