Rename module from hnv_client to hnv

This commit is contained in:
Alexandru Coman 2017-02-06 15:33:22 +02:00
parent 243d3b0732
commit 75cea338f5
No known key found for this signature in database
GPG Key ID: A7B6A9021F704507
44 changed files with 70 additions and 70 deletions

View File

@ -171,7 +171,7 @@ ignored-modules=
# List of class names for which member attributes should not be checked (useful
# for classes with dynamically set attributes). This supports the use of
# qualified names.
ignored-classes=optparse.Values,thread._local,_thread._local, hnv_client.common.model.Model
ignored-classes=optparse.Values,thread._local,_thread._local, hnv.common.model.Model
# List of members which are set dynamically and missed by pylint inference
# system, and so shouldn't trigger E1101 when accessed. Python regular

View File

@ -2,7 +2,7 @@
test_command=OS_STDOUT_CAPTURE=${OS_STDOUT_CAPTURE:-1} \
OS_STDERR_CAPTURE=${OS_STDERR_CAPTURE:-1} \
OS_TEST_TIMEOUT=${OS_TEST_TIMEOUT:-160} \
${PYTHON:-python} -m subunit.run discover -t ./ ./hnv_client/tests $LISTOPT $IDOPTION
${PYTHON:-python} -m subunit.run discover -t ./ ./hnv/tests $LISTOPT $IDOPTION
test_id_option=--load-list $IDFILE
test_list_option=--list

View File

@ -1,2 +1,2 @@
# hvn-client
# python-hnv
Python client for the HNV (Hyper-V Network Virtualization) REST API.

View File

@ -1,7 +1,7 @@
HNV Client
==========
.. automodule:: hnv_client.client
.. automodule:: hnv.client
:members:
:inherited-members:
.. autoattribute::

View File

@ -1,6 +1,6 @@
HNV Client's exceptions
=======================
.. automodule:: hnv_client.common.exception
.. automodule:: hnv.common.exception
:members:
.. autoattribute::

4
etc/hnv/README.md Normal file
View File

@ -0,0 +1,4 @@
To generate the sample hnv.conf file, run the following command from the top
level of the python-hnv directory:
oslo-config-generator --config-file etc/python-hnv/hnv-config-generator.conf

View File

@ -0,0 +1,5 @@
[DEFAULT]
output_file = etc/python-hnv/hnv.conf
wrap_width = 80
namespace = hnv.conf
namespace = oslo.log

View File

@ -1,4 +0,0 @@
To generate the sample hnv_client.conf file, run the following command from the top
level of the arestor directory:
oslo-config-generator --config-file etc/hnv_client/hnv_client-config-generator.conf

View File

@ -1,5 +0,0 @@
[DEFAULT]
output_file = etc/hnv_client/hnv_client.conf
wrap_width = 80
namespace = hnv_client
namespace = oslo.log

View File

@ -19,11 +19,11 @@ import uuid
from oslo_log import log as logging
from hnv_client.common import constant
from hnv_client.common import exception
from hnv_client.common import model
from hnv_client.common import utils
from hnv_client import config as hnv_config
from hnv.common import constant
from hnv.common import exception
from hnv.common import model
from hnv.common import utils
from hnv import config as hnv_config
LOG = logging.getLogger(__name__)
CONFIG = hnv_config.CONFIG

View File

@ -17,7 +17,7 @@
class HNVException(Exception):
"""Base hnv_client exception.
"""Base HNV client exception.
To correctly use this class, inherit from it and define
a `template` property.

View File

@ -21,7 +21,7 @@ import copy
from oslo_log import log as logging
import six
from hnv_client.common import exception
from hnv.common import exception
LOG = logging.getLogger(__name__)

View File

@ -23,9 +23,9 @@ import requests
import requests_ntlm
import six
from hnv_client.common import constant
from hnv_client.common import exception
from hnv_client import config as hnv_config
from hnv.common import constant
from hnv.common import exception
from hnv import config as hnv_config
LOG = logging.getLogger(__name__)
CONFIG = hnv_config.CONFIG

View File

@ -16,9 +16,9 @@
from oslo_config import cfg
from hnv_client.config import factory
from hnv.config import factory as options_factory
CONFIG = cfg.CONF
for option_class in factory.get_options():
for option_class in options_factory.get_options():
option_class(CONFIG).register()

View File

@ -16,7 +16,7 @@
from oslo_config import cfg
from hnv_client.config import base as config_base
from hnv.config import base as config_base
class HVNOptions(config_base.Options):

View File

@ -15,7 +15,7 @@
"""Factory for all the available config options."""
_OPT_PATHS = (
'hnv_client.config.hnv.HVNOptions',
'hnv.config.client.HVNOptions',
)

View File

@ -19,8 +19,8 @@ file for Cloudbase-Init.
import collections
from hnv_client.config import base as config_base
from hnv_client.config import factory as config_factory
from hnv.config import base as config_base
from hnv.config import factory as config_factory
def get_options():

View File

@ -21,8 +21,8 @@ try:
except ImportError:
import mock
from hnv_client.common import exception
from hnv_client.common import model
from hnv.common import exception
from hnv.common import model
class TestFieldDescriptor(unittest.TestCase):
@ -80,7 +80,7 @@ class TestField(unittest.TestCase):
self.assertIs(field.is_property, mock.sentinel.is_property)
self.assertIs(field.is_read_only, mock.sentinel.is_read_only)
@mock.patch("hnv_client.common.model._FieldDescriptor")
@mock.patch("hnv.common.model._FieldDescriptor")
def test_add_to_class(self, mock_field_descriptor):
field = model.Field(name="test_add_to_class", key="test")
model_class = mock.Mock()
@ -101,7 +101,7 @@ class TestModelOptions(unittest.TestCase):
self.assertEqual(model_options._name, mock.sentinel.cls.name)
@mock.patch("six.callable")
@mock.patch("hnv_client.common.model._ModelOptions.remove_field")
@mock.patch("hnv.common.model._ModelOptions.remove_field")
def _test_add_field(self, mock_remove_field, mock_callable,
callable_default):
model_options = model._ModelOptions(self.__class__)

View File

@ -22,11 +22,11 @@ except ImportError:
import requests
from hnv_client.common import constant
from hnv_client.common import exception
from hnv_client.common import utils as hnv_utils
from hnv_client import config as hnv_config
from hnv_client.tests import utils as test_utils
from hnv.common import constant
from hnv.common import exception
from hnv.common import utils as hnv_utils
from hnv import config as hnv_config
from hnv.tests import utils as test_utils
CONFIG = hnv_config.CONFIG
@ -41,8 +41,8 @@ class TestHNVClient(unittest.TestCase):
return hnv_utils._HNVClient(url, username, password, allow_insecure,
ca_bundle)
@mock.patch("hnv_client.common.utils._HNVClient._get_headers")
@mock.patch("hnv_client.common.utils._HNVClient._verify_https_request")
@mock.patch("hnv.common.utils._HNVClient._get_headers")
@mock.patch("hnv.common.utils._HNVClient._verify_https_request")
@mock.patch("requests_ntlm.HttpNtlmAuth")
@mock.patch("requests.Session")
def test_session(self, mock_get_session, mock_auth, mock_verify,
@ -75,8 +75,8 @@ class TestHNVClient(unittest.TestCase):
@mock.patch("time.sleep")
@mock.patch("json.dumps")
@mock.patch("requests.compat.urljoin")
@mock.patch("hnv_client.common.utils._HNVClient._session")
@mock.patch("hnv_client.common.utils._HNVClient._get_headers")
@mock.patch("hnv.common.utils._HNVClient._session")
@mock.patch("hnv.common.utils._HNVClient._get_headers")
def _test_http_request(self, mock_headers, mock_session, mock_join,
mock_dump, mock_sleep,
method, body, response, status_code):
@ -101,7 +101,7 @@ class TestHNVClient(unittest.TestCase):
{"status_code": status_code})
client = self._get_client()
with test_utils.LogSnatcher("hnv_client.common.utils") as logging:
with test_utils.LogSnatcher("hnv.common.utils") as logging:
if isinstance(expected_response, requests.exceptions.SSLError):
self.assertRaises(exception.CertificateVerifyFailed,
client._http_request,
@ -209,7 +209,7 @@ class TestHNVClient(unittest.TestCase):
response=response,
status_code=500)
@mock.patch("hnv_client.common.utils._HNVClient._http_request")
@mock.patch("hnv.common.utils._HNVClient._http_request")
def test_get_resource(self, mock_http_request):
response = mock.Mock()
response.json = mock.Mock()
@ -224,7 +224,7 @@ class TestHNVClient(unittest.TestCase):
self.assertRaises(exception.ServiceException,
client.get_resource, mock.sentinel.path)
@mock.patch("hnv_client.common.utils._HNVClient._http_request")
@mock.patch("hnv.common.utils._HNVClient._http_request")
def test_update_resource(self, mock_http_request):
response = mock.Mock()
response.json = mock.Mock()
@ -243,7 +243,7 @@ class TestHNVClient(unittest.TestCase):
client.update_resource,
mock.sentinel.path, mock.sentinel.data)
@mock.patch("hnv_client.common.utils._HNVClient._http_request")
@mock.patch("hnv.common.utils._HNVClient._http_request")
def test_remove_resource(self, mock_http_request):
mock_http_request.return_value = mock.sentinel.response

View File

@ -23,7 +23,7 @@ class FakeResponse(object):
"""HNV API fake responses."""
def __init__(self):
self._resources = "hnv_client.tests.fake.response"
self._resources = "hnv.tests.fake.response"
self._cache = {}
def _load_resource(self, resource):

View File

@ -21,12 +21,12 @@ try:
except ImportError:
import mock
from hnv_client import client
from hnv_client.common import constant
from hnv_client.common import exception
from hnv_client import config as hnv_config
from hnv_client.tests.fake import fake_response
from hnv_client.tests import utils as test_utils
from hnv import client
from hnv.common import constant
from hnv.common import exception
from hnv import config as hnv_config
from hnv.tests.fake import fake_response
from hnv.tests import utils as test_utils
CONFIG = hnv_config.CONFIG
@ -36,8 +36,8 @@ class TestBaseHNVModel(unittest.TestCase):
def setUp(self):
client._BaseHNVModel._endpoint = "{parent_id}/{resource_id}"
@mock.patch("hnv_client.client._BaseHNVModel.from_raw_data")
@mock.patch("hnv_client.client._BaseHNVModel._get_client")
@mock.patch("hnv.client._BaseHNVModel.from_raw_data")
@mock.patch("hnv.client._BaseHNVModel._get_client")
def test_get(self, mock_get_client, mock_from_raw_data):
mock_from_raw_data.return_value = mock.sentinel.resource
http_client = mock_get_client.return_value = mock.Mock()
@ -48,8 +48,8 @@ class TestBaseHNVModel(unittest.TestCase):
get_resource.assert_called_once_with("/hnv-client-test")
self.assertIs(resource, mock.sentinel.resource)
@mock.patch("hnv_client.client._BaseHNVModel.from_raw_data")
@mock.patch("hnv_client.client._BaseHNVModel._get_client")
@mock.patch("hnv.client._BaseHNVModel.from_raw_data")
@mock.patch("hnv.client._BaseHNVModel._get_client")
def test_get_all(self, mock_get_client, mock_from_raw_data):
mock_from_raw_data.side_effect = range(10)
@ -63,7 +63,7 @@ class TestBaseHNVModel(unittest.TestCase):
self.assertEqual(resources, range(10))
@mock.patch("time.sleep")
@mock.patch("hnv_client.client._BaseHNVModel._get_client")
@mock.patch("hnv.client._BaseHNVModel._get_client")
def _test_remove(self, mock_get_client, mock_sleep,
loop_count, timeout):
http_client = mock_get_client.return_value = mock.Mock()
@ -101,9 +101,9 @@ class TestBaseHNVModel(unittest.TestCase):
return {"properties": {"provisioningState": provisioning_state}}
@mock.patch("time.sleep")
@mock.patch("hnv_client.client._BaseHNVModel.process_raw_data")
@mock.patch("hnv_client.client._BaseHNVModel.dump")
@mock.patch("hnv_client.client._BaseHNVModel._get_client")
@mock.patch("hnv.client._BaseHNVModel.process_raw_data")
@mock.patch("hnv.client._BaseHNVModel.dump")
@mock.patch("hnv.client._BaseHNVModel._get_client")
def _test_commit(self, mock_get_client, mock_dump, mock_process,
mock_sleep,
loop_count, timeout, failed, invalid_response):
@ -174,7 +174,7 @@ class TestClient(unittest.TestCase):
self._response = fake_response.FakeResponse()
def _test_get_resource(self, model, raw_data):
with test_utils.LogSnatcher("hnv_client.common.model") as logging:
with test_utils.LogSnatcher("hnv.common.model") as logging:
model.from_raw_data(raw_data)
self.assertEqual(logging.output, [])

View File

@ -21,7 +21,7 @@ import logging as base_logging
from oslo_log import log as oslo_logging
from hnv_client import config as hnv_conf
from hnv import config as hnv_conf
CONFIG = hnv_conf.CONFIG
@ -45,7 +45,7 @@ class LogSnatcher(object):
The class can be used as following::
with LogSnatcher('hnv_client.client') as snatcher:
with LogSnatcher('hnv.client') as snatcher:
LOG.info("doing stuff")
LOG.info("doing stuff %s", 1)
LOG.warn("doing other stuff")

View File

@ -1,5 +1,5 @@
[metadata]
name = hnv_client
name = hnv
version = 0.1.0
summary = Python client for the HNV (Hyper-V Network Virtualization) REST API.
description-file =
@ -23,7 +23,7 @@ classifier =
[files]
packages =
hnv_client
hnv
[global]
setup-hooks =
@ -31,7 +31,7 @@ setup-hooks =
[entry_points]
oslo.config.opts =
hnv_client = hnv_client.config.options:get_options
hnv.conf = hnv.config.options:get_options
[build_sphinx]
all_files = 1

View File

@ -12,11 +12,11 @@ install_command = pip install -U --force-reinstall {opts} {packages}
commands = python setup.py testr --testr-args='{posargs}'
[testenv:pep8]
commands = flake8 hnv_client {posargs}
commands = flake8 hnv {posargs}
deps = flake8
[testenv:pylint]
commands = pylint hnv_client --rcfile={toxinidir}/.pylintrc {posargs}
commands = pylint hnv --rcfile={toxinidir}/.pylintrc {posargs}
deps = pylint
[testenv:cover]