Fix tests to pass gates
Only python2.7 tests were passing. This will fix all tests for python2.6, python3.3, and pep8. Change-Id: I067d4194774d7e2cf2970c49febe52643d7ac21d
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -35,6 +35,9 @@ nosetests.xml
|
|||||||
.project
|
.project
|
||||||
.pydevproject
|
.pydevproject
|
||||||
|
|
||||||
|
# Rope
|
||||||
|
*/.ropeproject/*
|
||||||
|
.ropeproject/*
|
||||||
|
|
||||||
*.DS_Store
|
*.DS_Store
|
||||||
*.log
|
*.log
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
pbr>=0.5.21,<1.0
|
pbr>=0.5.21,<1.0
|
||||||
python-novaclient==2.15.0
|
python-novaclient==2.15.0
|
||||||
pythonwhois==2.0.5
|
# pythonwhois with python 3.3 readiness patch
|
||||||
|
-e git://github.com/joepie91/python-whois.git@655d1ca37497f0f6407c6bdbe0d2bbd0caac8544#egg=pythonwhois
|
||||||
six==1.5.2
|
six==1.5.2
|
||||||
tldextract==1.3.1
|
tldextract==1.3.1
|
||||||
|
|||||||
@@ -26,12 +26,11 @@ Example usage:
|
|||||||
|
|
||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
|
|
||||||
import importlib
|
|
||||||
|
|
||||||
from novaclient.v1_1 import client
|
from novaclient.v1_1 import client
|
||||||
import six
|
import six
|
||||||
|
|
||||||
from satori import dns
|
from satori import dns
|
||||||
|
from satori import utils
|
||||||
|
|
||||||
|
|
||||||
def run(address, config):
|
def run(address, config):
|
||||||
@@ -57,7 +56,7 @@ def run(address, config):
|
|||||||
module_name = config.system_info
|
module_name = config.system_info
|
||||||
if '.' not in module_name:
|
if '.' not in module_name:
|
||||||
module_name = 'satori.sysinfo.%s' % module_name
|
module_name = 'satori.sysinfo.%s' % module_name
|
||||||
system_info_module = importlib.import_module(module_name)
|
system_info_module = utils.import_object(module_name)
|
||||||
result = system_info_module.get_systeminfo(host, config)
|
result = system_info_module.get_systeminfo(host, config)
|
||||||
host['system_info'] = result
|
host['system_info'] = result
|
||||||
|
|
||||||
|
|||||||
@@ -16,8 +16,8 @@ import datetime
|
|||||||
import logging
|
import logging
|
||||||
import socket
|
import socket
|
||||||
|
|
||||||
from six.moves.urllib import parse as urlparse
|
|
||||||
import pythonwhois
|
import pythonwhois
|
||||||
|
from six.moves.urllib import parse as urlparse
|
||||||
import tldextract
|
import tldextract
|
||||||
|
|
||||||
from satori import errors
|
from satori import errors
|
||||||
@@ -28,9 +28,11 @@ LOG = logging.getLogger(__name__)
|
|||||||
def resolve_hostname(host):
|
def resolve_hostname(host):
|
||||||
"""Get IP address of hostname or URL."""
|
"""Get IP address of hostname or URL."""
|
||||||
try:
|
try:
|
||||||
|
if not host:
|
||||||
|
raise AttributeError("Host must be supplied.")
|
||||||
parsed = urlparse.urlparse(host)
|
parsed = urlparse.urlparse(host)
|
||||||
except AttributeError as err:
|
except AttributeError as err:
|
||||||
error = "Hostname `%s`is unparseable. Error: %s" % (host, err)
|
error = "Hostname `%s` is unparseable. Error: %s" % (host, err)
|
||||||
LOG.exception(error)
|
LOG.exception(error)
|
||||||
raise errors.SatoriInvalidNetloc(error)
|
raise errors.SatoriInvalidNetloc(error)
|
||||||
|
|
||||||
|
|||||||
39
satori/utils.py
Normal file
39
satori/utils.py
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
# 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.
|
||||||
|
#
|
||||||
|
"""General utilities."""
|
||||||
|
|
||||||
|
import logging
|
||||||
|
import sys
|
||||||
|
|
||||||
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
def import_class(import_str):
|
||||||
|
"""Return a class from a string including module and class."""
|
||||||
|
mod_str, _, class_str = import_str.rpartition('.')
|
||||||
|
try:
|
||||||
|
__import__(mod_str)
|
||||||
|
return getattr(sys.modules[mod_str], class_str)
|
||||||
|
except (ImportError, ValueError, AttributeError) as exc:
|
||||||
|
LOG.debug('Inner Exception: %s', exc)
|
||||||
|
raise
|
||||||
|
|
||||||
|
|
||||||
|
def import_object(import_str, *args, **kw):
|
||||||
|
"""Return an object including a module or module and class."""
|
||||||
|
try:
|
||||||
|
__import__(import_str)
|
||||||
|
return sys.modules[import_str]
|
||||||
|
except ImportError:
|
||||||
|
cls = import_class(import_str)
|
||||||
|
return cls(*args, **kw)
|
||||||
2
tox.ini
2
tox.ini
@@ -26,4 +26,4 @@ downloadcache = ~/cache/pip
|
|||||||
[flake8]
|
[flake8]
|
||||||
ignore = E126,E202,W602,H302,H402
|
ignore = E126,E202,W602,H302,H402
|
||||||
show-source = True
|
show-source = True
|
||||||
exclude = .venv,.git,.tox,dist,doc,*openstack/common*,*lib/python*,*egg,build,tools,satori/contrib
|
exclude = .venv,.git,.tox,dist,doc,*openstack/common*,*lib/python*,*egg,build,tools,satori/contrib,*.ropeproject
|
||||||
|
|||||||
Reference in New Issue
Block a user