diff --git a/orm/app.py b/orm/app.py index aa55a875..99cd9800 100644 --- a/orm/app.py +++ b/orm/app.py @@ -1,5 +1,5 @@ -from pecan import make_app from orm import model +from pecan import make_app def setup_app(config): diff --git a/orm/common/client/audit/audit_client/tests/api/model/test_get_audits_result.py b/orm/common/client/audit/audit_client/tests/api/model/test_get_audits_result.py index 8b3bc3fd..075b76bd 100644 --- a/orm/common/client/audit/audit_client/tests/api/model/test_get_audits_result.py +++ b/orm/common/client/audit/audit_client/tests/api/model/test_get_audits_result.py @@ -1,8 +1,9 @@ """test_get_audits_result module.""" -from audit_client.api.model.get_audits_result import AuditsResult import unittest +from audit_client.api.model.get_audits_result import AuditsResult + class Test(unittest.TestCase): """test get audits result class.""" diff --git a/orm/common/client/audit/audit_client/tests/api/test_audit.py b/orm/common/client/audit/audit_client/tests/api/test_audit.py index e1af78a8..19cacdcf 100755 --- a/orm/common/client/audit/audit_client/tests/api/test_audit.py +++ b/orm/common/client/audit/audit_client/tests/api/test_audit.py @@ -5,10 +5,9 @@ import threading import unittest import urllib2 -from mock import patch - from audit_client.api import audit from audit_client.api.exceptions.audit_exception import AuditException +from mock import patch class Test(unittest.TestCase): diff --git a/orm/common/client/audit/setup.py b/orm/common/client/audit/setup.py index 17a2583b..8e97bb60 100644 --- a/orm/common/client/audit/setup.py +++ b/orm/common/client/audit/setup.py @@ -17,8 +17,7 @@ # THIS FILE IS MANAGED BY THE GLOBAL REQUIREMENTS REPO - DO NOT EDIT -from setuptools import find_packages -from setuptools import setup +from setuptools import find_packages, setup setup( name='audit_client', diff --git a/orm/common/client/keystone/keystone_utils/tests/unit/test_tokens.py b/orm/common/client/keystone/keystone_utils/tests/unit/test_tokens.py index c8370fed..ec8b24ec 100755 --- a/orm/common/client/keystone/keystone_utils/tests/unit/test_tokens.py +++ b/orm/common/client/keystone/keystone_utils/tests/unit/test_tokens.py @@ -1,8 +1,8 @@ """keystone_utils token validator unittests.""" -import mock import unittest from keystone_utils import tokens +import mock class MyResponse(object): @@ -191,7 +191,7 @@ class TokensTest(unittest.TestCase): tokens.get_token_user, 'a', mock.MagicMock(), 'c') def test_get_token_user_invalid_keystone_version(self): - conf = tokens.TokenConf(*(None,)*5) + conf = tokens.TokenConf(*(None,) * 5) self.assertRaises(ValueError, tokens.get_token_user, 'a', conf, 'c', 'd') @@ -200,7 +200,7 @@ class TokensTest(unittest.TestCase): ks = mock.MagicMock() ks.tokens.validate.side_effect = tokens.v3_client.exceptions.NotFound() mock_get_keystone_client.return_value = ks - conf = tokens.TokenConf(*('3',)*5) + conf = tokens.TokenConf(*('3',) * 5) self.assertIsNone(tokens.get_token_user('a', conf, 'c', 'd')) @mock.patch.object(tokens, '_get_keystone_client') @@ -212,7 +212,7 @@ class TokensTest(unittest.TestCase): ks.tokens.validate.return_value = token_info mock_get_keystone_client.return_value = ks - conf = tokens.TokenConf(*('2.0',)*5) + conf = tokens.TokenConf(*('2.0',) * 5) result = tokens.get_token_user('a', conf, 'c', 'd') self.assertEqual(result.token, 'a') diff --git a/orm/common/client/keystone/keystone_utils/tokens.py b/orm/common/client/keystone/keystone_utils/tokens.py index 7a64153f..20900b24 100755 --- a/orm/common/client/keystone/keystone_utils/tokens.py +++ b/orm/common/client/keystone/keystone_utils/tokens.py @@ -1,10 +1,10 @@ """Token utility module.""" import logging + import requests from keystoneclient.v2_0 import client as v2_client from keystoneclient.v3 import client as v3_client - from orm_common.utils import dictator _verify = False diff --git a/orm/common/client/keystone/mock_keystone/keystoneclient/v2_0/client.py b/orm/common/client/keystone/mock_keystone/keystoneclient/v2_0/client.py index b9600200..45c3a714 100644 --- a/orm/common/client/keystone/mock_keystone/keystoneclient/v2_0/client.py +++ b/orm/common/client/keystone/mock_keystone/keystoneclient/v2_0/client.py @@ -1,4 +1,3 @@ -from keystoneclient import exceptions class Client(object): diff --git a/orm/common/client/keystone/mock_keystone/keystoneclient/v3/client.py b/orm/common/client/keystone/mock_keystone/keystoneclient/v3/client.py index b9600200..45c3a714 100644 --- a/orm/common/client/keystone/mock_keystone/keystoneclient/v3/client.py +++ b/orm/common/client/keystone/mock_keystone/keystoneclient/v3/client.py @@ -1,4 +1,3 @@ -from keystoneclient import exceptions class Client(object): diff --git a/orm/common/client/keystone/setup.py b/orm/common/client/keystone/setup.py index fc3981db..91532c3e 100644 --- a/orm/common/client/keystone/setup.py +++ b/orm/common/client/keystone/setup.py @@ -1,4 +1,4 @@ -from setuptools import setup, find_packages +from setuptools import find_packages, setup setup( name='keystone_utils', diff --git a/orm/common/orm_common/hooks/api_error_hook.py b/orm/common/orm_common/hooks/api_error_hook.py index 9cddff0c..a43bcbe8 100755 --- a/orm/common/orm_common/hooks/api_error_hook.py +++ b/orm/common/orm_common/hooks/api_error_hook.py @@ -1,8 +1,8 @@ import json import logging -from pecan.hooks import PecanHook from orm_common.utils import api_error_utils as err_utils +from pecan.hooks import PecanHook logger = logging.getLogger(__name__) diff --git a/orm/common/orm_common/hooks/security_headers_hook.py b/orm/common/orm_common/hooks/security_headers_hook.py index 791cea99..dbc8f9a8 100755 --- a/orm/common/orm_common/hooks/security_headers_hook.py +++ b/orm/common/orm_common/hooks/security_headers_hook.py @@ -1,4 +1,5 @@ import logging + from pecan.hooks import PecanHook logger = logging.getLogger(__name__) diff --git a/orm/common/orm_common/hooks/transaction_id_hook.py b/orm/common/orm_common/hooks/transaction_id_hook.py index a5780b2b..a7a180be 100755 --- a/orm/common/orm_common/hooks/transaction_id_hook.py +++ b/orm/common/orm_common/hooks/transaction_id_hook.py @@ -1,6 +1,6 @@ +from orm_common.utils import utils from pecan import abort from pecan.hooks import PecanHook -from orm_common.utils import utils class TransactionIdHook(PecanHook): diff --git a/orm/common/orm_common/injector/fang/__init__.py b/orm/common/orm_common/injector/fang/__init__.py index 18404b50..e69de29b 100755 --- a/orm/common/orm_common/injector/fang/__init__.py +++ b/orm/common/orm_common/injector/fang/__init__.py @@ -1,7 +0,0 @@ -''' -''' - -from .di import Di -from .dependency_register import DependencyRegister -from .resource_provider_register import ResourceProviderRegister -from .resolver import DependencyResolver diff --git a/orm/common/orm_common/injector/fang/dependency_register.py b/orm/common/orm_common/injector/fang/dependency_register.py index 7b4d7093..02d62b54 100755 --- a/orm/common/orm_common/injector/fang/dependency_register.py +++ b/orm/common/orm_common/injector/fang/dependency_register.py @@ -18,8 +18,7 @@ class DependencyRegister: @classmethod def _unwrap_func(cls, decorated_func): - ''' - This unwraps a decorated func, returning the inner wrapped func. + '''This unwraps a decorated func, returning the inner wrapped func. This may become unnecessary with Python 3.4's inspect.unwrap(). ''' diff --git a/orm/common/orm_common/injector/fang/di.py b/orm/common/orm_common/injector/fang/di.py index 6a436354..76b4304a 100755 --- a/orm/common/orm_common/injector/fang/di.py +++ b/orm/common/orm_common/injector/fang/di.py @@ -1,6 +1,6 @@ from .dependency_register import DependencyRegister -from .resource_provider_register import ResourceProviderRegister from .resolver import DependencyResolver +from .resource_provider_register import ResourceProviderRegister class Di: diff --git a/orm/common/orm_common/injector/fang/resource_provider_register.py b/orm/common/orm_common/injector/fang/resource_provider_register.py index a9d6dbdf..bc08dfa1 100755 --- a/orm/common/orm_common/injector/fang/resource_provider_register.py +++ b/orm/common/orm_common/injector/fang/resource_provider_register.py @@ -1,9 +1,7 @@ from functools import partial -from .errors import ( - FangError, - ProviderAlreadyRegisteredError, - ProviderNotFoundError) +from .errors import (FangError, ProviderAlreadyRegisteredError, + ProviderNotFoundError) class ResourceProviderRegister: diff --git a/orm/common/orm_common/injector/injector.py b/orm/common/orm_common/injector/injector.py index 8babfdb4..08309a92 100755 --- a/orm/common/orm_common/injector/injector.py +++ b/orm/common/orm_common/injector/injector.py @@ -1,9 +1,9 @@ +import imp +import os + from orm_common.injector import fang from orm_common.utils.sanitize import sanitize_symbol_name -import os -import imp - _di = fang.Di() logger = None diff --git a/orm/common/orm_common/policy/_checks.py b/orm/common/orm_common/policy/_checks.py index 22fef170..4d161939 100755 --- a/orm/common/orm_common/policy/_checks.py +++ b/orm/common/orm_common/policy/_checks.py @@ -19,10 +19,10 @@ import abc import logging import six + from orm_common.utils import api_error_utils as err_utils from orm_common.utils import dictator - logger = logging.getLogger(__name__) registered_checks = {} diff --git a/orm/common/orm_common/policy/_parser.py b/orm/common/orm_common/policy/_parser.py index 5ef04d26..4751cce1 100755 --- a/orm/common/orm_common/policy/_parser.py +++ b/orm/common/orm_common/policy/_parser.py @@ -21,10 +21,8 @@ import re import six import _checks - from oslo_policy._i18n import _LE - LOG = logging.getLogger(__name__) diff --git a/orm/common/orm_common/policy/policy.py b/orm/common/orm_common/policy/policy.py index 72c48200..370e6c43 100755 --- a/orm/common/orm_common/policy/policy.py +++ b/orm/common/orm_common/policy/policy.py @@ -5,10 +5,8 @@ import logging from keystone_utils import tokens from orm_common.utils import api_error_utils as err_utils from orm_common.utils import dictator -from wsme.exc import ClientSideError - - import qolicy +from wsme.exc import ClientSideError logger = logging.getLogger(__name__) _ENFORCER = None diff --git a/orm/common/orm_common/policy/qolicy.py b/orm/common/orm_common/policy/qolicy.py index 5afc9700..8157e686 100755 --- a/orm/common/orm_common/policy/qolicy.py +++ b/orm/common/orm_common/policy/qolicy.py @@ -218,16 +218,13 @@ desired rule name. import logging import os +import _parser from oslo_config import cfg -from oslo_serialization import jsonutils -import six - from oslo_policy import _checks from oslo_policy._i18n import _ -from oslo_policy import opts - -import _parser +from oslo_serialization import jsonutils +import six LOG = logging.getLogger(__name__) diff --git a/orm/common/orm_common/tests/hooks/test_api_error_hook.py b/orm/common/orm_common/tests/hooks/test_api_error_hook.py index a854335b..d49da1b6 100755 --- a/orm/common/orm_common/tests/hooks/test_api_error_hook.py +++ b/orm/common/orm_common/tests/hooks/test_api_error_hook.py @@ -1,8 +1,9 @@ import json +import logging +from unittest import TestCase + import mock from orm_common.hooks import api_error_hook -from unittest import TestCase -import logging logger = logging.getLogger(__name__) diff --git a/orm/common/orm_common/tests/hooks/test_security_headers_hook.py b/orm/common/orm_common/tests/hooks/test_security_headers_hook.py index db0b9108..66f1462b 100755 --- a/orm/common/orm_common/tests/hooks/test_security_headers_hook.py +++ b/orm/common/orm_common/tests/hooks/test_security_headers_hook.py @@ -1,6 +1,7 @@ +from unittest import TestCase + import mock from orm_common.hooks import security_headers_hook -from unittest import TestCase class MyHeaders(object): diff --git a/orm/common/orm_common/tests/hooks/test_transaction_id_hook.py b/orm/common/orm_common/tests/hooks/test_transaction_id_hook.py index f97e0679..2dacac48 100755 --- a/orm/common/orm_common/tests/hooks/test_transaction_id_hook.py +++ b/orm/common/orm_common/tests/hooks/test_transaction_id_hook.py @@ -1,7 +1,8 @@ +import logging +from unittest import TestCase + import mock from orm_common.hooks import transaction_id_hook -from unittest import TestCase -import logging logger = logging.getLogger(__name__) diff --git a/orm/common/orm_common/tests/injector/test_injector.py b/orm/common/orm_common/tests/injector/test_injector.py index 1ac3bb04..994dea70 100755 --- a/orm/common/orm_common/tests/injector/test_injector.py +++ b/orm/common/orm_common/tests/injector/test_injector.py @@ -1,9 +1,9 @@ +import logging +import os +from unittest import TestCase + import mock from orm_common.injector import injector -from unittest import TestCase -import os -import logging -from orm_common.injector.fang.resource_provider_register import ResourceProviderRegister logger = logging.getLogger(__name__) diff --git a/orm/common/orm_common/tests/policy/test_checks.py b/orm/common/orm_common/tests/policy/test_checks.py index 6d1e46cd..3dcc6d0e 100755 --- a/orm/common/orm_common/tests/policy/test_checks.py +++ b/orm/common/orm_common/tests/policy/test_checks.py @@ -1,6 +1,6 @@ -import mock import unittest +import mock from orm_common.policy import _checks from wsme.exc import ClientSideError diff --git a/orm/common/orm_common/tests/policy/test_policy.py b/orm/common/orm_common/tests/policy/test_policy.py index 654d7837..21f7c621 100755 --- a/orm/common/orm_common/tests/policy/test_policy.py +++ b/orm/common/orm_common/tests/policy/test_policy.py @@ -1,8 +1,7 @@ -import mock import unittest +import mock from orm_common.policy import policy -from orm_common.utils import api_error_utils as err_utils class TestException(Exception): diff --git a/orm/common/orm_common/tests/utils/test_api_error_utils.py b/orm/common/orm_common/tests/utils/test_api_error_utils.py index 948874a4..76fa728f 100755 --- a/orm/common/orm_common/tests/utils/test_api_error_utils.py +++ b/orm/common/orm_common/tests/utils/test_api_error_utils.py @@ -1,7 +1,8 @@ import json +from unittest import TestCase + import mock from orm_common.utils import api_error_utils -from unittest import TestCase class TestCrossApiUtil(TestCase): diff --git a/orm/common/orm_common/tests/utils/test_cross_api_utils.py b/orm/common/orm_common/tests/utils/test_cross_api_utils.py index 76037ea0..78371d3a 100755 --- a/orm/common/orm_common/tests/utils/test_cross_api_utils.py +++ b/orm/common/orm_common/tests/utils/test_cross_api_utils.py @@ -1,12 +1,8 @@ +import time +from unittest import TestCase + import mock from orm_common.utils import cross_api_utils -from testfixtures import log_capture -from unittest import TestCase -import requests -import pecan -import logging -import pprint -import time class TestCrossApiUtil(TestCase): diff --git a/orm/common/orm_common/tests/utils/test_utils.py b/orm/common/orm_common/tests/utils/test_utils.py index d9640ef7..6ce8a4c6 100755 --- a/orm/common/orm_common/tests/utils/test_utils.py +++ b/orm/common/orm_common/tests/utils/test_utils.py @@ -1,11 +1,10 @@ +import logging +import pprint +from unittest import TestCase + import mock from orm_common.utils import utils from testfixtures import log_capture -from unittest import TestCase -import requests -import pecan -import logging -import pprint class TestUtil(TestCase): diff --git a/orm/common/orm_common/utils/api_error_utils.py b/orm/common/orm_common/utils/api_error_utils.py index e1fa3cf3..67c51678 100755 --- a/orm/common/orm_common/utils/api_error_utils.py +++ b/orm/common/orm_common/utils/api_error_utils.py @@ -1,4 +1,5 @@ import json + from orm_common.utils import utils from wsme.exc import ClientSideError diff --git a/orm/common/orm_common/utils/cross_api_utils.py b/orm/common/orm_common/utils/cross_api_utils.py index 51ddac36..34b6c5a3 100755 --- a/orm/common/orm_common/utils/cross_api_utils.py +++ b/orm/common/orm_common/utils/cross_api_utils.py @@ -1,9 +1,10 @@ -import requests import logging -from pecan import conf -from audit_client.api import audit import time +import requests + +from pecan import conf + # from orm_common.logger import get_logger # logger = get_logger(__name__) diff --git a/orm/common/orm_common/utils/utils.py b/orm/common/orm_common/utils/utils.py index 0fb95fac..3f2c77dd 100755 --- a/orm/common/orm_common/utils/utils.py +++ b/orm/common/orm_common/utils/utils.py @@ -1,9 +1,11 @@ -import requests import logging -from pecan import conf -from audit_client.api import audit -import time import pprint +import time + +import requests + +from audit_client.api import audit +from pecan import conf # from cms_rest.logger import get_logger # @@ -218,8 +220,7 @@ def get_resource_status(resource_id): def get_time_human(): - """ - this function return the timestamp for output JSON + """this function return the timestamp for output JSON :return: timestamp in wanted format """ return time.strftime("%a, %b %d %Y, %X (%Z)", time.gmtime()) diff --git a/orm/services/audit_trail_manager/audit_server/app.py b/orm/services/audit_trail_manager/audit_server/app.py index 304ade7c..339517ed 100644 --- a/orm/services/audit_trail_manager/audit_server/app.py +++ b/orm/services/audit_trail_manager/audit_server/app.py @@ -2,10 +2,10 @@ import logging import os -from pecan import make_app -from pecan.commands import CommandRunner from audit_server import model from audit_server.storage import factory +from pecan.commands import CommandRunner +from pecan import make_app logger = logging.getLogger(__name__) @@ -32,4 +32,4 @@ def main(): drive, path_and_file = os.path.splitdrive(dir_name) path, filename = os.path.split(path_and_file) runner = CommandRunner() - runner.run(['serve', path+'/config.py']) + runner.run(['serve', path + '/config.py']) diff --git a/orm/services/audit_trail_manager/audit_server/controllers/v1/audit.py b/orm/services/audit_trail_manager/audit_server/controllers/v1/audit.py index 7f4709cb..a5cf18e3 100755 --- a/orm/services/audit_trail_manager/audit_server/controllers/v1/audit.py +++ b/orm/services/audit_trail_manager/audit_server/controllers/v1/audit.py @@ -1,8 +1,6 @@ """audit controller module.""" -from audit_server.controllers.v1 import configuration -from audit_server.controllers.v1 import logs -from audit_server.controllers.v1 import transaction +from audit_server.controllers.v1 import configuration, logs, transaction class AuditController(object): diff --git a/orm/services/audit_trail_manager/audit_server/controllers/v1/configuration.py b/orm/services/audit_trail_manager/audit_server/controllers/v1/configuration.py index f6bdd0bd..c619f82d 100755 --- a/orm/services/audit_trail_manager/audit_server/controllers/v1/configuration.py +++ b/orm/services/audit_trail_manager/audit_server/controllers/v1/configuration.py @@ -1,28 +1,28 @@ -"""Configuration rest API input module.""" - -import logging -from orm_common.utils import utils -from pecan import conf -from pecan import rest -from wsmeext.pecan import wsexpose - -logger = logging.getLogger(__name__) - - -class ConfigurationController(rest.RestController): - """Configuration controller.""" - - @wsexpose(str, str, status_code=200) - def get(self, dump_to_log='false'): - """get method. - - :param dump_to_log: A boolean string that says whether the - configuration should be written to log - :return: A pretty string that contains the service's configuration - """ - logger.info("Get configuration...") - - dump = dump_to_log.lower() == 'true' - utils.set_utils_conf(conf) - result = utils.report_config(conf, dump, logger) - return result +"""Configuration rest API input module.""" + +import logging + +from orm_common.utils import utils +from pecan import conf, rest +from wsmeext.pecan import wsexpose + +logger = logging.getLogger(__name__) + + +class ConfigurationController(rest.RestController): + """Configuration controller.""" + + @wsexpose(str, str, status_code=200) + def get(self, dump_to_log='false'): + """get method. + + :param dump_to_log: A boolean string that says whether the + configuration should be written to log + :return: A pretty string that contains the service's configuration + """ + logger.info("Get configuration...") + + dump = dump_to_log.lower() == 'true' + utils.set_utils_conf(conf) + result = utils.report_config(conf, dump, logger) + return result diff --git a/orm/services/audit_trail_manager/audit_server/controllers/v1/logs.py b/orm/services/audit_trail_manager/audit_server/controllers/v1/logs.py index e8d7b1bb..13e67429 100644 --- a/orm/services/audit_trail_manager/audit_server/controllers/v1/logs.py +++ b/orm/services/audit_trail_manager/audit_server/controllers/v1/logs.py @@ -1,7 +1,7 @@ import logging +import wsme from pecan import rest -import wsme from wsmeext.pecan import wsexpose logger = logging.getLogger(__name__) diff --git a/orm/services/audit_trail_manager/audit_server/controllers/v1/transaction.py b/orm/services/audit_trail_manager/audit_server/controllers/v1/transaction.py index 0407e5fa..40b27c97 100755 --- a/orm/services/audit_trail_manager/audit_server/controllers/v1/transaction.py +++ b/orm/services/audit_trail_manager/audit_server/controllers/v1/transaction.py @@ -1,16 +1,16 @@ """transaction controller module.""" +import base +import logging +import wsme + from audit_server.model.transaction import Model as TransactionModel from audit_server.model.transaction_query import Model as QueryModel from audit_server.services import transaction as transaction_service -import base -import logging from pecan import rest -import wsme from wsme import types as wtypes from wsmeext.pecan import wsexpose - logger = logging.getLogger(__name__) diff --git a/orm/services/audit_trail_manager/audit_server/external_mock/orm_common/utils/utils.py b/orm/services/audit_trail_manager/audit_server/external_mock/orm_common/utils/utils.py index e1fc153a..ba516a7a 100755 --- a/orm/services/audit_trail_manager/audit_server/external_mock/orm_common/utils/utils.py +++ b/orm/services/audit_trail_manager/audit_server/external_mock/orm_common/utils/utils.py @@ -1,13 +1,13 @@ -"""Utils module mock.""" - - -def report_config(conf, dump=False): - """Mock report_config function.""" - - pass - - -def set_utils_conf(conf): - """Mock set_utils_conf function.""" - - pass +"""Utils module mock.""" + + +def report_config(conf, dump=False): + """Mock report_config function.""" + + pass + + +def set_utils_conf(conf): + """Mock set_utils_conf function.""" + + pass diff --git a/orm/services/audit_trail_manager/audit_server/storage/mysql/transaction.py b/orm/services/audit_trail_manager/audit_server/storage/mysql/transaction.py index c25b31b1..b44960f3 100755 --- a/orm/services/audit_trail_manager/audit_server/storage/mysql/transaction.py +++ b/orm/services/audit_trail_manager/audit_server/storage/mysql/transaction.py @@ -2,15 +2,13 @@ import logging -from sqlalchemy import Column, Integer, Text, BigInteger, asc -from sqlalchemy import create_engine +from audit_server.model.transaction import Model +from audit_server.storage import transaction +from sqlalchemy import BigInteger, Column, Integer, Text, asc, create_engine from sqlalchemy.exc import IntegrityError from sqlalchemy.ext.declarative.api import declarative_base from sqlalchemy.orm import sessionmaker -from audit_server.model.transaction import Model -from audit_server.storage import transaction - Base = declarative_base() logger = logging.getLogger(__name__) diff --git a/orm/services/audit_trail_manager/audit_server/tests/controllers/functional_test.py b/orm/services/audit_trail_manager/audit_server/tests/controllers/functional_test.py index 6bf55bb6..b1f9fd86 100755 --- a/orm/services/audit_trail_manager/audit_server/tests/controllers/functional_test.py +++ b/orm/services/audit_trail_manager/audit_server/tests/controllers/functional_test.py @@ -1,8 +1,9 @@ """Base classes for API tests.""" +import unittest + import pecan import pecan.testing -import unittest class FunctionalTest(unittest.TestCase): diff --git a/orm/services/audit_trail_manager/audit_server/tests/controllers/v1/test_base.py b/orm/services/audit_trail_manager/audit_server/tests/controllers/v1/test_base.py index b2c62ca2..51fff921 100644 --- a/orm/services/audit_trail_manager/audit_server/tests/controllers/v1/test_base.py +++ b/orm/services/audit_trail_manager/audit_server/tests/controllers/v1/test_base.py @@ -1,11 +1,12 @@ """test_base module.""" -from audit_server.controllers.v1.base import ClientSideError -from audit_server.controllers.v1.base import EntityNotFoundError -from audit_server.controllers.v1.base import InputValueError import unittest +from audit_server.controllers.v1.base import (ClientSideError, + EntityNotFoundError, + InputValueError) + class Test(unittest.TestCase): """test case class.""" diff --git a/orm/services/audit_trail_manager/audit_server/tests/controllers/v1/test_configuration.py b/orm/services/audit_trail_manager/audit_server/tests/controllers/v1/test_configuration.py index aa94c050..24ebd5d8 100755 --- a/orm/services/audit_trail_manager/audit_server/tests/controllers/v1/test_configuration.py +++ b/orm/services/audit_trail_manager/audit_server/tests/controllers/v1/test_configuration.py @@ -1,14 +1,14 @@ -"""Get configuration module unittests.""" -from audit_server.controllers.v1 import configuration as root -from audit_server.tests.controllers.v1.functional_test import FunctionalTest -from mock import patch - - -class TestGetConfiguration(FunctionalTest): - """Main get configuration test case.""" - - @patch.object(root.utils, 'report_config', return_value='12345') - def test_get_configuration_success(self, input): - """Test get_configuration returns the expected value on success.""" - response = self.app.get('/v1/audit/configuration') - self.assertEqual(response.json, '12345') +"""Get configuration module unittests.""" +from audit_server.controllers.v1 import configuration as root +from audit_server.tests.controllers.v1.functional_test import FunctionalTest +from mock import patch + + +class TestGetConfiguration(FunctionalTest): + """Main get configuration test case.""" + + @patch.object(root.utils, 'report_config', return_value='12345') + def test_get_configuration_success(self, input): + """Test get_configuration returns the expected value on success.""" + response = self.app.get('/v1/audit/configuration') + self.assertEqual(response.json, '12345') diff --git a/orm/services/audit_trail_manager/audit_server/tests/controllers/v1/test_logs.py b/orm/services/audit_trail_manager/audit_server/tests/controllers/v1/test_logs.py index 80a7377e..3c5634f3 100755 --- a/orm/services/audit_trail_manager/audit_server/tests/controllers/v1/test_logs.py +++ b/orm/services/audit_trail_manager/audit_server/tests/controllers/v1/test_logs.py @@ -1,25 +1,25 @@ -"""Logs module unittests.""" -from audit_server.tests.controllers.v1.functional_test import FunctionalTest - - -class TestLogs(FunctionalTest): - """logs tests.""" - - def test_change_log_level_fail(self): - response = self.app.put('/v1/audit/logs/1') - expected_result = { - "result": "Fail to change log_level. Reason: " - "The given log level [1] doesn't exist."} - self.assertEqual(expected_result, response.json) - - def test_change_log_level_none(self): - response = self.app.put('/v1/audit/logs', expect_errors=True) - expected_result = 'Missing argument: "level"' - self.assertEqual(response.json["faultstring"], expected_result) - self.assertEqual(response.status_code, 400) - - def test_change_log_level_success(self): - response = self.app.put('/v1/audit/logs/debug') - expected_result = {'result': 'Log level changed to debug.'} - self.assertEqual(response.json, expected_result) - self.assertEqual(response.status_code, 201) +"""Logs module unittests.""" +from audit_server.tests.controllers.v1.functional_test import FunctionalTest + + +class TestLogs(FunctionalTest): + """logs tests.""" + + def test_change_log_level_fail(self): + response = self.app.put('/v1/audit/logs/1') + expected_result = { + "result": "Fail to change log_level. Reason: " + "The given log level [1] doesn't exist."} + self.assertEqual(expected_result, response.json) + + def test_change_log_level_none(self): + response = self.app.put('/v1/audit/logs', expect_errors=True) + expected_result = 'Missing argument: "level"' + self.assertEqual(response.json["faultstring"], expected_result) + self.assertEqual(response.status_code, 400) + + def test_change_log_level_success(self): + response = self.app.put('/v1/audit/logs/debug') + expected_result = {'result': 'Log level changed to debug.'} + self.assertEqual(response.json, expected_result) + self.assertEqual(response.status_code, 201) diff --git a/orm/services/audit_trail_manager/audit_server/tests/controllers/v1/test_transaction.py b/orm/services/audit_trail_manager/audit_server/tests/controllers/v1/test_transaction.py index 3e2a550e..878efa1d 100755 --- a/orm/services/audit_trail_manager/audit_server/tests/controllers/v1/test_transaction.py +++ b/orm/services/audit_trail_manager/audit_server/tests/controllers/v1/test_transaction.py @@ -1,14 +1,13 @@ """test_transaction module.""" -from mock import patch - from audit_server.controllers.v1.transaction import QueryResult from audit_server.model.transaction import Model as TransactionModel from audit_server.model.transaction_query_result import \ Model as TransactionQueryResultModel from audit_server.services import transaction as transaction_service from audit_server.tests.controllers.v1.functional_test import FunctionalTest +from mock import patch class Test(FunctionalTest): diff --git a/orm/services/audit_trail_manager/audit_server/tests/services/test_base.py b/orm/services/audit_trail_manager/audit_server/tests/services/test_base.py index a94506cd..27810e60 100644 --- a/orm/services/audit_trail_manager/audit_server/tests/services/test_base.py +++ b/orm/services/audit_trail_manager/audit_server/tests/services/test_base.py @@ -1,9 +1,10 @@ """test_base module.""" -from audit_server.services.base import Error import unittest +from audit_server.services.base import Error + class Test(unittest.TestCase): """test base class.""" diff --git a/orm/services/audit_trail_manager/audit_server/tests/services/test_transaction.py b/orm/services/audit_trail_manager/audit_server/tests/services/test_transaction.py index 3916e56b..25da2871 100755 --- a/orm/services/audit_trail_manager/audit_server/tests/services/test_transaction.py +++ b/orm/services/audit_trail_manager/audit_server/tests/services/test_transaction.py @@ -2,12 +2,11 @@ import unittest -from mock import patch - from audit_server.model.transaction import Model as TransactionModel from audit_server.model.transaction_query import Model as TransactionQuery from audit_server.services import transaction as TransactionService from audit_server.storage import factory +from mock import patch class Test(unittest.TestCase): diff --git a/orm/services/audit_trail_manager/audit_server/tests/storage/mysql/test_transaction.py b/orm/services/audit_trail_manager/audit_server/tests/storage/mysql/test_transaction.py index 87d38b23..9105f1f9 100755 --- a/orm/services/audit_trail_manager/audit_server/tests/storage/mysql/test_transaction.py +++ b/orm/services/audit_trail_manager/audit_server/tests/storage/mysql/test_transaction.py @@ -2,18 +2,15 @@ import unittest +from audit_server.model.transaction import Model as TransactionModel +from audit_server.model.transaction_query import Model as TransactionQueryModel +from audit_server.storage.mysql.transaction import Connection, Record from mock import patch from sqlalchemy import create_engine from sqlalchemy.exc import IntegrityError from sqlalchemy.orm import sessionmaker -from audit_server.model.transaction import Model as TransactionModel -from audit_server.model.transaction_query import Model as TransactionQueryModel -from audit_server.storage.mysql.transaction import Connection -from audit_server.storage.mysql.transaction import Record - - class Test(unittest.TestCase): """test transaction class.""" diff --git a/orm/services/audit_trail_manager/audit_server/tests/storage/test_factory.py b/orm/services/audit_trail_manager/audit_server/tests/storage/test_factory.py index 0ca8d81e..0ddc3fd6 100644 --- a/orm/services/audit_trail_manager/audit_server/tests/storage/test_factory.py +++ b/orm/services/audit_trail_manager/audit_server/tests/storage/test_factory.py @@ -1,10 +1,11 @@ """test_factory module.""" +import unittest + from audit_server.storage import factory from audit_server.storage.mysql.transaction import Connection from mock import patch from sqlalchemy import create_engine -import unittest class Test(unittest.TestCase): diff --git a/orm/services/audit_trail_manager/audit_server/tests/storage/test_transaction.py b/orm/services/audit_trail_manager/audit_server/tests/storage/test_transaction.py index cd360a42..45a5dc28 100644 --- a/orm/services/audit_trail_manager/audit_server/tests/storage/test_transaction.py +++ b/orm/services/audit_trail_manager/audit_server/tests/storage/test_transaction.py @@ -1,9 +1,10 @@ """test_transaction module.""" -from audit_server.storage.transaction import Base import unittest +from audit_server.storage.transaction import Base + class Test(unittest.TestCase): """test transaction class.""" diff --git a/orm/services/customer_manager/cms_rest/app.py b/orm/services/customer_manager/cms_rest/app.py index 57944115..c33c908c 100755 --- a/orm/services/customer_manager/cms_rest/app.py +++ b/orm/services/customer_manager/cms_rest/app.py @@ -1,12 +1,13 @@ -from pecan import make_app -from cms_rest import model -from orm_common.utils import utils -from cms_rest.logger import get_logger -from pecan.commands import CommandRunner -from orm_common.policy import policy -from cms_rest.utils import authentication import os +from cms_rest.logger import get_logger +from cms_rest import model +from cms_rest.utils import authentication +from orm_common.policy import policy +from orm_common.utils import utils +from pecan.commands import CommandRunner +from pecan import make_app + logger = get_logger(__name__) @@ -33,4 +34,4 @@ def main(): drive, path_and_file = os.path.splitdrive(dir_name) path, filename = os.path.split(path_and_file) runner = CommandRunner() - runner.run(['serve', path+'/config.py']) + runner.run(['serve', path + '/config.py']) diff --git a/orm/services/customer_manager/cms_rest/controllers/root.py b/orm/services/customer_manager/cms_rest/controllers/root.py index ff4ba865..39688a98 100755 --- a/orm/services/customer_manager/cms_rest/controllers/root.py +++ b/orm/services/customer_manager/cms_rest/controllers/root.py @@ -1,9 +1,5 @@ -from pecan import expose, request, response -from webob.exc import status_map -from pecan.secure import SecureController from cms_rest.controllers.v1 import root as v1 -from cms_rest.utils import authentication -from pecan import conf +from pecan import expose class RootController(object): @@ -12,8 +8,7 @@ class RootController(object): @expose(template='json') def _default(self): - """ - Method to handle GET / + """Method to handle GET / parameters: None return: dict describing cms rest version information """ diff --git a/orm/services/customer_manager/cms_rest/controllers/v1/base.py b/orm/services/customer_manager/cms_rest/controllers/v1/base.py index 8fb3c48b..66c80fa8 100644 --- a/orm/services/customer_manager/cms_rest/controllers/v1/base.py +++ b/orm/services/customer_manager/cms_rest/controllers/v1/base.py @@ -1,7 +1,6 @@ -import wsme from pecan import response +import wsme from wsme import types as wtypes -import inspect class ClientSideError(wsme.exc.ClientSideError): diff --git a/orm/services/customer_manager/cms_rest/controllers/v1/orm/configuration.py b/orm/services/customer_manager/cms_rest/controllers/v1/orm/configuration.py index 258132fc..c619f82d 100755 --- a/orm/services/customer_manager/cms_rest/controllers/v1/orm/configuration.py +++ b/orm/services/customer_manager/cms_rest/controllers/v1/orm/configuration.py @@ -1,11 +1,10 @@ """Configuration rest API input module.""" import logging -from orm_common.utils import utils -from pecan import conf -from pecan import rest -from wsmeext.pecan import wsexpose +from orm_common.utils import utils +from pecan import conf, rest +from wsmeext.pecan import wsexpose logger = logging.getLogger(__name__) diff --git a/orm/services/customer_manager/cms_rest/controllers/v1/orm/customer/enabled.py b/orm/services/customer_manager/cms_rest/controllers/v1/orm/customer/enabled.py index 0b3d0021..386631c7 100755 --- a/orm/services/customer_manager/cms_rest/controllers/v1/orm/customer/enabled.py +++ b/orm/services/customer_manager/cms_rest/controllers/v1/orm/customer/enabled.py @@ -1,14 +1,13 @@ -from pecan import rest, request -from wsmeext.pecan import wsexpose - -from orm_common.utils import utils -from orm_common.utils import api_error_utils as err_utils -from cms_rest.model.Models import Enabled, CustomerResultWrapper +from cms_rest.logger import get_logger from cms_rest.logic.customer_logic import CustomerLogic from cms_rest.logic.error_base import ErrorStatus +from cms_rest.model.Models import CustomerResultWrapper, Enabled from cms_rest.utils import authentication +from orm_common.utils import api_error_utils as err_utils +from orm_common.utils import utils +from pecan import request, rest +from wsmeext.pecan import wsexpose -from cms_rest.logger import get_logger LOG = get_logger(__name__) diff --git a/orm/services/customer_manager/cms_rest/controllers/v1/orm/customer/metadata.py b/orm/services/customer_manager/cms_rest/controllers/v1/orm/customer/metadata.py index 2c4aae20..41cfb501 100755 --- a/orm/services/customer_manager/cms_rest/controllers/v1/orm/customer/metadata.py +++ b/orm/services/customer_manager/cms_rest/controllers/v1/orm/customer/metadata.py @@ -1,15 +1,13 @@ -from pecan import rest, request -from wsmeext.pecan import wsexpose -from cms_rest.model.Models import CustomerResultWrapper -from orm_common.utils import utils -from orm_common.utils import api_error_utils as err_utils - -from cms_rest.logic.error_base import ErrorStatus -from cms_rest.model.Models import MetadataWrapper -import cms_rest.logic.metadata_logic as logic -from cms_rest.utils import authentication - from cms_rest.logger import get_logger +from cms_rest.logic.error_base import ErrorStatus +import cms_rest.logic.metadata_logic as logic +from cms_rest.model.Models import CustomerResultWrapper, MetadataWrapper +from cms_rest.utils import authentication +from orm_common.utils import api_error_utils as err_utils +from orm_common.utils import utils +from pecan import request, rest +from wsmeext.pecan import wsexpose + LOG = get_logger(__name__) diff --git a/orm/services/customer_manager/cms_rest/controllers/v1/orm/customer/regions.py b/orm/services/customer_manager/cms_rest/controllers/v1/orm/customer/regions.py index c830a552..a31514ff 100755 --- a/orm/services/customer_manager/cms_rest/controllers/v1/orm/customer/regions.py +++ b/orm/services/customer_manager/cms_rest/controllers/v1/orm/customer/regions.py @@ -1,17 +1,15 @@ +from cms_rest.controllers.v1.orm.customer.users import UserController +from cms_rest.logger import get_logger +from cms_rest.logic.customer_logic import CustomerLogic +from cms_rest.logic.error_base import ErrorStatus +from cms_rest.model.Models import Region, RegionResultWrapper +from cms_rest.utils import authentication +from orm_common.utils import api_error_utils as err_utils +from orm_common.utils import utils from oslo_db.exception import DBDuplicateEntry -from pecan import rest, request +from pecan import request, rest from wsmeext.pecan import wsexpose -from orm_common.utils import utils -from orm_common.utils import api_error_utils as err_utils - -from cms_rest.controllers.v1.orm.customer.users import UserController -from cms_rest.model.Models import Region, RegionResultWrapper -from cms_rest.logic.customer_logic import CustomerLogic -from cms_rest.logic.error_base import ErrorStatus, DuplicateEntryError -from cms_rest.utils import authentication - -from cms_rest.logger import get_logger LOG = get_logger(__name__) diff --git a/orm/services/customer_manager/cms_rest/controllers/v1/orm/customer/root.py b/orm/services/customer_manager/cms_rest/controllers/v1/orm/customer/root.py index 804c93e1..ac80c51c 100755 --- a/orm/services/customer_manager/cms_rest/controllers/v1/orm/customer/root.py +++ b/orm/services/customer_manager/cms_rest/controllers/v1/orm/customer/root.py @@ -2,17 +2,16 @@ from pecan import rest, request, response import oslo_db from wsmeext.pecan import wsexpose -from cms_rest.model.Models import Customer, CustomerResultWrapper, CustomerSummaryResponse -from cms_rest.controllers.v1.orm.customer.users import DefaultUserController -from cms_rest.controllers.v1.orm.customer.regions import RegionController -from cms_rest.controllers.v1.orm.customer.metadata import MetadataController from cms_rest.controllers.v1.orm.customer.enabled import EnabledController +from cms_rest.controllers.v1.orm.customer.metadata import MetadataController +from cms_rest.controllers.v1.orm.customer.regions import RegionController +from cms_rest.controllers.v1.orm.customer.users import DefaultUserController from cms_rest.logic.customer_logic import CustomerLogic - from cms_rest.logic.error_base import ErrorStatus -from orm_common.utils import utils -from orm_common.utils import api_error_utils as err_utils +from cms_rest.model.Models import Customer, CustomerResultWrapper, CustomerSummaryResponse from cms_rest.utils import authentication +from orm_common.utils import api_error_utils as err_utils +from orm_common.utils import utils from cms_rest.logger import get_logger diff --git a/orm/services/customer_manager/cms_rest/controllers/v1/orm/customer/users.py b/orm/services/customer_manager/cms_rest/controllers/v1/orm/customer/users.py index ab0876e1..bae532c9 100755 --- a/orm/services/customer_manager/cms_rest/controllers/v1/orm/customer/users.py +++ b/orm/services/customer_manager/cms_rest/controllers/v1/orm/customer/users.py @@ -1,15 +1,13 @@ -from pecan import rest, request -from wsmeext.pecan import wsexpose - -from orm_common.utils import utils -from orm_common.utils import api_error_utils as err_utils - -from cms_rest.model.Models import User, UserResultWrapper +from cms_rest.logger import get_logger from cms_rest.logic.customer_logic import CustomerLogic from cms_rest.logic.error_base import ErrorStatus, NotFound +from cms_rest.model.Models import User, UserResultWrapper from cms_rest.utils import authentication +from orm_common.utils import api_error_utils as err_utils +from orm_common.utils import utils +from pecan import request, rest +from wsmeext.pecan import wsexpose -from cms_rest.logger import get_logger LOG = get_logger(__name__) diff --git a/orm/services/customer_manager/cms_rest/controllers/v1/orm/root.py b/orm/services/customer_manager/cms_rest/controllers/v1/orm/root.py index f6708f01..8472f180 100755 --- a/orm/services/customer_manager/cms_rest/controllers/v1/orm/root.py +++ b/orm/services/customer_manager/cms_rest/controllers/v1/orm/root.py @@ -1,6 +1,6 @@ +from cms_rest.controllers.v1.orm.configuration import ConfigurationController from cms_rest.controllers.v1.orm.customer.root import CustomerController from cms_rest.controllers.v1.orm.logs import LogsController -from cms_rest.controllers.v1.orm.configuration import ConfigurationController from pecan.rest import RestController diff --git a/orm/services/customer_manager/cms_rest/data/data_manager.py b/orm/services/customer_manager/cms_rest/data/data_manager.py index 6ed9b19f..fa953466 100755 --- a/orm/services/customer_manager/cms_rest/data/data_manager.py +++ b/orm/services/customer_manager/cms_rest/data/data_manager.py @@ -1,20 +1,19 @@ -import oslo_db -from oslo_db.sqlalchemy import session as db_session -from sqlalchemy.event import listen -from sqlalchemy import or_ -from cms_rest.logic.error_base import ErrorStatus - -from pecan import conf - import logging -from cms_rest.data.sql_alchemy.models import CmsRole, CmsUser, Customer, \ - CustomerRegion, Quota, QuotaFieldDetail, \ - Region, UserRole from cms_rest.data.sql_alchemy.customer_record import CustomerRecord from cms_rest.data.sql_alchemy.customer_region_record import \ CustomerRegionRecord +from cms_rest.data.sql_alchemy.models import (CmsRole, CmsUser, Customer, + CustomerRegion, Quota, + QuotaFieldDetail, Region, + UserRole) from cms_rest.data.sql_alchemy.user_role_record import UserRoleRecord +from cms_rest.logic.error_base import ErrorStatus +import oslo_db +from oslo_db.sqlalchemy import session as db_session +from pecan import conf +from sqlalchemy.event import listen +from sqlalchemy import or_ LOG = logging.getLogger(__name__) diff --git a/orm/services/customer_manager/cms_rest/data/sql_alchemy/base.py b/orm/services/customer_manager/cms_rest/data/sql_alchemy/base.py index c64447da..860e5425 100644 --- a/orm/services/customer_manager/cms_rest/data/sql_alchemy/base.py +++ b/orm/services/customer_manager/cms_rest/data/sql_alchemy/base.py @@ -1,2 +1,3 @@ from sqlalchemy.ext.declarative import declarative_base + Base = declarative_base() diff --git a/orm/services/customer_manager/cms_rest/data/sql_alchemy/cms_user_record.py b/orm/services/customer_manager/cms_rest/data/sql_alchemy/cms_user_record.py index c6aa2f5a..4a556007 100755 --- a/orm/services/customer_manager/cms_rest/data/sql_alchemy/cms_user_record.py +++ b/orm/services/customer_manager/cms_rest/data/sql_alchemy/cms_user_record.py @@ -1,6 +1,6 @@ from cms_rest.data.sql_alchemy.models import CmsUser - from cms_rest.logger import get_logger + LOG = get_logger(__name__) diff --git a/orm/services/customer_manager/cms_rest/data/sql_alchemy/customer_record.py b/orm/services/customer_manager/cms_rest/data/sql_alchemy/customer_record.py index fc47a609..7e12d232 100755 --- a/orm/services/customer_manager/cms_rest/data/sql_alchemy/customer_record.py +++ b/orm/services/customer_manager/cms_rest/data/sql_alchemy/customer_record.py @@ -1,8 +1,10 @@ -from cms_rest.data.sql_alchemy.models import Customer, Region, CustomerRegion, UserRole, CmsUser, CustomerMetadata -from sqlalchemy import and_, func from __builtin__ import int +from cms_rest.data.sql_alchemy.models import (CmsUser, Customer, + CustomerMetadata, CustomerRegion, + Region, UserRole) from cms_rest.logger import get_logger +from sqlalchemy import func LOG = get_logger(__name__) @@ -85,8 +87,7 @@ class CustomerRecord: raise def _build_meta_query(self, metadata): - """ - build query for having list of metadata + """build query for having list of metadata get list of keys and list of values quereis :param metadata: :return: diff --git a/orm/services/customer_manager/cms_rest/data/sql_alchemy/customer_region_record.py b/orm/services/customer_manager/cms_rest/data/sql_alchemy/customer_region_record.py index c3821795..1d81323b 100755 --- a/orm/services/customer_manager/cms_rest/data/sql_alchemy/customer_region_record.py +++ b/orm/services/customer_manager/cms_rest/data/sql_alchemy/customer_region_record.py @@ -1,7 +1,6 @@ -from cms_rest.data.sql_alchemy.models import CustomerRegion from cms_rest.data.sql_alchemy.customer_record import CustomerRecord +from cms_rest.data.sql_alchemy.models import CustomerRegion from cms_rest.data.sql_alchemy.region_record import RegionRecord - from cms_rest.logger import get_logger LOG = get_logger(__name__) diff --git a/orm/services/customer_manager/cms_rest/data/sql_alchemy/models.py b/orm/services/customer_manager/cms_rest/data/sql_alchemy/models.py index 3fe7d474..f95ce1ce 100755 --- a/orm/services/customer_manager/cms_rest/data/sql_alchemy/models.py +++ b/orm/services/customer_manager/cms_rest/data/sql_alchemy/models.py @@ -1,11 +1,10 @@ -from sqlalchemy import Column, Integer, String, SmallInteger, ForeignKey -from sqlalchemy.orm import relationship from cms_rest.data.sql_alchemy.base import Base -import wsme - +import cms_rest.model.Models as WsmeModels from oslo_db.sqlalchemy import models -import cms_rest.model.Models as WsmeModels +from sqlalchemy import Column, ForeignKey, Integer, SmallInteger, String +from sqlalchemy.orm import relationship +import wsme class CMSBaseModel(models.ModelBase): diff --git a/orm/services/customer_manager/cms_rest/data/sql_alchemy/region_record.py b/orm/services/customer_manager/cms_rest/data/sql_alchemy/region_record.py index d6909d1b..a0386d8b 100755 --- a/orm/services/customer_manager/cms_rest/data/sql_alchemy/region_record.py +++ b/orm/services/customer_manager/cms_rest/data/sql_alchemy/region_record.py @@ -1,7 +1,6 @@ from cms_rest.data.sql_alchemy.models import Region -from cms_rest.data.sql_alchemy.customer_record import CustomerRecord - from cms_rest.logger import get_logger + LOG = get_logger(__name__) diff --git a/orm/services/customer_manager/cms_rest/data/sql_alchemy/user_role_record.py b/orm/services/customer_manager/cms_rest/data/sql_alchemy/user_role_record.py index 9ec6f636..c44b1856 100755 --- a/orm/services/customer_manager/cms_rest/data/sql_alchemy/user_role_record.py +++ b/orm/services/customer_manager/cms_rest/data/sql_alchemy/user_role_record.py @@ -1,10 +1,10 @@ -from cms_rest.data.sql_alchemy.models import * -from cms_rest.data.sql_alchemy.customer_record import CustomerRecord from cms_rest.data.sql_alchemy.cms_user_record import CmsUserRecord +from cms_rest.data.sql_alchemy.customer_record import CustomerRecord +from cms_rest.data.sql_alchemy.models import * from cms_rest.data.sql_alchemy.region_record import RegionRecord +from cms_rest.logger import get_logger from cms_rest.logic.error_base import NotFound -from cms_rest.logger import get_logger LOG = get_logger(__name__) diff --git a/orm/services/customer_manager/cms_rest/logic/customer_logic.py b/orm/services/customer_manager/cms_rest/logic/customer_logic.py index df2fc94a..2bdfd8ca 100755 --- a/orm/services/customer_manager/cms_rest/logic/customer_logic.py +++ b/orm/services/customer_manager/cms_rest/logic/customer_logic.py @@ -1,21 +1,19 @@ -from cms_rest.model.Models import CustomerResultWrapper -from cms_rest.model.Models import RegionResultWrapper -from cms_rest.model.Models import UserResultWrapper -from cms_rest.model.Models import CustomerSummaryResponse, CustomerSummary -from cms_rest.rds_proxy import RdsProxy -from cms_rest.data.data_manager import DataManager -from cms_rest.data.sql_alchemy.models import UserRole -from cms_rest.logic.error_base import ErrorStatus, NotFound, DuplicateEntryError -from cms_rest.data.sql_alchemy.models import CustomerMetadata -from orm_common.utils.cross_api_utils import get_regions_of_group, set_utils_conf -from orm_common.utils import utils - -from pecan import conf, request - -import pecan import requests +from cms_rest.data.data_manager import DataManager +from cms_rest.data.sql_alchemy.models import CustomerMetadata, UserRole from cms_rest.logger import get_logger +from cms_rest.logic.error_base import (DuplicateEntryError, ErrorStatus, + NotFound) +from cms_rest.model.Models import (CustomerResultWrapper, CustomerSummary, + CustomerSummaryResponse, + RegionResultWrapper, UserResultWrapper) +from cms_rest.rds_proxy import RdsProxy +from orm_common.utils import utils +from orm_common.utils.cross_api_utils import (get_regions_of_group, + set_utils_conf) +import pecan +from pecan import conf, request LOG = get_logger(__name__) @@ -698,8 +696,7 @@ class CustomerLogic(object): def build_response(customer_uuid, transaction_id, context): - """ - this function generate th customer action response JSON + """this function generate th customer action response JSON :param customer_uuid: :param transaction_id: :param context: create or update diff --git a/orm/services/customer_manager/cms_rest/logic/metadata_logic.py b/orm/services/customer_manager/cms_rest/logic/metadata_logic.py index 1de4a6b6..14cc7db7 100755 --- a/orm/services/customer_manager/cms_rest/logic/metadata_logic.py +++ b/orm/services/customer_manager/cms_rest/logic/metadata_logic.py @@ -1,12 +1,12 @@ -from cms_rest.data.sql_alchemy.models import CustomerMetadata +import json + from cms_rest.data.data_manager import DataManager -from cms_rest.rds_proxy import RdsProxy +from cms_rest.data.sql_alchemy.models import CustomerMetadata +from cms_rest.logger import get_logger from cms_rest.model.Models import CustomerResultWrapper +from cms_rest.rds_proxy import RdsProxy from orm_common.utils import utils from pecan import request -from pecan import conf -import json -from cms_rest.logger import get_logger logger = get_logger(__name__) diff --git a/orm/services/customer_manager/cms_rest/model/Model.py b/orm/services/customer_manager/cms_rest/model/Model.py index f6a4fd67..4fe0d82d 100644 --- a/orm/services/customer_manager/cms_rest/model/Model.py +++ b/orm/services/customer_manager/cms_rest/model/Model.py @@ -1,6 +1,5 @@ -import inspect -from wsme import types as wtypes from wsme.rest.json import tojson +from wsme import types as wtypes class Model(wtypes.DynamicBase): diff --git a/orm/services/customer_manager/cms_rest/model/Models.py b/orm/services/customer_manager/cms_rest/model/Models.py index 8a9a2d45..25abc981 100755 --- a/orm/services/customer_manager/cms_rest/model/Models.py +++ b/orm/services/customer_manager/cms_rest/model/Models.py @@ -1,9 +1,10 @@ +from cms_rest.logic.error_base import ErrorStatus +from cms_rest.model.Model import Model +from orm_common.utils.cross_api_utils import (get_regions_of_group, + set_utils_conf) +from pecan import conf import wsme from wsme import types as wtypes -from cms_rest.model.Model import Model -from cms_rest.logic.error_base import ErrorStatus -from pecan import conf -from orm_common.utils.cross_api_utils import set_utils_conf, get_regions_of_group class Enabled(Model): @@ -41,8 +42,7 @@ class Compute(Model): vcpus=None, metadata_items=None, injected_file_content_bytes=None, floating_ips='', fixed_ips='', injected_file_path_bytes='', server_groups='', server_group_members=''): - """ - Create a new compute instance. + """Create a new compute instance. :param instances: :param injected_files: :param key_pairs: @@ -91,8 +91,7 @@ class Storage(Model): volumes = wsme.wsattr(wsme.types.text, mandatory=True) def __init__(self, gigabytes='', snapshots='', volumes=''): - """ - create a new Storage instance. + """create a new Storage instance. :param gigabytes: :param snapshots: :param volumes: @@ -125,8 +124,7 @@ class Network(Model): health_monitor='', member='', nat_instance='', pool='', route_table='', vip=''): - """ - Create a new Network instance. + """Create a new Network instance. :param floating_ips: num of floating_ips :param networks: num of networks :param ports: num of ports @@ -268,8 +266,7 @@ class Customer(Model): self.uuid = uuid def validate_model(self, context=None): - """ - this function check if the customer model meet the demands + """this function check if the customer model meet the demands :param context: i.e. 'create 'update' :return: none """ diff --git a/orm/services/customer_manager/cms_rest/model/__init__.py b/orm/services/customer_manager/cms_rest/model/__init__.py index d983f7bc..2eef4a20 100644 --- a/orm/services/customer_manager/cms_rest/model/__init__.py +++ b/orm/services/customer_manager/cms_rest/model/__init__.py @@ -2,8 +2,7 @@ from pecan import conf # noqa def init_model(): - """ - This is a stub method which is called at application startup time. + """This is a stub method which is called at application startup time. If you need to bind to a parsed database configuration, set up tables or ORM classes, or perform any database initialization, this is the diff --git a/orm/services/customer_manager/cms_rest/rds_proxy.py b/orm/services/customer_manager/cms_rest/rds_proxy.py index e205abb9..8e885c59 100755 --- a/orm/services/customer_manager/cms_rest/rds_proxy.py +++ b/orm/services/customer_manager/cms_rest/rds_proxy.py @@ -1,10 +1,11 @@ -import pprint -import requests import json -from pecan import conf -from pecan import request -from cms_rest.logic.error_base import ErrorStatus +import pprint + +import requests + from cms_rest.logger import get_logger +from cms_rest.logic.error_base import ErrorStatus +from pecan import conf, request LOG = get_logger(__name__) headers = {'content-type': 'application/json'} diff --git a/orm/services/customer_manager/cms_rest/tests/__init__.py b/orm/services/customer_manager/cms_rest/tests/__init__.py index 78ea5274..8fcee68f 100644 --- a/orm/services/customer_manager/cms_rest/tests/__init__.py +++ b/orm/services/customer_manager/cms_rest/tests/__init__.py @@ -1,14 +1,13 @@ import os -from unittest import TestCase from pecan import set_config from pecan.testing import load_test_app +from unittest import TestCase __all__ = ['FunctionalTest'] class FunctionalTest(TestCase): - """ - Used for functional tests where you need to test your + """Used for functional tests where you need to test your literal application and its integration with the framework. """ diff --git a/orm/services/customer_manager/cms_rest/tests/config.py b/orm/services/customer_manager/cms_rest/tests/config.py index 5a9c2367..7c7ddcb6 100755 --- a/orm/services/customer_manager/cms_rest/tests/config.py +++ b/orm/services/customer_manager/cms_rest/tests/config.py @@ -1,4 +1,5 @@ import os + from cms_rest.tests.simple_hook_mock import SimpleHookMock global SimpleHookMock diff --git a/orm/services/customer_manager/cms_rest/tests/logic/test_customer_logic.py b/orm/services/customer_manager/cms_rest/tests/logic/test_customer_logic.py index 014e0ddc..52dfd054 100755 --- a/orm/services/customer_manager/cms_rest/tests/logic/test_customer_logic.py +++ b/orm/services/customer_manager/cms_rest/tests/logic/test_customer_logic.py @@ -1,8 +1,9 @@ from cms_rest.data.sql_alchemy import models as sql_models from cms_rest.logic import customer_logic -from cms_rest.tests import FunctionalTest from cms_rest.logic.error_base import ErrorStatus import cms_rest.model.Models as models +from cms_rest.tests import FunctionalTest + import mock customer = None diff --git a/orm/services/customer_manager/cms_rest/tests/rest/test_customer.py b/orm/services/customer_manager/cms_rest/tests/rest/test_customer.py index 142e79e7..70816a7b 100755 --- a/orm/services/customer_manager/cms_rest/tests/rest/test_customer.py +++ b/orm/services/customer_manager/cms_rest/tests/rest/test_customer.py @@ -1,14 +1,12 @@ -import mock import requests -import sqlalchemy -from wsme.exc import ClientSideError from cms_rest.controllers.v1.orm.customer import root from cms_rest.logic.error_base import ErrorStatus - from cms_rest.model import Models -from cms_rest.tests import FunctionalTest -from cms_rest.tests import test_utils +from cms_rest.tests import FunctionalTest, test_utils +import mock +import sqlalchemy +from wsme.exc import ClientSideError customer_logic_mock = None diff --git a/orm/services/customer_manager/cms_rest/tests/rest/test_enable.py b/orm/services/customer_manager/cms_rest/tests/rest/test_enable.py index ccbb3733..f74d816e 100755 --- a/orm/services/customer_manager/cms_rest/tests/rest/test_enable.py +++ b/orm/services/customer_manager/cms_rest/tests/rest/test_enable.py @@ -1,10 +1,10 @@ -import mock import requests from cms_rest.controllers.v1.orm.customer import enabled from cms_rest.logic.error_base import ErrorStatus from cms_rest.model import Models from cms_rest.tests import FunctionalTest +import mock customer_logic_mock = None diff --git a/orm/services/customer_manager/cms_rest/tests/rest/test_metadata.py b/orm/services/customer_manager/cms_rest/tests/rest/test_metadata.py index 6e7f2057..e61b1848 100755 --- a/orm/services/customer_manager/cms_rest/tests/rest/test_metadata.py +++ b/orm/services/customer_manager/cms_rest/tests/rest/test_metadata.py @@ -1,10 +1,10 @@ -import mock import requests from cms_rest.controllers.v1.orm.customer import metadata from cms_rest.logic.error_base import ErrorStatus from cms_rest.model import Models from cms_rest.tests import FunctionalTest +import mock metadata_logic_mock = None diff --git a/orm/services/customer_manager/cms_rest/tests/rest/test_regions.py b/orm/services/customer_manager/cms_rest/tests/rest/test_regions.py index 07b135fd..bf25a702 100755 --- a/orm/services/customer_manager/cms_rest/tests/rest/test_regions.py +++ b/orm/services/customer_manager/cms_rest/tests/rest/test_regions.py @@ -1,12 +1,11 @@ -import mock import requests -from wsme.exc import ClientSideError - from cms_rest.controllers.v1.orm.customer import regions from cms_rest.logic.error_base import ErrorStatus from cms_rest.model import Models from cms_rest.tests import FunctionalTest +import mock +from wsme.exc import ClientSideError customer_logic_mock = None diff --git a/orm/services/customer_manager/cms_rest/tests/rest/test_users.py b/orm/services/customer_manager/cms_rest/tests/rest/test_users.py index fc1f6d70..a93a3011 100755 --- a/orm/services/customer_manager/cms_rest/tests/rest/test_users.py +++ b/orm/services/customer_manager/cms_rest/tests/rest/test_users.py @@ -1,11 +1,11 @@ -import mock import requests -from wsme.exc import ClientSideError from cms_rest.controllers.v1.orm.customer import users from cms_rest.logic.error_base import ErrorStatus from cms_rest.model import Models from cms_rest.tests import FunctionalTest +import mock +from wsme.exc import ClientSideError customer_logic_mock = None diff --git a/orm/services/customer_manager/cms_rest/tests/test_authentication.py b/orm/services/customer_manager/cms_rest/tests/test_authentication.py index 418e2e3f..18afceba 100644 --- a/orm/services/customer_manager/cms_rest/tests/test_authentication.py +++ b/orm/services/customer_manager/cms_rest/tests/test_authentication.py @@ -1,8 +1,7 @@ -import mock from cms_rest.tests import FunctionalTest -from pecan import conf - from cms_rest.utils import authentication +import mock +from pecan import conf class TestUtil(FunctionalTest): diff --git a/orm/services/customer_manager/cms_rest/tests/test_models.py b/orm/services/customer_manager/cms_rest/tests/test_models.py index 91009893..a8150028 100755 --- a/orm/services/customer_manager/cms_rest/tests/test_models.py +++ b/orm/services/customer_manager/cms_rest/tests/test_models.py @@ -1,7 +1,6 @@ -import mock -from cms_rest.tests import FunctionalTest - from cms_rest.model import Models as models +from cms_rest.tests import FunctionalTest +import mock GROUP_REGIONS = [ "DPK", @@ -31,8 +30,7 @@ class TestModels(FunctionalTest): def get_cust_model(): - """ - this function create a customer model object for testing + """this function create a customer model object for testing :return: new customer object """ diff --git a/orm/services/customer_manager/cms_rest/tests/test_rds_proxy.py b/orm/services/customer_manager/cms_rest/tests/test_rds_proxy.py index b612ad07..0e318a14 100755 --- a/orm/services/customer_manager/cms_rest/tests/test_rds_proxy.py +++ b/orm/services/customer_manager/cms_rest/tests/test_rds_proxy.py @@ -1,12 +1,9 @@ -import mock -from mock import MagicMock -from cms_rest.tests import FunctionalTest -from cms_rest.logger import get_logger -from testfixtures import log_capture, compare, Comparison as C -import logging -from cms_rest import rds_proxy from cms_rest.data.sql_alchemy import models from cms_rest.logic.error_base import ErrorStatus +from cms_rest import rds_proxy +from cms_rest.tests import FunctionalTest +import mock +from testfixtures import log_capture class Response: diff --git a/orm/services/customer_manager/cms_rest/tests/test_utils.py b/orm/services/customer_manager/cms_rest/tests/test_utils.py index 5fdf9280..94ba5c04 100755 --- a/orm/services/customer_manager/cms_rest/tests/test_utils.py +++ b/orm/services/customer_manager/cms_rest/tests/test_utils.py @@ -1,4 +1,5 @@ import json + from wsme.exc import ClientSideError diff --git a/orm/services/customer_manager/cms_rest/utils/authentication.py b/orm/services/customer_manager/cms_rest/utils/authentication.py index 46b1b27a..b8553e33 100755 --- a/orm/services/customer_manager/cms_rest/utils/authentication.py +++ b/orm/services/customer_manager/cms_rest/utils/authentication.py @@ -1,9 +1,10 @@ import logging + from keystone_utils import tokens from orm_common.policy import policy +from orm_common.utils import api_error_utils as err_utils from pecan import conf -from orm_common.utils import api_error_utils as err_utils logger = logging.getLogger(__name__) diff --git a/orm/services/customer_manager/config.py b/orm/services/customer_manager/config.py index 9fa85c38..5a12ad75 100755 --- a/orm/services/customer_manager/config.py +++ b/orm/services/customer_manager/config.py @@ -1,7 +1,6 @@ -import os -from orm_common.hooks.transaction_id_hook import TransactionIdHook -from orm_common.hooks.security_headers_hook import SecurityHeadersHook from orm_common.hooks.api_error_hook import APIErrorHook +from orm_common.hooks.security_headers_hook import SecurityHeadersHook +from orm_common.hooks.transaction_id_hook import TransactionIdHook global TransactionIdHook global APIErrorHook diff --git a/orm/services/customer_manager/pycharm_init.py b/orm/services/customer_manager/pycharm_init.py index 469a65d9..5b11a0d4 100755 --- a/orm/services/customer_manager/pycharm_init.py +++ b/orm/services/customer_manager/pycharm_init.py @@ -1,3 +1,4 @@ from pecan.commands import CommandRunner + runner = CommandRunner() runner.run(['serve', 'config.py']) diff --git a/orm/services/customer_manager/run_pecan.py b/orm/services/customer_manager/run_pecan.py index 4d1ce01d..0fbfa08e 100644 --- a/orm/services/customer_manager/run_pecan.py +++ b/orm/services/customer_manager/run_pecan.py @@ -2,5 +2,6 @@ ' this script is running the pecan web server inside ide so we can set break points in the code and debug our code ''' from pecan.commands import CommandRunner + runner = CommandRunner() runner.run(['serve', 'config.py']) diff --git a/orm/services/flavor_manager/config.py b/orm/services/flavor_manager/config.py index 4e5fcd2e..0f664843 100755 --- a/orm/services/flavor_manager/config.py +++ b/orm/services/flavor_manager/config.py @@ -1,5 +1,5 @@ -from orm_common.hooks.api_error_hook import APIErrorHook from fms_rest.hooks.service_hooks import TransIdHook +from orm_common.hooks.api_error_hook import APIErrorHook from orm_common.hooks.security_headers_hook import SecurityHeadersHook global TransIdHook diff --git a/orm/services/flavor_manager/fms_mocks/audit_mock.py b/orm/services/flavor_manager/fms_mocks/audit_mock.py index 36299893..ce952c75 100644 --- a/orm/services/flavor_manager/fms_mocks/audit_mock.py +++ b/orm/services/flavor_manager/fms_mocks/audit_mock.py @@ -1,4 +1,3 @@ -from mock import MagicMock from fms_rest.logger import get_logger logger = get_logger(__name__) diff --git a/orm/services/flavor_manager/fms_mocks/requests_mock.py b/orm/services/flavor_manager/fms_mocks/requests_mock.py index 755bd355..cb9444f1 100644 --- a/orm/services/flavor_manager/fms_mocks/requests_mock.py +++ b/orm/services/flavor_manager/fms_mocks/requests_mock.py @@ -1,9 +1,10 @@ import copy import uuid -from mock import MagicMock -from fms_rest.data.sql_alchemy.data_manager import DataManager +from fms_rest.data.sql_alchemy.data_manager import DataManager from fms_rest.logger import get_logger +from mock import MagicMock + logger = get_logger(__name__) diff --git a/orm/services/flavor_manager/fms_rest/app.py b/orm/services/flavor_manager/fms_rest/app.py index 369bd1ae..d5ab722b 100644 --- a/orm/services/flavor_manager/fms_rest/app.py +++ b/orm/services/flavor_manager/fms_rest/app.py @@ -1,11 +1,12 @@ -from pecan import make_app +import os + from fms_rest.data import wsme from fms_rest.logger import get_logger -from pecan.commands import CommandRunner from fms_rest.utils import authentication from orm_common.policy import policy +from pecan.commands import CommandRunner +from pecan import make_app -import os logger = get_logger(__name__) @@ -29,4 +30,4 @@ def main(): drive, path_and_file = os.path.splitdrive(dir_name) path, filename = os.path.split(path_and_file) runner = CommandRunner() - runner.run(['serve', path+'/config.py']) + runner.run(['serve', path + '/config.py']) diff --git a/orm/services/flavor_manager/fms_rest/controllers/__init__.py b/orm/services/flavor_manager/fms_rest/controllers/__init__.py index d57e44a1..95881725 100644 --- a/orm/services/flavor_manager/fms_rest/controllers/__init__.py +++ b/orm/services/flavor_manager/fms_rest/controllers/__init__.py @@ -1,7 +1,8 @@ import os + +import fms_rest.di_providers as di_providers from fms_rest.logger import get_logger from orm_common.injector import injector -import fms_rest.di_providers as di_providers logger = get_logger(__name__) diff --git a/orm/services/flavor_manager/fms_rest/controllers/root.py b/orm/services/flavor_manager/fms_rest/controllers/root.py index 40b587b3..bc047167 100644 --- a/orm/services/flavor_manager/fms_rest/controllers/root.py +++ b/orm/services/flavor_manager/fms_rest/controllers/root.py @@ -1,28 +1,14 @@ -from pecan import conf, expose -from pecan import request - -from webob.exc import status_map -from pecan.secure import SecureController from fms_rest.controllers.v1.v1 import V1Controller -from fms_rest.utils import authentication +from pecan import conf, expose +from webob.exc import status_map class RootController(object): v1 = V1Controller() - ''' - @classmethod - def check_permissions(cls): - # Extract the required values from the request header - headers = request.headers - token_to_validate = headers.get('X-Auth-Token') - lcp_id = headers.get('X-Auth-Region') - return authentication.check_permissions(conf, token_to_validate, lcp_id) - ''' @expose(template='json') def get(self): - """ - Method to handle GET / + """Method to handle GET / prameters: None return: dict describing flavor command version information """ diff --git a/orm/services/flavor_manager/fms_rest/controllers/v1/orm/configuration.py b/orm/services/flavor_manager/fms_rest/controllers/v1/orm/configuration.py index 258132fc..c619f82d 100755 --- a/orm/services/flavor_manager/fms_rest/controllers/v1/orm/configuration.py +++ b/orm/services/flavor_manager/fms_rest/controllers/v1/orm/configuration.py @@ -1,11 +1,10 @@ """Configuration rest API input module.""" import logging -from orm_common.utils import utils -from pecan import conf -from pecan import rest -from wsmeext.pecan import wsexpose +from orm_common.utils import utils +from pecan import conf, rest +from wsmeext.pecan import wsexpose logger = logging.getLogger(__name__) diff --git a/orm/services/flavor_manager/fms_rest/controllers/v1/orm/flavors/flavors.py b/orm/services/flavor_manager/fms_rest/controllers/v1/orm/flavors/flavors.py index 348a1264..db56bf5e 100755 --- a/orm/services/flavor_manager/fms_rest/controllers/v1/orm/flavors/flavors.py +++ b/orm/services/flavor_manager/fms_rest/controllers/v1/orm/flavors/flavors.py @@ -1,20 +1,16 @@ -from pecan import rest, request, response, expose -from pecan.core import abort - -from wsmeext.pecan import wsexpose - +from fms_rest.controllers.v1.orm.flavors.os_extra_specs import \ + OsExtraSpecsController from fms_rest.controllers.v1.orm.flavors.regions import RegionController -from fms_rest.controllers.v1.orm.flavors.tenants import TenantController -from fms_rest.controllers.v1.orm.flavors.os_extra_specs import OsExtraSpecsController from fms_rest.controllers.v1.orm.flavors.tags import TagsController - -from fms_rest.data.wsme.models import FlavorWrapper, FlavorListFullResponse -from fms_rest.logic.error_base import ErrorStatus +from fms_rest.controllers.v1.orm.flavors.tenants import TenantController +from fms_rest.data.wsme.models import FlavorListFullResponse, FlavorWrapper from fms_rest.logger import get_logger +from fms_rest.logic.error_base import ErrorStatus from fms_rest.utils import authentication - from orm_common.injector import injector from orm_common.utils import api_error_utils as err_utils +from pecan import request, rest +from wsmeext.pecan import wsexpose di = injector.get_di() LOG = get_logger(__name__) diff --git a/orm/services/flavor_manager/fms_rest/controllers/v1/orm/flavors/os_extra_specs.py b/orm/services/flavor_manager/fms_rest/controllers/v1/orm/flavors/os_extra_specs.py index 9ea434a0..daf2b880 100755 --- a/orm/services/flavor_manager/fms_rest/controllers/v1/orm/flavors/os_extra_specs.py +++ b/orm/services/flavor_manager/fms_rest/controllers/v1/orm/flavors/os_extra_specs.py @@ -1,16 +1,11 @@ -import base -from pecan import rest, request, response -from wsmeext.pecan import wsexpose from fms_rest.data.wsme.models import ExtraSpecsWrapper - -from orm_common.injector import injector - -from orm_common.utils import api_error_utils as err_utils - -from fms_rest.logic.error_base import ErrorStatus - from fms_rest.logger import get_logger +from fms_rest.logic.error_base import ErrorStatus from fms_rest.utils import authentication +from orm_common.injector import injector +from orm_common.utils import api_error_utils as err_utils +from pecan import request, rest +from wsmeext.pecan import wsexpose LOG = get_logger(__name__) diff --git a/orm/services/flavor_manager/fms_rest/controllers/v1/orm/flavors/regions.py b/orm/services/flavor_manager/fms_rest/controllers/v1/orm/flavors/regions.py index b85d4b4f..59cc6769 100755 --- a/orm/services/flavor_manager/fms_rest/controllers/v1/orm/flavors/regions.py +++ b/orm/services/flavor_manager/fms_rest/controllers/v1/orm/flavors/regions.py @@ -1,14 +1,11 @@ -from pecan import rest, request -from wsmeext.pecan import wsexpose - from fms_rest.data.wsme.models import RegionWrapper -from fms_rest.logic.error_base import ErrorStatus -from base import ClientSideError from fms_rest.logger import get_logger - +from fms_rest.logic.error_base import ErrorStatus +from fms_rest.utils import authentication from orm_common.injector import injector from orm_common.utils import api_error_utils as err_utils -from fms_rest.utils import authentication +from pecan import request, rest +from wsmeext.pecan import wsexpose LOG = get_logger(__name__) diff --git a/orm/services/flavor_manager/fms_rest/controllers/v1/orm/flavors/tags.py b/orm/services/flavor_manager/fms_rest/controllers/v1/orm/flavors/tags.py index c42720d9..13bfd9ea 100644 --- a/orm/services/flavor_manager/fms_rest/controllers/v1/orm/flavors/tags.py +++ b/orm/services/flavor_manager/fms_rest/controllers/v1/orm/flavors/tags.py @@ -1,14 +1,11 @@ -import base -from pecan import rest, request, response -from wsmeext.pecan import wsexpose - from fms_rest.data.wsme.models import TagsWrapper -from fms_rest.logic.error_base import ErrorStatus from fms_rest.logger import get_logger - +from fms_rest.logic.error_base import ErrorStatus +from fms_rest.utils import authentication from orm_common.injector import injector from orm_common.utils import api_error_utils as err_utils -from fms_rest.utils import authentication +from pecan import request, rest +from wsmeext.pecan import wsexpose LOG = get_logger(__name__) diff --git a/orm/services/flavor_manager/fms_rest/controllers/v1/orm/flavors/tenants.py b/orm/services/flavor_manager/fms_rest/controllers/v1/orm/flavors/tenants.py index 9ba623d0..c7a13a47 100755 --- a/orm/services/flavor_manager/fms_rest/controllers/v1/orm/flavors/tenants.py +++ b/orm/services/flavor_manager/fms_rest/controllers/v1/orm/flavors/tenants.py @@ -1,14 +1,11 @@ -from pecan import rest, request -from pecan.core import abort -from wsmeext.pecan import wsexpose - from fms_rest.data.wsme.models import TenantWrapper -from fms_rest.logic.error_base import ErrorStatus from fms_rest.logger import get_logger - +from fms_rest.logic.error_base import ErrorStatus +from fms_rest.utils import authentication from orm_common.injector import injector from orm_common.utils import api_error_utils as err_utils -from fms_rest.utils import authentication +from pecan import request, rest +from wsmeext.pecan import wsexpose LOG = get_logger(__name__) diff --git a/orm/services/flavor_manager/fms_rest/data/sql_alchemy/data_manager.py b/orm/services/flavor_manager/fms_rest/data/sql_alchemy/data_manager.py index 6200980a..bb8f9a3a 100755 --- a/orm/services/flavor_manager/fms_rest/data/sql_alchemy/data_manager.py +++ b/orm/services/flavor_manager/fms_rest/data/sql_alchemy/data_manager.py @@ -10,15 +10,13 @@ * For more information visit http://www.igenxsoft.com ''' -from sqlalchemy.event import listen -from pecan import conf -from oslo_db.sqlalchemy import session as db_session - import logging - # from fms_rest.logic.error_base import DuplicateEntityError from fms_rest.data.sql_alchemy.flavor.flavor_record import FlavorRecord +from oslo_db.sqlalchemy import session as db_session +from pecan import conf +from sqlalchemy.event import listen LOG = logging.getLogger(__name__) diff --git a/orm/services/flavor_manager/fms_rest/data/sql_alchemy/db_models.py b/orm/services/flavor_manager/fms_rest/data/sql_alchemy/db_models.py index d8cd93fd..2248b2f5 100755 --- a/orm/services/flavor_manager/fms_rest/data/sql_alchemy/db_models.py +++ b/orm/services/flavor_manager/fms_rest/data/sql_alchemy/db_models.py @@ -1,11 +1,12 @@ -from sqlalchemy import Column, Integer, BigInteger, String, ForeignKey -from sqlalchemy.ext.declarative import declarative_base -from sqlalchemy.orm import relationship, validates -from oslo_db.sqlalchemy import models +from __builtin__ import reversed from fms_rest.logger import get_logger -from __builtin__ import reversed from fms_rest.logic.error_base import ErrorStatus +from oslo_db.sqlalchemy import models +from sqlalchemy import BigInteger, Column, ForeignKey, Integer, String +from sqlalchemy.ext.declarative import declarative_base +from sqlalchemy.orm import relationship, validates + LOG = get_logger(__name__) Base = declarative_base() @@ -29,10 +30,9 @@ class FMSBaseModel(models.ModelBase): class Flavor(Base, FMSBaseModel): - ''' - Flavor is a DataObject contains all the fields defined in Flavor table record. + """DataObject containing all the fields defined in Flavor table record. defined as SqlAlchemy model map to a table - ''' + """ __tablename__ = "flavor" internal_id = Column(BigInteger, primary_key=True) diff --git a/orm/services/flavor_manager/fms_rest/data/sql_alchemy/flavor/flavor_record.py b/orm/services/flavor_manager/fms_rest/data/sql_alchemy/flavor/flavor_record.py index 126c950f..ba40b77b 100755 --- a/orm/services/flavor_manager/fms_rest/data/sql_alchemy/flavor/flavor_record.py +++ b/orm/services/flavor_manager/fms_rest/data/sql_alchemy/flavor/flavor_record.py @@ -1,8 +1,6 @@ -from fms_rest.data.sql_alchemy.db_models import Flavor -from fms_rest.data.sql_alchemy.db_models import FlavorExtraSpec -from fms_rest.data.sql_alchemy.db_models import FlavorRegion -from fms_rest.data.sql_alchemy.db_models import FlavorTenant +from fms_rest.data.sql_alchemy.db_models import (Flavor, FlavorRegion, + FlavorTenant) from fms_rest.logger import get_logger from sqlalchemy.sql import or_ diff --git a/orm/services/flavor_manager/fms_rest/data/sql_alchemy/flavor_extra_spec/flavor_extra_spec_record.py b/orm/services/flavor_manager/fms_rest/data/sql_alchemy/flavor_extra_spec/flavor_extra_spec_record.py index 29727f06..bffb2717 100755 --- a/orm/services/flavor_manager/fms_rest/data/sql_alchemy/flavor_extra_spec/flavor_extra_spec_record.py +++ b/orm/services/flavor_manager/fms_rest/data/sql_alchemy/flavor_extra_spec/flavor_extra_spec_record.py @@ -1,7 +1,6 @@ -from sqlalchemy import and_ from fms_rest.data.sql_alchemy.db_models import FlavorExtraSpec - from fms_rest.logger import get_logger +from sqlalchemy import and_ LOG = get_logger(__name__) diff --git a/orm/services/flavor_manager/fms_rest/data/sql_alchemy/flavor_options/flavor_option_record.py b/orm/services/flavor_manager/fms_rest/data/sql_alchemy/flavor_options/flavor_option_record.py index f82f1a44..86235e9e 100755 --- a/orm/services/flavor_manager/fms_rest/data/sql_alchemy/flavor_options/flavor_option_record.py +++ b/orm/services/flavor_manager/fms_rest/data/sql_alchemy/flavor_options/flavor_option_record.py @@ -1,7 +1,6 @@ -from sqlalchemy import and_ from fms_rest.data.sql_alchemy.db_models import FlavorOption - from fms_rest.logger import get_logger +from sqlalchemy import and_ LOG = get_logger(__name__) diff --git a/orm/services/flavor_manager/fms_rest/data/sql_alchemy/flavor_region/flavor_region_record.py b/orm/services/flavor_manager/fms_rest/data/sql_alchemy/flavor_region/flavor_region_record.py index 30a2def8..16384a3d 100755 --- a/orm/services/flavor_manager/fms_rest/data/sql_alchemy/flavor_region/flavor_region_record.py +++ b/orm/services/flavor_manager/fms_rest/data/sql_alchemy/flavor_region/flavor_region_record.py @@ -1,7 +1,7 @@ -from sqlalchemy import and_ from fms_rest.data.sql_alchemy.db_models import FlavorRegion - from fms_rest.logger import get_logger +from sqlalchemy import and_ + LOG = get_logger(__name__) diff --git a/orm/services/flavor_manager/fms_rest/data/sql_alchemy/flavor_tags/flavor_tag_record.py b/orm/services/flavor_manager/fms_rest/data/sql_alchemy/flavor_tags/flavor_tag_record.py index 0b703efa..f3b4a255 100755 --- a/orm/services/flavor_manager/fms_rest/data/sql_alchemy/flavor_tags/flavor_tag_record.py +++ b/orm/services/flavor_manager/fms_rest/data/sql_alchemy/flavor_tags/flavor_tag_record.py @@ -1,7 +1,6 @@ -from sqlalchemy import and_ from fms_rest.data.sql_alchemy.db_models import FlavorTag - from fms_rest.logger import get_logger +from sqlalchemy import and_ LOG = get_logger(__name__) diff --git a/orm/services/flavor_manager/fms_rest/data/sql_alchemy/flavor_tenant/flavor_tenant_record.py b/orm/services/flavor_manager/fms_rest/data/sql_alchemy/flavor_tenant/flavor_tenant_record.py index 4ae65a10..273a0bd2 100755 --- a/orm/services/flavor_manager/fms_rest/data/sql_alchemy/flavor_tenant/flavor_tenant_record.py +++ b/orm/services/flavor_manager/fms_rest/data/sql_alchemy/flavor_tenant/flavor_tenant_record.py @@ -1,7 +1,7 @@ -from sqlalchemy import and_ from fms_rest.data.sql_alchemy.db_models import FlavorTenant - from fms_rest.logger import get_logger +from sqlalchemy import and_ + LOG = get_logger(__name__) diff --git a/orm/services/flavor_manager/fms_rest/data/wsme/__init__.py b/orm/services/flavor_manager/fms_rest/data/wsme/__init__.py index c65cf067..9b6e85eb 100644 --- a/orm/services/flavor_manager/fms_rest/data/wsme/__init__.py +++ b/orm/services/flavor_manager/fms_rest/data/wsme/__init__.py @@ -1,8 +1,7 @@ def init_model(): - """ - This is a stub method which is called at application startup time. + """This is a stub method which is called at application startup time. If you need to bind to a parsed database configuration, set up tables or ORM classes, or perform any database initialization, this is the diff --git a/orm/services/flavor_manager/fms_rest/data/wsme/model.py b/orm/services/flavor_manager/fms_rest/data/wsme/model.py index a964a2d6..969a5b5c 100644 --- a/orm/services/flavor_manager/fms_rest/data/wsme/model.py +++ b/orm/services/flavor_manager/fms_rest/data/wsme/model.py @@ -1,5 +1,5 @@ -from wsme import types as wtypes from wsme.rest.json import tojson +from wsme import types as wtypes class Model(wtypes.DynamicBase): diff --git a/orm/services/flavor_manager/fms_rest/data/wsme/models.py b/orm/services/flavor_manager/fms_rest/data/wsme/models.py index 552c26fd..0f6d23ab 100755 --- a/orm/services/flavor_manager/fms_rest/data/wsme/models.py +++ b/orm/services/flavor_manager/fms_rest/data/wsme/models.py @@ -1,10 +1,8 @@ import wsme + from fms_rest.data.sql_alchemy import db_models - from fms_rest.data.wsme.model import Model - from fms_rest.logic.error_base import ErrorStatus - from pecan import conf, request from orm_common.utils.cross_api_utils import set_utils_conf, get_regions_of_group @@ -139,7 +137,7 @@ class RegionWrapper(Model): # pragma: no cover regions = wsme.wsattr([Region], mandatory=False) def __init__(self, regions=[]): - """ + """init :param regions: array of regions """ @@ -487,7 +485,7 @@ class FlavorWrapper(Model): flavor = wsme.wsattr(Flavor, mandatory=True, name='flavor') def __init__(self, flavor=Flavor()): - """ + """init :param flavor: flavor dict """ diff --git a/orm/services/flavor_manager/fms_rest/di_providers/mock_providers.py b/orm/services/flavor_manager/fms_rest/di_providers/mock_providers.py index 64a8a47d..e6a0830d 100644 --- a/orm/services/flavor_manager/fms_rest/di_providers/mock_providers.py +++ b/orm/services/flavor_manager/fms_rest/di_providers/mock_providers.py @@ -1,6 +1,4 @@ -from fms_mocks import requests_mock -from fms_mocks import audit_mock - +from fms_mocks import audit_mock, requests_mock from fms_rest.data.sql_alchemy.data_manager import DataManager from fms_rest.logic import flavor_logic from fms_rest.proxies import rds_proxy diff --git a/orm/services/flavor_manager/fms_rest/di_providers/prod_providers.py b/orm/services/flavor_manager/fms_rest/di_providers/prod_providers.py index e69babbe..8e17cb15 100644 --- a/orm/services/flavor_manager/fms_rest/di_providers/prod_providers.py +++ b/orm/services/flavor_manager/fms_rest/di_providers/prod_providers.py @@ -1,12 +1,11 @@ import requests + from audit_client.api import audit - -from fms_rest.proxies import rds_proxy -from fms_rest.logic import flavor_logic from fms_rest.data.sql_alchemy.data_manager import DataManager +from fms_rest.logic import flavor_logic +from fms_rest.proxies import rds_proxy from fms_rest.utils import utils - providers = [ ('rds_proxy', rds_proxy), ('flavor_logic', flavor_logic), diff --git a/orm/services/flavor_manager/fms_rest/external_mock/orm_common/injector/fang/__init__.py b/orm/services/flavor_manager/fms_rest/external_mock/orm_common/injector/fang/__init__.py index 18404b50..e69de29b 100755 --- a/orm/services/flavor_manager/fms_rest/external_mock/orm_common/injector/fang/__init__.py +++ b/orm/services/flavor_manager/fms_rest/external_mock/orm_common/injector/fang/__init__.py @@ -1,7 +0,0 @@ -''' -''' - -from .di import Di -from .dependency_register import DependencyRegister -from .resource_provider_register import ResourceProviderRegister -from .resolver import DependencyResolver diff --git a/orm/services/flavor_manager/fms_rest/external_mock/orm_common/injector/fang/dependency_register.py b/orm/services/flavor_manager/fms_rest/external_mock/orm_common/injector/fang/dependency_register.py index 7b4d7093..02d62b54 100755 --- a/orm/services/flavor_manager/fms_rest/external_mock/orm_common/injector/fang/dependency_register.py +++ b/orm/services/flavor_manager/fms_rest/external_mock/orm_common/injector/fang/dependency_register.py @@ -18,8 +18,7 @@ class DependencyRegister: @classmethod def _unwrap_func(cls, decorated_func): - ''' - This unwraps a decorated func, returning the inner wrapped func. + '''This unwraps a decorated func, returning the inner wrapped func. This may become unnecessary with Python 3.4's inspect.unwrap(). ''' diff --git a/orm/services/flavor_manager/fms_rest/external_mock/orm_common/injector/fang/di.py b/orm/services/flavor_manager/fms_rest/external_mock/orm_common/injector/fang/di.py index 6a436354..76b4304a 100755 --- a/orm/services/flavor_manager/fms_rest/external_mock/orm_common/injector/fang/di.py +++ b/orm/services/flavor_manager/fms_rest/external_mock/orm_common/injector/fang/di.py @@ -1,6 +1,6 @@ from .dependency_register import DependencyRegister -from .resource_provider_register import ResourceProviderRegister from .resolver import DependencyResolver +from .resource_provider_register import ResourceProviderRegister class Di: diff --git a/orm/services/flavor_manager/fms_rest/external_mock/orm_common/injector/fang/resource_provider_register.py b/orm/services/flavor_manager/fms_rest/external_mock/orm_common/injector/fang/resource_provider_register.py index 58da4619..c3ff580f 100755 --- a/orm/services/flavor_manager/fms_rest/external_mock/orm_common/injector/fang/resource_provider_register.py +++ b/orm/services/flavor_manager/fms_rest/external_mock/orm_common/injector/fang/resource_provider_register.py @@ -1,9 +1,7 @@ from functools import partial -from .errors import ( - FangError, - ProviderAlreadyRegisteredError, - ProviderNotFoundError) +from .errors import (FangError, ProviderAlreadyRegisteredError, + ProviderNotFoundError) class ResourceProviderRegister: diff --git a/orm/services/flavor_manager/fms_rest/external_mock/orm_common/injector/injector.py b/orm/services/flavor_manager/fms_rest/external_mock/orm_common/injector/injector.py index 53acb543..679f309a 100755 --- a/orm/services/flavor_manager/fms_rest/external_mock/orm_common/injector/injector.py +++ b/orm/services/flavor_manager/fms_rest/external_mock/orm_common/injector/injector.py @@ -1,6 +1,7 @@ -from orm_common.injector import fang -import os import imp +import os + +from orm_common.injector import fang _di = fang.Di() logger = None diff --git a/orm/services/flavor_manager/fms_rest/external_mock/orm_common/utils/cross_api_utils.py b/orm/services/flavor_manager/fms_rest/external_mock/orm_common/utils/cross_api_utils.py index 11233bbe..b2183133 100755 --- a/orm/services/flavor_manager/fms_rest/external_mock/orm_common/utils/cross_api_utils.py +++ b/orm/services/flavor_manager/fms_rest/external_mock/orm_common/utils/cross_api_utils.py @@ -1,10 +1,9 @@ -import requests -import logging -from pecan import conf -from audit_client.api import audit import time +import requests + from orm_common.logger import get_logger +from pecan import conf logger = get_logger(__name__) diff --git a/orm/services/flavor_manager/fms_rest/external_mock/orm_common/utils/utils.py b/orm/services/flavor_manager/fms_rest/external_mock/orm_common/utils/utils.py index 49d90ecc..0bdf312e 100755 --- a/orm/services/flavor_manager/fms_rest/external_mock/orm_common/utils/utils.py +++ b/orm/services/flavor_manager/fms_rest/external_mock/orm_common/utils/utils.py @@ -1,11 +1,11 @@ -import requests import pprint -import logging -from pecan import conf -from audit_client.api import audit import time +import requests + +from audit_client.api import audit from orm_common.logger import get_logger +from pecan import conf logger = get_logger(__name__) diff --git a/orm/services/flavor_manager/fms_rest/hooks/service_hooks.py b/orm/services/flavor_manager/fms_rest/hooks/service_hooks.py index 27f8484e..b348fea1 100755 --- a/orm/services/flavor_manager/fms_rest/hooks/service_hooks.py +++ b/orm/services/flavor_manager/fms_rest/hooks/service_hooks.py @@ -1,6 +1,6 @@ +from fms_rest.utils import utils from orm_common.hooks.transaction_id_hook import TransactionIdHook from pecan import abort -from fms_rest.utils import utils class TransIdHook(TransactionIdHook): diff --git a/orm/services/flavor_manager/fms_rest/logic/flavor_logic.py b/orm/services/flavor_manager/fms_rest/logic/flavor_logic.py index 95b28146..b90b4164 100755 --- a/orm/services/flavor_manager/fms_rest/logic/flavor_logic.py +++ b/orm/services/flavor_manager/fms_rest/logic/flavor_logic.py @@ -1,15 +1,14 @@ -from fms_rest.logger import get_logger -from fms_rest.data.wsme.models import RegionWrapper, TenantWrapper, ExtraSpecsWrapper, Flavor -from fms_rest.data.wsme.models import FlavorWrapper, Region, TagsWrapper -from fms_rest.data.wsme.models import FlavorListFullResponse, Flavor -from fms_rest.data.sql_alchemy.db_models import FlavorRegion, FlavorTenant -from fms_rest.logic.error_base import ErrorStatus, NotFoundError, ConflictError -from sqlalchemy.orm.exc import FlushError - -from orm_common.injector import injector -import re import uuid +from fms_rest.data.sql_alchemy.db_models import FlavorRegion, FlavorTenant +from fms_rest.data.wsme.models import (ExtraSpecsWrapper, Flavor, + FlavorListFullResponse, FlavorWrapper, + Region, RegionWrapper, TagsWrapper, + TenantWrapper) +from fms_rest.logger import get_logger +from fms_rest.logic.error_base import ConflictError, ErrorStatus, NotFoundError +from orm_common.injector import injector + LOG = get_logger(__name__) di = injector.get_di() diff --git a/orm/services/flavor_manager/fms_rest/proxies/rds_proxy.py b/orm/services/flavor_manager/fms_rest/proxies/rds_proxy.py index 218a50c8..41c5ef38 100755 --- a/orm/services/flavor_manager/fms_rest/proxies/rds_proxy.py +++ b/orm/services/flavor_manager/fms_rest/proxies/rds_proxy.py @@ -1,10 +1,11 @@ import json import pprint -from pecan import conf -from pecan import request + from fms_rest.logger import get_logger -from orm_common.injector import injector from fms_rest.logic.error_base import ErrorStatus +from orm_common.injector import injector +from pecan import conf, request + di = injector.get_di() LOG = get_logger(__name__) diff --git a/orm/services/flavor_manager/fms_rest/tests/__init__.py b/orm/services/flavor_manager/fms_rest/tests/__init__.py index 78ea5274..55396865 100644 --- a/orm/services/flavor_manager/fms_rest/tests/__init__.py +++ b/orm/services/flavor_manager/fms_rest/tests/__init__.py @@ -1,15 +1,15 @@ import os -from unittest import TestCase from pecan import set_config from pecan.testing import load_test_app +from unittest import TestCase __all__ = ['FunctionalTest'] class FunctionalTest(TestCase): - """ - Used for functional tests where you need to test your - literal application and its integration with the framework. + """Used for functional tests + where you need to test your literal application + and its integration with the framework. """ def setUp(self): diff --git a/orm/services/flavor_manager/fms_rest/tests/data/test_wsme_models.py b/orm/services/flavor_manager/fms_rest/tests/data/test_wsme_models.py index cc08e833..067726a7 100755 --- a/orm/services/flavor_manager/fms_rest/tests/data/test_wsme_models.py +++ b/orm/services/flavor_manager/fms_rest/tests/data/test_wsme_models.py @@ -1,6 +1,6 @@ -from fms_rest.tests import FunctionalTest from fms_rest.data.sql_alchemy import db_models import fms_rest.data.wsme.models as wsme_models +from fms_rest.tests import FunctionalTest class TestWsmeModels(FunctionalTest): diff --git a/orm/services/flavor_manager/fms_rest/tests/logic/test_flavor_logic.py b/orm/services/flavor_manager/fms_rest/tests/logic/test_flavor_logic.py index cef5355e..6b813244 100755 --- a/orm/services/flavor_manager/fms_rest/tests/logic/test_flavor_logic.py +++ b/orm/services/flavor_manager/fms_rest/tests/logic/test_flavor_logic.py @@ -1,12 +1,11 @@ -from fms_rest.tests import FunctionalTest -from orm_common.injector import injector -from mock import MagicMock -from mock import patch +from fms_rest.data.sql_alchemy import db_models from fms_rest.data.wsme import models from fms_rest.data.wsme.models import * -from fms_rest.data.sql_alchemy import db_models +from fms_rest.logic.error_base import NotFoundError import fms_rest.logic.flavor_logic as flavor_logic -from fms_rest.logic.error_base import NotFoundError, ConflictError +from fms_rest.tests import FunctionalTest +from mock import MagicMock, patch +from orm_common.injector import injector class OES(): diff --git a/orm/services/flavor_manager/fms_rest/tests/rest/test_flavors.py b/orm/services/flavor_manager/fms_rest/tests/rest/test_flavors.py index 14ecf544..6d472146 100755 --- a/orm/services/flavor_manager/fms_rest/tests/rest/test_flavors.py +++ b/orm/services/flavor_manager/fms_rest/tests/rest/test_flavors.py @@ -1,15 +1,13 @@ import copy import requests -from fms_rest.tests import FunctionalTest -from orm_common.injector import injector -from mock import MagicMock -from mock import patch import sqlalchemy +from fms_rest.controllers.v1.orm.flavors import flavors from fms_rest.data.wsme import models from fms_rest.logic.error_base import ErrorStatus -from fms_rest.controllers.v1.orm.flavors import flavors -from fms_rest.tests import test_utils +from fms_rest.tests import FunctionalTest, test_utils +from mock import MagicMock, patch +from orm_common.injector import injector utils_mock = None flavor_logic_mock = None diff --git a/orm/services/flavor_manager/fms_rest/tests/rest/test_os_extra_specs.py b/orm/services/flavor_manager/fms_rest/tests/rest/test_os_extra_specs.py index 74221c1a..6aaa58fb 100755 --- a/orm/services/flavor_manager/fms_rest/tests/rest/test_os_extra_specs.py +++ b/orm/services/flavor_manager/fms_rest/tests/rest/test_os_extra_specs.py @@ -1,12 +1,8 @@ -import json - from fms_rest.controllers.v1.orm.flavors import os_extra_specs as es from fms_rest.data.wsme import models from fms_rest.logic.error_base import NotFoundError from fms_rest.tests import FunctionalTest -from orm_common.injector import injector -from mock import MagicMock -from mock import patch +from mock import MagicMock, patch class TestOsExtraSpecsController(FunctionalTest): diff --git a/orm/services/flavor_manager/fms_rest/tests/rest/test_regions.py b/orm/services/flavor_manager/fms_rest/tests/rest/test_regions.py index bb968684..b58266d9 100755 --- a/orm/services/flavor_manager/fms_rest/tests/rest/test_regions.py +++ b/orm/services/flavor_manager/fms_rest/tests/rest/test_regions.py @@ -1,13 +1,11 @@ import requests -from fms_rest.tests import FunctionalTest -from orm_common.injector import injector -from mock import MagicMock -from mock import patch from fms_rest.controllers.v1.orm.flavors import regions from fms_rest.data.wsme import models from fms_rest.logic.error_base import ErrorStatus -from fms_rest.tests import test_utils +from fms_rest.tests import FunctionalTest, test_utils +from mock import MagicMock, patch +from orm_common.injector import injector utils_mock = None region_logic_mock = None diff --git a/orm/services/flavor_manager/fms_rest/tests/rest/test_tags.py b/orm/services/flavor_manager/fms_rest/tests/rest/test_tags.py index 568031bd..1b960be3 100644 --- a/orm/services/flavor_manager/fms_rest/tests/rest/test_tags.py +++ b/orm/services/flavor_manager/fms_rest/tests/rest/test_tags.py @@ -1,13 +1,10 @@ import requests -from fms_rest.tests import FunctionalTest -from orm_common.injector import injector -from mock import MagicMock -from mock import patch -import sqlalchemy from fms_rest.data.wsme import models from fms_rest.logic.error_base import ErrorStatus -from fms_rest.controllers.v1.orm.flavors import flavors +from fms_rest.tests import FunctionalTest +from mock import MagicMock +from orm_common.injector import injector utils_mock = None flavor_logic_mock = None diff --git a/orm/services/flavor_manager/fms_rest/tests/rest/test_tenants.py b/orm/services/flavor_manager/fms_rest/tests/rest/test_tenants.py index 1b3ec133..a5aebaa8 100755 --- a/orm/services/flavor_manager/fms_rest/tests/rest/test_tenants.py +++ b/orm/services/flavor_manager/fms_rest/tests/rest/test_tenants.py @@ -1,10 +1,10 @@ import requests -from fms_rest.tests import FunctionalTest -from orm_common.injector import injector -from mock import MagicMock from fms_rest.data.wsme import models from fms_rest.logic.error_base import ErrorStatus +from fms_rest.tests import FunctionalTest +from mock import MagicMock +from orm_common.injector import injector utils_mock = None tenant_logic_mock = None diff --git a/orm/services/flavor_manager/fms_rest/tests/test_authentication.py b/orm/services/flavor_manager/fms_rest/tests/test_authentication.py index e6deb140..52dbf2dc 100755 --- a/orm/services/flavor_manager/fms_rest/tests/test_authentication.py +++ b/orm/services/flavor_manager/fms_rest/tests/test_authentication.py @@ -1,8 +1,7 @@ -import mock from fms_rest.tests import FunctionalTest -from pecan import conf - from fms_rest.utils import authentication +import mock +from pecan import conf class TestUtil(FunctionalTest): diff --git a/orm/services/flavor_manager/fms_rest/tests/test_configuration.py b/orm/services/flavor_manager/fms_rest/tests/test_configuration.py index 957fa685..f64d6c1e 100755 --- a/orm/services/flavor_manager/fms_rest/tests/test_configuration.py +++ b/orm/services/flavor_manager/fms_rest/tests/test_configuration.py @@ -1,5 +1,4 @@ """Get configuration module unittests.""" -from fms_rest.controllers.v1.orm import configuration from fms_rest.tests import FunctionalTest from mock import patch diff --git a/orm/services/flavor_manager/fms_rest/tests/test_models.py b/orm/services/flavor_manager/fms_rest/tests/test_models.py index 21cda170..b56ec320 100755 --- a/orm/services/flavor_manager/fms_rest/tests/test_models.py +++ b/orm/services/flavor_manager/fms_rest/tests/test_models.py @@ -1,7 +1,6 @@ -import mock -from fms_rest.tests import FunctionalTest - from fms_rest.data.wsme import models +from fms_rest.tests import FunctionalTest +import mock GROUP_REGIONS = [ "DPK", @@ -31,8 +30,8 @@ class TestModels(FunctionalTest): def get_flavor_model(): - """ - this function create a customer model object for testing + """this function create a customer model object for testing + :return: new customer object """ diff --git a/orm/services/flavor_manager/fms_rest/tests/test_rds_proxy.py b/orm/services/flavor_manager/fms_rest/tests/test_rds_proxy.py index 53708c64..53895dfb 100755 --- a/orm/services/flavor_manager/fms_rest/tests/test_rds_proxy.py +++ b/orm/services/flavor_manager/fms_rest/tests/test_rds_proxy.py @@ -1,9 +1,8 @@ -import mock -from fms_rest.tests import FunctionalTest -from fms_rest import proxies from fms_rest.data.sql_alchemy import db_models -from fms_rest.logic.error_base import ErrorStatus -from testfixtures import log_capture, compare +from fms_rest import proxies +from fms_rest.tests import FunctionalTest +import mock +from testfixtures import log_capture class Response: diff --git a/orm/services/flavor_manager/fms_rest/tests/test_utils.py b/orm/services/flavor_manager/fms_rest/tests/test_utils.py index 5fdf9280..94ba5c04 100755 --- a/orm/services/flavor_manager/fms_rest/tests/test_utils.py +++ b/orm/services/flavor_manager/fms_rest/tests/test_utils.py @@ -1,4 +1,5 @@ import json + from wsme.exc import ClientSideError diff --git a/orm/services/flavor_manager/fms_rest/utils/authentication.py b/orm/services/flavor_manager/fms_rest/utils/authentication.py index 99cb1c4b..43eaf965 100644 --- a/orm/services/flavor_manager/fms_rest/utils/authentication.py +++ b/orm/services/flavor_manager/fms_rest/utils/authentication.py @@ -2,9 +2,8 @@ import logging from keystone_utils import tokens from orm_common.policy import policy -from orm_common.utils import api_error_utils as err_utils - from pecan import conf + logger = logging.getLogger(__name__) diff --git a/orm/services/flavor_manager/fms_rest/utils/utils.py b/orm/services/flavor_manager/fms_rest/utils/utils.py index 3a02d50b..388c101c 100755 --- a/orm/services/flavor_manager/fms_rest/utils/utils.py +++ b/orm/services/flavor_manager/fms_rest/utils/utils.py @@ -1,8 +1,8 @@ -from pecan import conf import time -from orm_common.injector import injector from fms_rest.logger import get_logger +from orm_common.injector import injector +from pecan import conf logger = get_logger(__name__) diff --git a/orm/services/flavor_manager/pycharm_init.py b/orm/services/flavor_manager/pycharm_init.py index 469a65d9..5b11a0d4 100755 --- a/orm/services/flavor_manager/pycharm_init.py +++ b/orm/services/flavor_manager/pycharm_init.py @@ -1,3 +1,4 @@ from pecan.commands import CommandRunner + runner = CommandRunner() runner.run(['serve', 'config.py']) diff --git a/orm/services/flavor_manager/run_pecan.py b/orm/services/flavor_manager/run_pecan.py index 4d1ce01d..0fbfa08e 100644 --- a/orm/services/flavor_manager/run_pecan.py +++ b/orm/services/flavor_manager/run_pecan.py @@ -2,5 +2,6 @@ ' this script is running the pecan web server inside ide so we can set break points in the code and debug our code ''' from pecan.commands import CommandRunner + runner = CommandRunner() runner.run(['serve', 'config.py']) diff --git a/orm/services/id_generator/uuidgen/app.py b/orm/services/id_generator/uuidgen/app.py index 85b9cc38..c421f166 100755 --- a/orm/services/id_generator/uuidgen/app.py +++ b/orm/services/id_generator/uuidgen/app.py @@ -1,7 +1,8 @@ -import os import logging -from pecan import make_app +import os + from pecan.commands import CommandRunner +from pecan import make_app from uuidgen import model logger = logging.getLogger(__name__) @@ -23,4 +24,4 @@ def main(): drive, path_and_file = os.path.splitdrive(dir_name) path, filename = os.path.split(path_and_file) runner = CommandRunner() - runner.run(['serve', path+'/config.py']) + runner.run(['serve', path + '/config.py']) diff --git a/orm/services/id_generator/uuidgen/controllers/root.py b/orm/services/id_generator/uuidgen/controllers/root.py index 555d6bd6..9f5a7f7e 100755 --- a/orm/services/id_generator/uuidgen/controllers/root.py +++ b/orm/services/id_generator/uuidgen/controllers/root.py @@ -1,9 +1,8 @@ +import logging + from pecan import expose from pecan.rest import RestController -from webob.exc import status_map - import uuidgen.controllers.v1.root as root -import logging LOG = logging.getLogger(__name__) @@ -14,9 +13,8 @@ class RootController(RestController): @expose(template='json') def get(self): - """ - Method to handle GET / - prameters: None + """Method to handle GET / + parameters: None return: dict describing uuid command version information """ LOG.info("root -get versions") diff --git a/orm/services/id_generator/uuidgen/controllers/v1/configuration.py b/orm/services/id_generator/uuidgen/controllers/v1/configuration.py index f6bdd0bd..c619f82d 100755 --- a/orm/services/id_generator/uuidgen/controllers/v1/configuration.py +++ b/orm/services/id_generator/uuidgen/controllers/v1/configuration.py @@ -1,28 +1,28 @@ -"""Configuration rest API input module.""" - -import logging -from orm_common.utils import utils -from pecan import conf -from pecan import rest -from wsmeext.pecan import wsexpose - -logger = logging.getLogger(__name__) - - -class ConfigurationController(rest.RestController): - """Configuration controller.""" - - @wsexpose(str, str, status_code=200) - def get(self, dump_to_log='false'): - """get method. - - :param dump_to_log: A boolean string that says whether the - configuration should be written to log - :return: A pretty string that contains the service's configuration - """ - logger.info("Get configuration...") - - dump = dump_to_log.lower() == 'true' - utils.set_utils_conf(conf) - result = utils.report_config(conf, dump, logger) - return result +"""Configuration rest API input module.""" + +import logging + +from orm_common.utils import utils +from pecan import conf, rest +from wsmeext.pecan import wsexpose + +logger = logging.getLogger(__name__) + + +class ConfigurationController(rest.RestController): + """Configuration controller.""" + + @wsexpose(str, str, status_code=200) + def get(self, dump_to_log='false'): + """get method. + + :param dump_to_log: A boolean string that says whether the + configuration should be written to log + :return: A pretty string that contains the service's configuration + """ + logger.info("Get configuration...") + + dump = dump_to_log.lower() == 'true' + utils.set_utils_conf(conf) + result = utils.report_config(conf, dump, logger) + return result diff --git a/orm/services/id_generator/uuidgen/controllers/v1/root.py b/orm/services/id_generator/uuidgen/controllers/v1/root.py index 46affcb9..e582c664 100755 --- a/orm/services/id_generator/uuidgen/controllers/v1/root.py +++ b/orm/services/id_generator/uuidgen/controllers/v1/root.py @@ -1,6 +1,6 @@ import uuidgen.controllers.v1.configuration as configuration -import uuidgen.controllers.v1.uuid_controller as v1 import uuidgen.controllers.v1.logs as logs +import uuidgen.controllers.v1.uuid_controller as v1 class RootController(object): diff --git a/orm/services/id_generator/uuidgen/controllers/v1/uuid_controller.py b/orm/services/id_generator/uuidgen/controllers/v1/uuid_controller.py index bc9ba278..709a36bf 100755 --- a/orm/services/id_generator/uuidgen/controllers/v1/uuid_controller.py +++ b/orm/services/id_generator/uuidgen/controllers/v1/uuid_controller.py @@ -4,16 +4,13 @@ import uuid from pecan import expose, response from pecan.rest import RestController - from uuidgen.db.db_manager import DBManager LOG = logging.getLogger(__name__) def respond(reason, code, message): - """ - A helper function to create a response dict with the given values - """ + """A helper function to create a response dict with the given values""" return { reason: { "code": code, @@ -25,8 +22,8 @@ def respond(reason, code, message): class UUIDController(RestController): @expose(template='json') def post(self, **kw): - """ - Method to handle POST /v1/uuids - create and return a new uuid + """Method to handle POST /v1/uuids + create and return a new uuid prameters: uuid_type (optional) return: dict describing success or failure of post command diff --git a/orm/services/id_generator/uuidgen/db/db_manager.py b/orm/services/id_generator/uuidgen/db/db_manager.py index c43cfc7d..b1677080 100755 --- a/orm/services/id_generator/uuidgen/db/db_manager.py +++ b/orm/services/id_generator/uuidgen/db/db_manager.py @@ -1,8 +1,9 @@ -from pecan import conf -from oslo_db.sqlalchemy import session as db_session -from uuid_db import UUID import logging +from oslo_db.sqlalchemy import session as db_session +from pecan import conf +from uuid_db import UUID + logger = logging.getLogger(__name__) diff --git a/orm/services/id_generator/uuidgen/db/uuid_db.py b/orm/services/id_generator/uuidgen/db/uuid_db.py index 134ea96c..f51a48d3 100755 --- a/orm/services/id_generator/uuidgen/db/uuid_db.py +++ b/orm/services/id_generator/uuidgen/db/uuid_db.py @@ -1,8 +1,9 @@ -from sqlalchemy.ext.declarative import declarative_base -from sqlalchemy import Column, String, Integer -from oslo_db.sqlalchemy import models import logging +from oslo_db.sqlalchemy import models +from sqlalchemy import Column, Integer, String +from sqlalchemy.ext.declarative import declarative_base + LOG = logging.getLogger(__name__) diff --git a/orm/services/id_generator/uuidgen/external_mock/orm_common/utils/utils.py b/orm/services/id_generator/uuidgen/external_mock/orm_common/utils/utils.py index e1fc153a..ba516a7a 100755 --- a/orm/services/id_generator/uuidgen/external_mock/orm_common/utils/utils.py +++ b/orm/services/id_generator/uuidgen/external_mock/orm_common/utils/utils.py @@ -1,13 +1,13 @@ -"""Utils module mock.""" - - -def report_config(conf, dump=False): - """Mock report_config function.""" - - pass - - -def set_utils_conf(conf): - """Mock set_utils_conf function.""" - - pass +"""Utils module mock.""" + + +def report_config(conf, dump=False): + """Mock report_config function.""" + + pass + + +def set_utils_conf(conf): + """Mock set_utils_conf function.""" + + pass diff --git a/orm/services/id_generator/uuidgen/model/__init__.py b/orm/services/id_generator/uuidgen/model/__init__.py index d983f7bc..2eef4a20 100644 --- a/orm/services/id_generator/uuidgen/model/__init__.py +++ b/orm/services/id_generator/uuidgen/model/__init__.py @@ -2,8 +2,7 @@ from pecan import conf # noqa def init_model(): - """ - This is a stub method which is called at application startup time. + """This is a stub method which is called at application startup time. If you need to bind to a parsed database configuration, set up tables or ORM classes, or perform any database initialization, this is the diff --git a/orm/services/id_generator/uuidgen/tests/__init__.py b/orm/services/id_generator/uuidgen/tests/__init__.py index 78ea5274..55396865 100644 --- a/orm/services/id_generator/uuidgen/tests/__init__.py +++ b/orm/services/id_generator/uuidgen/tests/__init__.py @@ -1,15 +1,15 @@ import os -from unittest import TestCase from pecan import set_config from pecan.testing import load_test_app +from unittest import TestCase __all__ = ['FunctionalTest'] class FunctionalTest(TestCase): - """ - Used for functional tests where you need to test your - literal application and its integration with the framework. + """Used for functional tests + where you need to test your literal application + and its integration with the framework. """ def setUp(self): diff --git a/orm/services/id_generator/uuidgen/tests/test_configuration.py b/orm/services/id_generator/uuidgen/tests/test_configuration.py index 58434c4e..232fd91b 100755 --- a/orm/services/id_generator/uuidgen/tests/test_configuration.py +++ b/orm/services/id_generator/uuidgen/tests/test_configuration.py @@ -1,14 +1,14 @@ -"""Get configuration module unittests.""" -from mock import patch -from uuidgen.controllers.v1 import configuration as root -from uuidgen.tests import FunctionalTest - - -class TestGetConfiguration(FunctionalTest): - """Main get configuration test case.""" - - @patch.object(root.utils, 'report_config', return_value='12345') - def test_get_configuration_success(self, input): - """Test get_configuration returns the expected value on success.""" - response = self.app.get('/v1/configuration') - self.assertEqual(response.json, '12345') +"""Get configuration module unittests.""" +from mock import patch +from uuidgen.controllers.v1 import configuration as root +from uuidgen.tests import FunctionalTest + + +class TestGetConfiguration(FunctionalTest): + """Main get configuration test case.""" + + @patch.object(root.utils, 'report_config', return_value='12345') + def test_get_configuration_success(self, input): + """Test get_configuration returns the expected value on success.""" + response = self.app.get('/v1/configuration') + self.assertEqual(response.json, '12345') diff --git a/orm/services/id_generator/uuidgen/tests/test_functional.py b/orm/services/id_generator/uuidgen/tests/test_functional.py index 2ef82327..1e847f37 100755 --- a/orm/services/id_generator/uuidgen/tests/test_functional.py +++ b/orm/services/id_generator/uuidgen/tests/test_functional.py @@ -1,9 +1,9 @@ -import mock -from uuidgen.tests import FunctionalTest -import re -import uuidgen.controllers.v1.uuid_controller as uuid_controller -import uuidgen.controllers.v1.uuid_controller import json +import re + +import mock +import uuidgen.controllers.v1.uuid_controller as uuid_controller +from uuidgen.tests import FunctionalTest class MyException(Exception): diff --git a/orm/services/id_generator/uuidgen/tests/test_logs.py b/orm/services/id_generator/uuidgen/tests/test_logs.py index ce344f83..22d6baff 100755 --- a/orm/services/id_generator/uuidgen/tests/test_logs.py +++ b/orm/services/id_generator/uuidgen/tests/test_logs.py @@ -1,18 +1,19 @@ -"""Set log level module unittests.""" -# import logging -# import mock -# from mock import patch -from uuidgen.controllers.v1 import logs -from uuidgen.tests import FunctionalTest - - -class TestLogs(FunctionalTest): - """Main test case.""" - - def test_change_log_level_sanity(self): - logs.__name__ = 'test.test' - response = self.app.put('/v1/logs', 'level=DEBUG') - - def test_change_log_level_bad_log_level(self): - logs.__name__ = 'test' - response = self.app.put('/v1/logs', 'level') +"""Set log level module unittests.""" + +# import mock +# from mock import patch +from uuidgen.controllers.v1 import logs +# import logging +from uuidgen.tests import FunctionalTest + + +class TestLogs(FunctionalTest): + """Main test case.""" + + def test_change_log_level_sanity(self): + logs.__name__ = 'test.test' + response = self.app.put('/v1/logs', 'level=DEBUG') + + def test_change_log_level_bad_log_level(self): + logs.__name__ = 'test' + response = self.app.put('/v1/logs', 'level') diff --git a/orm/services/image_manager/config.py b/orm/services/image_manager/config.py index a7bbf522..4ac9f014 100755 --- a/orm/services/image_manager/config.py +++ b/orm/services/image_manager/config.py @@ -1,6 +1,6 @@ +from ims.hooks.service_hooks import TransIdHook from orm_common.hooks.api_error_hook import APIErrorHook from orm_common.hooks.security_headers_hook import SecurityHeadersHook -from ims.hooks.service_hooks import TransIdHook global TransIdHook global APIErrorHook diff --git a/orm/services/image_manager/data_manager_test.py b/orm/services/image_manager/data_manager_test.py index 6fa2cfa7..7c0ea79d 100755 --- a/orm/services/image_manager/data_manager_test.py +++ b/orm/services/image_manager/data_manager_test.py @@ -1,15 +1,15 @@ -from ims.logger import get_logger +import os import traceback +from ims.logger import get_logger from ims.persistency.sql_alchemy.data_manager import DataManager - +from ims.persistency.sql_alchemy.db_models import (Image, ImageCustomer, + ImageProperty, ImageRegion) +from pecan import conf +from pecan.testing import load_test_app # conf = imp.load_source('config.py', '../config.py') -from pecan.testing import load_test_app -import os -from pecan import conf -from ims.persistency.sql_alchemy.db_models import Image, ImageProperty, ImageRegion, ImageCustomer image_id = "Id 11" # image id diff --git a/orm/services/image_manager/ims/app.py b/orm/services/image_manager/ims/app.py index df13bbe3..7b2ed883 100755 --- a/orm/services/image_manager/ims/app.py +++ b/orm/services/image_manager/ims/app.py @@ -1,13 +1,12 @@ -from pecan import make_app -from pecan import conf -from ims.logger import get_logger -from orm_common.utils.utils import set_utils_conf -from pecan.commands import CommandRunner +import os +from ims.logger import get_logger from ims.utils import authentication as auth from orm_common.policy import policy +from orm_common.utils.utils import set_utils_conf +from pecan import conf, make_app +from pecan.commands import CommandRunner -import os logger = get_logger(__name__) @@ -33,4 +32,4 @@ def main(): drive, path_and_file = os.path.splitdrive(dir_name) path, filename = os.path.split(path_and_file) runner = CommandRunner() - runner.run(['serve', path+'/config.py']) + runner.run(['serve', path + '/config.py']) diff --git a/orm/services/image_manager/ims/controllers/__init__.py b/orm/services/image_manager/ims/controllers/__init__.py index d1cde99e..c705b745 100755 --- a/orm/services/image_manager/ims/controllers/__init__.py +++ b/orm/services/image_manager/ims/controllers/__init__.py @@ -1,8 +1,9 @@ """Init package.""" import os + +import ims.di_providers as di_providers from ims.logger import get_logger from orm_common.injector import injector -import ims.di_providers as di_providers logger = get_logger(__name__) diff --git a/orm/services/image_manager/ims/controllers/root.py b/orm/services/image_manager/ims/controllers/root.py index 181cbbda..94d02091 100755 --- a/orm/services/image_manager/ims/controllers/root.py +++ b/orm/services/image_manager/ims/controllers/root.py @@ -1,11 +1,6 @@ -from pecan import conf -from pecan import rest -from pecan import expose, request - -from webob.exc import status_map -from pecan.secure import SecureController from ims.controllers.v1.v1 import V1Controller -from ims.utils import authentication +from pecan import conf, expose +from webob.exc import status_map class RootController(object): @@ -13,8 +8,7 @@ class RootController(object): @expose(template='json') def get(self): - """ - Method to handle GET / + """Method to handle GET / prameters: None return: dict describing image command version information """ diff --git a/orm/services/image_manager/ims/controllers/v1/orm/configuration.py b/orm/services/image_manager/ims/controllers/v1/orm/configuration.py index 258132fc..c619f82d 100755 --- a/orm/services/image_manager/ims/controllers/v1/orm/configuration.py +++ b/orm/services/image_manager/ims/controllers/v1/orm/configuration.py @@ -1,11 +1,10 @@ """Configuration rest API input module.""" import logging -from orm_common.utils import utils -from pecan import conf -from pecan import rest -from wsmeext.pecan import wsexpose +from orm_common.utils import utils +from pecan import conf, rest +from wsmeext.pecan import wsexpose logger = logging.getLogger(__name__) diff --git a/orm/services/image_manager/ims/controllers/v1/orm/images/customers.py b/orm/services/image_manager/ims/controllers/v1/orm/images/customers.py index 4fc9aae8..c404be1d 100755 --- a/orm/services/image_manager/ims/controllers/v1/orm/images/customers.py +++ b/orm/services/image_manager/ims/controllers/v1/orm/images/customers.py @@ -1,14 +1,11 @@ -from pecan import rest, request -from pecan.core import abort -from wsmeext.pecan import wsexpose -from orm_common.injector import injector - -from ims.persistency.wsme.models import ImageWrapper, CustomerWrapper -from ims.logic.error_base import ErrorStatus -from orm_common.utils import api_error_utils as err_utils -from ims.utils import authentication as auth - from ims.logger import get_logger +from ims.logic.error_base import ErrorStatus +from ims.persistency.wsme.models import CustomerWrapper, ImageWrapper +from ims.utils import authentication as auth +from orm_common.injector import injector +from orm_common.utils import api_error_utils as err_utils +from pecan import request, rest +from wsmeext.pecan import wsexpose LOG = get_logger(__name__) diff --git a/orm/services/image_manager/ims/controllers/v1/orm/images/enabled.py b/orm/services/image_manager/ims/controllers/v1/orm/images/enabled.py index 93ea5c52..789622c7 100755 --- a/orm/services/image_manager/ims/controllers/v1/orm/images/enabled.py +++ b/orm/services/image_manager/ims/controllers/v1/orm/images/enabled.py @@ -1,13 +1,13 @@ """Status (activate/deactivate) Image rest API input module.""" -from pecan import conf, rest, request -from wsmeext.pecan import wsexpose from ims.logger import get_logger -from orm_common.injector import injector from ims.logic.error_base import ErrorStatus from ims.persistency.wsme.models import Enabled, ImageWrapper -from orm_common.utils import api_error_utils as err_utils from ims.utils import authentication as auth +from orm_common.injector import injector +from orm_common.utils import api_error_utils as err_utils +from pecan import request, rest +from wsmeext.pecan import wsexpose di = injector.get_di() diff --git a/orm/services/image_manager/ims/controllers/v1/orm/images/images.py b/orm/services/image_manager/ims/controllers/v1/orm/images/images.py index 1a8aa564..fb89cfb3 100755 --- a/orm/services/image_manager/ims/controllers/v1/orm/images/images.py +++ b/orm/services/image_manager/ims/controllers/v1/orm/images/images.py @@ -1,19 +1,16 @@ -from pecan import rest, request - -from wsmeext.pecan import wsexpose -from pecan import expose, abort import oslo_db -from ims.controllers.v1.orm.images.regions import RegionController + from ims.controllers.v1.orm.images.customers import CustomerController from ims.controllers.v1.orm.images.enabled import EnabledController - -from ims.persistency.wsme.models import ImageWrapper, ImageSummaryResponse -from ims.logic.error_base import ErrorStatus +from ims.controllers.v1.orm.images.regions import RegionController from ims.logger import get_logger +from ims.logic.error_base import ErrorStatus +from ims.persistency.wsme.models import ImageSummaryResponse, ImageWrapper +from ims.utils import authentication as auth from orm_common.injector import injector from orm_common.utils import api_error_utils as err_utils -from ims.utils import authentication as auth - +from pecan import request, rest +from wsmeext.pecan import wsexpose di = injector.get_di() LOG = get_logger(__name__) diff --git a/orm/services/image_manager/ims/controllers/v1/orm/images/metadata.py b/orm/services/image_manager/ims/controllers/v1/orm/images/metadata.py index c2601ba9..48e5f5a7 100644 --- a/orm/services/image_manager/ims/controllers/v1/orm/images/metadata.py +++ b/orm/services/image_manager/ims/controllers/v1/orm/images/metadata.py @@ -1,14 +1,11 @@ -from pecan import rest, request, response -from wsmeext.pecan import wsexpose -from ims.persistency.wsme.models import MetadataWrapper - -from orm_common.injector import injector - -from ims.logic.error_base import ErrorStatus - from ims.logger import get_logger -from orm_common.utils import api_error_utils as err_utils +from ims.logic.error_base import ErrorStatus +from ims.persistency.wsme.models import MetadataWrapper from ims.utils import authentication as auth +from orm_common.injector import injector +from orm_common.utils import api_error_utils as err_utils +from pecan import request, rest +from wsmeext.pecan import wsexpose LOG = get_logger(__name__) diff --git a/orm/services/image_manager/ims/controllers/v1/orm/images/regions.py b/orm/services/image_manager/ims/controllers/v1/orm/images/regions.py index 6128a39b..8ba4c66f 100755 --- a/orm/services/image_manager/ims/controllers/v1/orm/images/regions.py +++ b/orm/services/image_manager/ims/controllers/v1/orm/images/regions.py @@ -1,16 +1,12 @@ -from pecan import rest, request, response -from wsmeext.pecan import wsexpose - from ims.controllers.v1.orm.images.metadata import MetadataController -from ims.persistency.wsme.models import RegionWrapper - -from orm_common.injector import injector - -from ims.logic.error_base import ErrorStatus - from ims.logger import get_logger -from orm_common.utils import api_error_utils as err_utils +from ims.logic.error_base import ErrorStatus +from ims.persistency.wsme.models import RegionWrapper from ims.utils import authentication as auth +from orm_common.injector import injector +from orm_common.utils import api_error_utils as err_utils +from pecan import request, rest +from wsmeext.pecan import wsexpose LOG = get_logger(__name__) diff --git a/orm/services/image_manager/ims/controllers/v1/orm/logs.py b/orm/services/image_manager/ims/controllers/v1/orm/logs.py index 0be7d9f6..6b672672 100755 --- a/orm/services/image_manager/ims/controllers/v1/orm/logs.py +++ b/orm/services/image_manager/ims/controllers/v1/orm/logs.py @@ -4,7 +4,6 @@ from pecan import rest import wsme from wsmeext.pecan import wsexpose - logger = logging.getLogger(__name__) diff --git a/orm/services/image_manager/ims/di_providers/mock_providers.py b/orm/services/image_manager/ims/di_providers/mock_providers.py index 626f0713..d833adaa 100755 --- a/orm/services/image_manager/ims/di_providers/mock_providers.py +++ b/orm/services/image_manager/ims/di_providers/mock_providers.py @@ -1,9 +1,6 @@ -from ims.ims_mocks import requests_mock -from ims.ims_mocks import audit_mock - +from ims.ims_mocks import audit_mock, requests_mock +from ims.logic import image_logic, metadata_logic from ims.persistency.sql_alchemy.data_manager import DataManager -from ims.logic import image_logic -from ims.logic import metadata_logic from ims.proxies import rds_proxy from orm_common.utils import utils diff --git a/orm/services/image_manager/ims/di_providers/prod_providers.py b/orm/services/image_manager/ims/di_providers/prod_providers.py index 845459c4..e8bbe902 100644 --- a/orm/services/image_manager/ims/di_providers/prod_providers.py +++ b/orm/services/image_manager/ims/di_providers/prod_providers.py @@ -1,13 +1,11 @@ import requests + from audit_client.api import audit - -from ims.proxies import rds_proxy -from ims.logic import image_logic -from ims.logic import metadata_logic +from ims.logic import image_logic, metadata_logic from ims.persistency.sql_alchemy.data_manager import DataManager +from ims.proxies import rds_proxy from orm_common.utils import utils - providers = [ ('rds_proxy', rds_proxy), ('image_logic', image_logic), diff --git a/orm/services/image_manager/ims/external_mock/orm_common/injector/fang/__init__.py b/orm/services/image_manager/ims/external_mock/orm_common/injector/fang/__init__.py index 18404b50..e69de29b 100755 --- a/orm/services/image_manager/ims/external_mock/orm_common/injector/fang/__init__.py +++ b/orm/services/image_manager/ims/external_mock/orm_common/injector/fang/__init__.py @@ -1,7 +0,0 @@ -''' -''' - -from .di import Di -from .dependency_register import DependencyRegister -from .resource_provider_register import ResourceProviderRegister -from .resolver import DependencyResolver diff --git a/orm/services/image_manager/ims/external_mock/orm_common/injector/fang/dependency_register.py b/orm/services/image_manager/ims/external_mock/orm_common/injector/fang/dependency_register.py index 7b4d7093..9a3b0b82 100755 --- a/orm/services/image_manager/ims/external_mock/orm_common/injector/fang/dependency_register.py +++ b/orm/services/image_manager/ims/external_mock/orm_common/injector/fang/dependency_register.py @@ -18,9 +18,7 @@ class DependencyRegister: @classmethod def _unwrap_func(cls, decorated_func): - ''' - This unwraps a decorated func, returning the inner wrapped func. - + '''This unwraps a decorated func, returning the inner wrapped func. This may become unnecessary with Python 3.4's inspect.unwrap(). ''' if click is not None: diff --git a/orm/services/image_manager/ims/external_mock/orm_common/injector/fang/di.py b/orm/services/image_manager/ims/external_mock/orm_common/injector/fang/di.py index 6a436354..76b4304a 100755 --- a/orm/services/image_manager/ims/external_mock/orm_common/injector/fang/di.py +++ b/orm/services/image_manager/ims/external_mock/orm_common/injector/fang/di.py @@ -1,6 +1,6 @@ from .dependency_register import DependencyRegister -from .resource_provider_register import ResourceProviderRegister from .resolver import DependencyResolver +from .resource_provider_register import ResourceProviderRegister class Di: diff --git a/orm/services/image_manager/ims/external_mock/orm_common/injector/fang/resource_provider_register.py b/orm/services/image_manager/ims/external_mock/orm_common/injector/fang/resource_provider_register.py index 58da4619..c3ff580f 100755 --- a/orm/services/image_manager/ims/external_mock/orm_common/injector/fang/resource_provider_register.py +++ b/orm/services/image_manager/ims/external_mock/orm_common/injector/fang/resource_provider_register.py @@ -1,9 +1,7 @@ from functools import partial -from .errors import ( - FangError, - ProviderAlreadyRegisteredError, - ProviderNotFoundError) +from .errors import (FangError, ProviderAlreadyRegisteredError, + ProviderNotFoundError) class ResourceProviderRegister: diff --git a/orm/services/image_manager/ims/external_mock/orm_common/injector/injector.py b/orm/services/image_manager/ims/external_mock/orm_common/injector/injector.py index 39264441..de6ce891 100755 --- a/orm/services/image_manager/ims/external_mock/orm_common/injector/injector.py +++ b/orm/services/image_manager/ims/external_mock/orm_common/injector/injector.py @@ -1,6 +1,7 @@ -from orm_common.injector import fang -import os import imp +import os + +from orm_common.injector import fang _di = fang.Di() logger = None diff --git a/orm/services/image_manager/ims/external_mock/orm_common/utils/cross_api_utils.py b/orm/services/image_manager/ims/external_mock/orm_common/utils/cross_api_utils.py index 11233bbe..b2183133 100755 --- a/orm/services/image_manager/ims/external_mock/orm_common/utils/cross_api_utils.py +++ b/orm/services/image_manager/ims/external_mock/orm_common/utils/cross_api_utils.py @@ -1,10 +1,9 @@ -import requests -import logging -from pecan import conf -from audit_client.api import audit import time +import requests + from orm_common.logger import get_logger +from pecan import conf logger = get_logger(__name__) diff --git a/orm/services/image_manager/ims/external_mock/orm_common/utils/utils.py b/orm/services/image_manager/ims/external_mock/orm_common/utils/utils.py index 49d90ecc..0bdf312e 100755 --- a/orm/services/image_manager/ims/external_mock/orm_common/utils/utils.py +++ b/orm/services/image_manager/ims/external_mock/orm_common/utils/utils.py @@ -1,11 +1,11 @@ -import requests import pprint -import logging -from pecan import conf -from audit_client.api import audit import time +import requests + +from audit_client.api import audit from orm_common.logger import get_logger +from pecan import conf logger = get_logger(__name__) diff --git a/orm/services/image_manager/ims/ims_mocks/requests_mock.py b/orm/services/image_manager/ims/ims_mocks/requests_mock.py index e1020b1e..fa519128 100755 --- a/orm/services/image_manager/ims/ims_mocks/requests_mock.py +++ b/orm/services/image_manager/ims/ims_mocks/requests_mock.py @@ -1,9 +1,9 @@ import copy import uuid -from mock import MagicMock -from ims.persistency.sql_alchemy.data_manager import DataManager from ims.logger import get_logger +from ims.persistency.sql_alchemy.data_manager import DataManager +from mock import MagicMock logger = get_logger(__name__) diff --git a/orm/services/image_manager/ims/logic/image_logic.py b/orm/services/image_manager/ims/logic/image_logic.py index f0429b9e..88d5e25b 100755 --- a/orm/services/image_manager/ims/logic/image_logic.py +++ b/orm/services/image_manager/ims/logic/image_logic.py @@ -1,15 +1,12 @@ -from ims.logger import get_logger -from ims.persistency.wsme.models import ImageWrapper, ImageSummaryResponse -from ims.persistency.wsme.models import Region, ImageSummary, RegionWrapper -from ims.persistency.sql_alchemy.db_models import ImageRegion, ImageCustomer -from ims.logic.error_base import ErrorStatus, NotFoundError, NoContentError -from ims.utils import utils as ImsUtils - -from orm_common.utils import utils -from orm_common.injector import injector import time -from pecan import request, conf +from ims.logger import get_logger +from ims.logic.error_base import ErrorStatus, NotFoundError +from ims.persistency.sql_alchemy.db_models import ImageCustomer, ImageRegion +from ims.persistency.wsme.models import (ImageSummary, ImageSummaryResponse, + ImageWrapper, RegionWrapper) +from ims.utils import utils as ImsUtils +from orm_common.injector import injector LOG = get_logger(__name__) diff --git a/orm/services/image_manager/ims/persistency/sql_alchemy/data_manager.py b/orm/services/image_manager/ims/persistency/sql_alchemy/data_manager.py index c3a69f3e..b637d292 100755 --- a/orm/services/image_manager/ims/persistency/sql_alchemy/data_manager.py +++ b/orm/services/image_manager/ims/persistency/sql_alchemy/data_manager.py @@ -1,14 +1,8 @@ -from sqlalchemy import create_engine -from sqlalchemy.orm import sessionmaker -from sqlalchemy.event import listen -from sqlalchemy import exc -from pecan import conf -from oslo_db.sqlalchemy import session as db_session from ims.logger import get_logger - from ims.persistency.sql_alchemy.image.image_record import ImageRecord -from ims.logic.error_base import DuplicateEntityError - +from oslo_db.sqlalchemy import session as db_session +from pecan import conf +from sqlalchemy.event import listen LOG = get_logger(__name__) diff --git a/orm/services/image_manager/ims/persistency/sql_alchemy/db_models.py b/orm/services/image_manager/ims/persistency/sql_alchemy/db_models.py index 64d991f2..a8932005 100755 --- a/orm/services/image_manager/ims/persistency/sql_alchemy/db_models.py +++ b/orm/services/image_manager/ims/persistency/sql_alchemy/db_models.py @@ -9,17 +9,17 @@ # For more information visit http://www.igenxsoft.com ### -from sqlalchemy import (Column, Integer, SmallInteger, String, - ForeignKeyConstraint) +from ims.logger import get_logger +from ims.logic.error_base import ErrorStatus, NotFoundError +from orm_common.utils.cross_api_utils import (get_regions_of_group, + set_utils_conf) +from oslo_db.sqlalchemy import models +from pecan import conf +from sqlalchemy import (Column, ForeignKeyConstraint, Integer, SmallInteger, + String) from sqlalchemy.ext.declarative import declarative_base from sqlalchemy.orm import relationship -from oslo_db.sqlalchemy import models -from ims.logger import get_logger -from orm_common.utils.cross_api_utils import get_regions_of_group, set_utils_conf -from pecan import conf -from ims.logic.error_base import NotFoundError -from ims.logic.error_base import ErrorStatus Base = declarative_base() LOG = get_logger(__name__) diff --git a/orm/services/image_manager/ims/persistency/sql_alchemy/image/image_record.py b/orm/services/image_manager/ims/persistency/sql_alchemy/image/image_record.py index 4b35d8c3..c115d7c3 100755 --- a/orm/services/image_manager/ims/persistency/sql_alchemy/image/image_record.py +++ b/orm/services/image_manager/ims/persistency/sql_alchemy/image/image_record.py @@ -1,8 +1,7 @@ -from ims.persistency.sql_alchemy.db_models import Image -from ims.persistency.sql_alchemy.db_models import ImageRegion -from ims.persistency.sql_alchemy.db_models import ImageCustomer -from ims.persistency.sql_alchemy.infra.record import Record from ims.logger import get_logger +from ims.persistency.sql_alchemy.db_models import (Image, ImageCustomer, + ImageRegion) +from ims.persistency.sql_alchemy.infra.record import Record LOG = get_logger(__name__) diff --git a/orm/services/image_manager/ims/persistency/wsme/models.py b/orm/services/image_manager/ims/persistency/wsme/models.py index 3e3488ab..ef8aea03 100755 --- a/orm/services/image_manager/ims/persistency/wsme/models.py +++ b/orm/services/image_manager/ims/persistency/wsme/models.py @@ -1,12 +1,11 @@ """Image model module.""" -import wsme -from pecan import conf -from pecan import request - from ims.logic.error_base import ErrorStatus -from ims.persistency.wsme.base import Model from ims.persistency.sql_alchemy import db_models -from orm_common.utils.cross_api_utils import set_utils_conf, get_regions_of_group +from ims.persistency.wsme.base import Model +from orm_common.utils.cross_api_utils import (get_regions_of_group, + set_utils_conf) +from pecan import conf, request +import wsme class Metadata(Model): @@ -90,7 +89,7 @@ class RegionWrapper(Model): # pragma: no cover regions = wsme.wsattr([Region], mandatory=False) def __init__(self, regions=[]): - """ + """init :param regions: array of regions """ self.regions = regions @@ -102,7 +101,7 @@ class CustomerWrapper(Model): # pragma: no cover customers = wsme.wsattr(wsme.types.ArrayType(str), mandatory=False) def __init__(self, customers=[]): - """ + """init :param regions: array of regions """ self.customers = customers @@ -394,7 +393,7 @@ class ImageWrapper(Model): image = wsme.wsattr(Image, mandatory=True, name='image') def __init__(self, image=Image()): - """ + """init :param image: image dict """ @@ -420,9 +419,7 @@ class ImageWrapper(Model): return image -''' -' ImageSummary a DataObject contains all the fields defined in ImageSummary. -''' +# ImageSummary a DataObject contains all the fields defined in ImageSummary. class ImageSummary(Model): diff --git a/orm/services/image_manager/ims/proxies/rds_proxy.py b/orm/services/image_manager/ims/proxies/rds_proxy.py index 969c3ac8..4156eed0 100755 --- a/orm/services/image_manager/ims/proxies/rds_proxy.py +++ b/orm/services/image_manager/ims/proxies/rds_proxy.py @@ -1,10 +1,11 @@ import json import pprint -from pecan import conf -from pecan import request + from ims.logger import get_logger -from orm_common.injector import injector from ims.logic.error_base import ErrorStatus +from orm_common.injector import injector +from pecan import conf, request + di = injector.get_di() LOG = get_logger(__name__) diff --git a/orm/services/image_manager/ims/tests/controllers/v1/orm/images/test_customers.py b/orm/services/image_manager/ims/tests/controllers/v1/orm/images/test_customers.py index 6c9999a0..6ecba533 100755 --- a/orm/services/image_manager/ims/tests/controllers/v1/orm/images/test_customers.py +++ b/orm/services/image_manager/ims/tests/controllers/v1/orm/images/test_customers.py @@ -1,14 +1,13 @@ import json -from ims.tests import FunctionalTest -from orm_common.injector import injector + from ims.controllers.v1.orm.images import customers -from ims.persistency.wsme.models import ImageWrapper - -import mock from ims.logic.error_base import ErrorStatus +from ims.persistency.wsme.models import ImageWrapper +from ims.tests import FunctionalTest +import mock +from orm_common.injector import injector from wsme.exc import ClientSideError - utils_mock = None image_logic_mock = None diff --git a/orm/services/image_manager/ims/tests/controllers/v1/orm/images/test_enabled.py b/orm/services/image_manager/ims/tests/controllers/v1/orm/images/test_enabled.py index bf1d897a..688baef7 100755 --- a/orm/services/image_manager/ims/tests/controllers/v1/orm/images/test_enabled.py +++ b/orm/services/image_manager/ims/tests/controllers/v1/orm/images/test_enabled.py @@ -1,13 +1,12 @@ -import mock import json + from ims.controllers.v1.orm.images import enabled -from ims.persistency.wsme.models import ImageWrapper - from ims.logic.error_base import ErrorStatus - +from ims.persistency.wsme.models import ImageWrapper from ims.tests import FunctionalTest -from wsme.exc import ClientSideError +import mock from orm_common.injector import injector +from wsme.exc import ClientSideError return_error = 0 diff --git a/orm/services/image_manager/ims/tests/controllers/v1/orm/images/test_images.py b/orm/services/image_manager/ims/tests/controllers/v1/orm/images/test_images.py index 126f3c7d..d5261730 100755 --- a/orm/services/image_manager/ims/tests/controllers/v1/orm/images/test_images.py +++ b/orm/services/image_manager/ims/tests/controllers/v1/orm/images/test_images.py @@ -1,13 +1,13 @@ """Images unittests module.""" -from ims.controllers.v1.orm.images import images -from ims.persistency.wsme.models import ImageWrapper, ImageSummaryResponse -from ims.tests import FunctionalTest -from ims.logic.error_base import ErrorStatus -import mock import json -from wsme.exc import ClientSideError -from orm_common.injector import injector +from ims.controllers.v1.orm.images import images +from ims.logic.error_base import ErrorStatus +from ims.persistency.wsme.models import ImageSummaryResponse, ImageWrapper +from ims.tests import FunctionalTest +import mock +from orm_common.injector import injector +from wsme.exc import ClientSideError utils_mock = None image_logic_mock = None diff --git a/orm/services/image_manager/ims/tests/controllers/v1/orm/images/test_metadata.py b/orm/services/image_manager/ims/tests/controllers/v1/orm/images/test_metadata.py index 4ed85c7c..708811ae 100755 --- a/orm/services/image_manager/ims/tests/controllers/v1/orm/images/test_metadata.py +++ b/orm/services/image_manager/ims/tests/controllers/v1/orm/images/test_metadata.py @@ -1,10 +1,9 @@ -import mock import json -from wsme.exc import ClientSideError -from ims.tests import FunctionalTest from ims.controllers.v1.orm.images import metadata - +from ims.tests import FunctionalTest +import mock +from wsme.exc import ClientSideError metadata_input = { "metadata": { diff --git a/orm/services/image_manager/ims/tests/controllers/v1/orm/images/test_regions.py b/orm/services/image_manager/ims/tests/controllers/v1/orm/images/test_regions.py index 3d204ba1..5aaf2a24 100755 --- a/orm/services/image_manager/ims/tests/controllers/v1/orm/images/test_regions.py +++ b/orm/services/image_manager/ims/tests/controllers/v1/orm/images/test_regions.py @@ -1,14 +1,13 @@ import json -from ims.tests import FunctionalTest -from orm_common.injector import injector + from ims.controllers.v1.orm.images import regions -from ims.persistency.wsme.models import RegionWrapper - -import mock from ims.logic.error_base import ErrorStatus +from ims.persistency.wsme.models import RegionWrapper +from ims.tests import FunctionalTest +import mock +from orm_common.injector import injector from wsme.exc import ClientSideError - utils_mock = None image_logic_mock = None diff --git a/orm/services/image_manager/ims/tests/logic/test_image_logic.py b/orm/services/image_manager/ims/tests/logic/test_image_logic.py index f95d90bd..6686e32c 100755 --- a/orm/services/image_manager/ims/tests/logic/test_image_logic.py +++ b/orm/services/image_manager/ims/tests/logic/test_image_logic.py @@ -1,8 +1,8 @@ -import mock from ims.logic import image_logic -from ims.tests import FunctionalTest from ims.persistency.sql_alchemy.db_models import Image from ims.persistency.wsme import models +from ims.tests import FunctionalTest +import mock class RDSGetStatus(): diff --git a/orm/services/image_manager/ims/tests/logic/test_meta_data.py b/orm/services/image_manager/ims/tests/logic/test_meta_data.py index 374df488..664fbfa5 100755 --- a/orm/services/image_manager/ims/tests/logic/test_meta_data.py +++ b/orm/services/image_manager/ims/tests/logic/test_meta_data.py @@ -1,8 +1,7 @@ from ims.logic import metadata_logic -from ims.tests import FunctionalTest from ims.persistency.sql_alchemy.db_models import ImageRegion -from ims.persistency.wsme.models import MetadataWrapper, Metadata -from ims.persistency.wsme import models +from ims.persistency.wsme.models import Metadata, MetadataWrapper +from ims.tests import FunctionalTest import mock diff --git a/orm/services/image_manager/ims/tests/persistency/sql_alchemy/images/test_image_record.py b/orm/services/image_manager/ims/tests/persistency/sql_alchemy/images/test_image_record.py index 58661cc3..3da27dce 100755 --- a/orm/services/image_manager/ims/tests/persistency/sql_alchemy/images/test_image_record.py +++ b/orm/services/image_manager/ims/tests/persistency/sql_alchemy/images/test_image_record.py @@ -1,7 +1,6 @@ from ims.persistency.sql_alchemy import data_manager -from ims.tests import FunctionalTest from ims.persistency.sql_alchemy.db_models import Image - +from ims.tests import FunctionalTest import mock diff --git a/orm/services/image_manager/ims/tests/proxies/rds_proxy.py b/orm/services/image_manager/ims/tests/proxies/rds_proxy.py index 20f87c7f..6c92f184 100755 --- a/orm/services/image_manager/ims/tests/proxies/rds_proxy.py +++ b/orm/services/image_manager/ims/tests/proxies/rds_proxy.py @@ -1,6 +1,6 @@ -import mock from ims.proxies import rds_proxy from ims.tests import FunctionalTest +import mock class Response: diff --git a/orm/services/image_manager/ims/tests/test_models.py b/orm/services/image_manager/ims/tests/test_models.py index 9df3f2db..cb0d824a 100644 --- a/orm/services/image_manager/ims/tests/test_models.py +++ b/orm/services/image_manager/ims/tests/test_models.py @@ -1,7 +1,6 @@ -import mock -from ims.tests import FunctionalTest - from ims.persistency.wsme import models +from ims.tests import FunctionalTest +import mock GROUP_REGIONS = [ "DPK", @@ -31,8 +30,7 @@ class TestModels(FunctionalTest): def get_image_model(): - """ - this function create a customer model object for testing + """this function create a customer model object for testing :return: new customer object """ diff --git a/orm/services/image_manager/ims/utils/authentication.py b/orm/services/image_manager/ims/utils/authentication.py index 3104b391..3bf4a836 100755 --- a/orm/services/image_manager/ims/utils/authentication.py +++ b/orm/services/image_manager/ims/utils/authentication.py @@ -1,8 +1,9 @@ import logging + from keystone_utils import tokens +from orm_common.policy import policy from orm_common.utils import api_error_utils as err_utils from pecan import conf -from orm_common.policy import policy logger = logging.getLogger(__name__) diff --git a/orm/services/image_manager/ims/utils/utils.py b/orm/services/image_manager/ims/utils/utils.py index 760cf5c0..02d8cacc 100755 --- a/orm/services/image_manager/ims/utils/utils.py +++ b/orm/services/image_manager/ims/utils/utils.py @@ -1,6 +1,7 @@ -from pecan import conf, request import time +from pecan import request + def convert_time_human(time_stamp): return time.ctime(int(time_stamp)) diff --git a/orm/services/image_manager/pycharm_init.py b/orm/services/image_manager/pycharm_init.py index 469a65d9..5b11a0d4 100644 --- a/orm/services/image_manager/pycharm_init.py +++ b/orm/services/image_manager/pycharm_init.py @@ -1,3 +1,4 @@ from pecan.commands import CommandRunner + runner = CommandRunner() runner.run(['serve', 'config.py']) diff --git a/orm/services/region_manager/csv2db.py b/orm/services/region_manager/csv2db.py index 5961dafc..faa51550 100755 --- a/orm/services/region_manager/csv2db.py +++ b/orm/services/region_manager/csv2db.py @@ -1,10 +1,9 @@ -import logging import csv +import logging -from rms.storage.base_data_manager import SQLDBError - -from rms.storage.my_sql.data_manager import DataManager import config +from rms.storage.base_data_manager import SQLDBError +from rms.storage.my_sql.data_manager import DataManager logger = logging.getLogger(__name__) diff --git a/orm/services/region_manager/revert_csv2db.py b/orm/services/region_manager/revert_csv2db.py index 7f25849a..bcd55310 100644 --- a/orm/services/region_manager/revert_csv2db.py +++ b/orm/services/region_manager/revert_csv2db.py @@ -1,10 +1,9 @@ -import logging import csv +import logging -from rms.storage.base_data_manager import SQLDBError - -from rms.storage.my_sql.data_manager import DataManager import config +from rms.storage.base_data_manager import SQLDBError +from rms.storage.my_sql.data_manager import DataManager logger = logging.getLogger(__name__) diff --git a/orm/services/region_manager/rms/app.py b/orm/services/region_manager/rms/app.py index a03c6ae9..baf80537 100755 --- a/orm/services/region_manager/rms/app.py +++ b/orm/services/region_manager/rms/app.py @@ -1,16 +1,13 @@ import logging import os -from pecan import make_app -from pecan.commands import CommandRunner - -from orm_common.utils import utils from orm_common.policy import policy - +from orm_common.utils import utils +from pecan.commands import CommandRunner +from pecan import make_app from rms import model from rms.utils import authentication - logger = logging.getLogger(__name__) @@ -37,4 +34,4 @@ def main(): drive, path_and_file = os.path.splitdrive(dir_name) path, filename = os.path.split(path_and_file) runner = CommandRunner() - runner.run(['serve', path+'/config.py']) + runner.run(['serve', path + '/config.py']) diff --git a/orm/services/region_manager/rms/controllers/configuration.py b/orm/services/region_manager/rms/controllers/configuration.py index 4c6126e1..17abea59 100755 --- a/orm/services/region_manager/rms/controllers/configuration.py +++ b/orm/services/region_manager/rms/controllers/configuration.py @@ -3,13 +3,9 @@ import logging from orm_common.utils import utils - -from pecan import conf -from pecan import request -from pecan import rest -from wsmeext.pecan import wsexpose - +from pecan import conf, request, rest from rms.utils import authentication +from wsmeext.pecan import wsexpose logger = logging.getLogger(__name__) diff --git a/orm/services/region_manager/rms/controllers/lcp_controller.py b/orm/services/region_manager/rms/controllers/lcp_controller.py index dacb8a57..281633e4 100755 --- a/orm/services/region_manager/rms/controllers/lcp_controller.py +++ b/orm/services/region_manager/rms/controllers/lcp_controller.py @@ -1,16 +1,13 @@ import logging -from pecan import rest, request -from pecan import conf - -from wsme import types as wtypes -from wsmeext.pecan import wsexpose +from orm_common.utils import api_error_utils as err_utils +from pecan import request, rest from rms.model import url_parm from rms.services.error_base import ErrorStatus from rms.services import services from rms.utils import authentication - -from orm_common.utils import api_error_utils as err_utils +from wsme import types as wtypes +from wsmeext.pecan import wsexpose logger = logging.getLogger(__name__) @@ -19,8 +16,7 @@ class LcpController(rest.RestController): @wsexpose(wtypes.text, rest_content_types='json') def get_all(self): - """ - This function is called when receiving /lcp without a parameter. + """This function is called when receiving /lcp without a parameter. parameter: None. return: entire list of lcp. @@ -71,8 +67,8 @@ class LcpController(rest.RestController): def get_zones(): - """ - This function returns the lcp list from CSV file. + """This function returns the lcp list from CSV file. + parameter: None. return: diff --git a/orm/services/region_manager/rms/controllers/logs.py b/orm/services/region_manager/rms/controllers/logs.py index 7cd4dafe..2478687f 100755 --- a/orm/services/region_manager/rms/controllers/logs.py +++ b/orm/services/region_manager/rms/controllers/logs.py @@ -1,11 +1,10 @@ import logging -from pecan import rest, request import wsme -from wsmeext.pecan import wsexpose from orm_common.utils import api_error_utils as err_utils - +from pecan import request, rest from rms.utils import authentication +from wsmeext.pecan import wsexpose logger = logging.getLogger(__name__) diff --git a/orm/services/region_manager/rms/controllers/root.py b/orm/services/region_manager/rms/controllers/root.py index 863ac35e..73a33335 100755 --- a/orm/services/region_manager/rms/controllers/root.py +++ b/orm/services/region_manager/rms/controllers/root.py @@ -1,7 +1,7 @@ -from pecan import expose +from configuration import ConfigurationController from lcp_controller import LcpController from logs import LogsController -from configuration import ConfigurationController +from pecan import expose from rms.controllers.v2 import root @@ -13,8 +13,8 @@ class RootController(object): @expose(template='json') def _default(self): - """ - Method to handle GET / + """Method to handle GET + parameters: None return: dict describing lcp rest version information """ diff --git a/orm/services/region_manager/rms/controllers/v2/orm/resources/groups.py b/orm/services/region_manager/rms/controllers/v2/orm/resources/groups.py index 913b9bdc..9ce58cfa 100755 --- a/orm/services/region_manager/rms/controllers/v2/orm/resources/groups.py +++ b/orm/services/region_manager/rms/controllers/v2/orm/resources/groups.py @@ -5,15 +5,13 @@ import wsme from orm_common.utils import api_error_utils as err_utils from orm_common.utils import utils - +from pecan import request, rest +from rms.model import model as PythonModel from rms.services import error_base from rms.services import services as GroupService from rms.utils import authentication -from pecan import rest, request from wsme import types as wtypes from wsmeext.pecan import wsexpose -from rms.model import model as PythonModel - logger = logging.getLogger(__name__) @@ -52,7 +50,7 @@ class GroupWrapper(wtypes.DynamicBase): groups = wsme.wsattr([Groups], mandatory=True) def __init__(self, groups=[]): - """ + """init function :param group: """ diff --git a/orm/services/region_manager/rms/controllers/v2/orm/resources/metadata.py b/orm/services/region_manager/rms/controllers/v2/orm/resources/metadata.py index 604ffcfc..a10454ba 100755 --- a/orm/services/region_manager/rms/controllers/v2/orm/resources/metadata.py +++ b/orm/services/region_manager/rms/controllers/v2/orm/resources/metadata.py @@ -1,19 +1,15 @@ import json - import logging - -from pecan import rest, request import wsme -from wsme import types as wtypes -from wsmeext.pecan import wsexpose - -from rms.services import error_base -from rms.services import services as RegionService - -from rms.utils import authentication from orm_common.utils import api_error_utils as err_utils from orm_common.utils import utils +from pecan import request, rest +from rms.services import error_base +from rms.services import services as RegionService +from rms.utils import authentication +from wsme import types as wtypes +from wsmeext.pecan import wsexpose logger = logging.getLogger(__name__) diff --git a/orm/services/region_manager/rms/controllers/v2/orm/resources/regions.py b/orm/services/region_manager/rms/controllers/v2/orm/resources/regions.py index a3597cfe..f0fe5f42 100755 --- a/orm/services/region_manager/rms/controllers/v2/orm/resources/regions.py +++ b/orm/services/region_manager/rms/controllers/v2/orm/resources/regions.py @@ -1,24 +1,19 @@ """rest module.""" import logging - -from pecan import rest, request import wsme -from wsme import types as wtypes -from wsmeext.pecan import wsexpose -from rms.model import url_parm -from rms.model import model as PythonModel -from rms.services import error_base -from rms.services import services as RegionService - -from rms.controllers.v2.orm.resources.metadata import RegionMetadataController -from rms.controllers.v2.orm.resources.status import RegionStatusController - -from rms.utils import authentication - -from orm_common.policy import policy from orm_common.utils import api_error_utils as err_utils from orm_common.utils import utils +from pecan import request, rest +from rms.controllers.v2.orm.resources.metadata import RegionMetadataController +from rms.controllers.v2.orm.resources.status import RegionStatusController +from rms.model import model as PythonModel +from rms.model import url_parm +from rms.services import error_base +from rms.services import services as RegionService +from rms.utils import authentication +from wsme import types as wtypes +from wsmeext.pecan import wsexpose logger = logging.getLogger(__name__) @@ -34,7 +29,7 @@ class Address(wtypes.DynamicBase): def __init__(self, country=None, state=None, city=None, street=None, zip=None): - """ + """Init function :param country: :param state: @@ -101,7 +96,7 @@ class RegionsData(wtypes.DynamicBase): location_type=None, vlcp_name=None, open_stack_version=None, address=Address(), ranger_agent_version=None, metadata={}, endpoint=[EndPoint()]): - """ + """init function :param status: :param id: diff --git a/orm/services/region_manager/rms/controllers/v2/orm/resources/status.py b/orm/services/region_manager/rms/controllers/v2/orm/resources/status.py index 85a877c4..8e8cdfbf 100755 --- a/orm/services/region_manager/rms/controllers/v2/orm/resources/status.py +++ b/orm/services/region_manager/rms/controllers/v2/orm/resources/status.py @@ -1,19 +1,16 @@ import logging import pecan -from pecan import rest, request, conf - import wsme -from wsme import types as wtypes -from wsmeext.pecan import wsexpose from orm_common.utils import api_error_utils as err_utils from orm_common.utils import utils - +from pecan import conf, request, rest from rms.services import error_base from rms.services import services as RegionService from rms.utils import authentication - +from wsme import types as wtypes +from wsmeext.pecan import wsexpose logger = logging.getLogger(__name__) @@ -25,8 +22,7 @@ class RegionStatus(wtypes.DynamicBase): links = wsme.wsattr({str: str}, mandatory=False) def __init__(self, status=None, links=None): - """ - RegionStatus wrapper + """RegionStatus wrapper :param status: """ self.status = status @@ -38,8 +34,7 @@ class RegionStatusController(rest.RestController): @wsexpose(RegionStatus, str, body=RegionStatus, status_code=201, rest_content_types='json') def put(self, region_id, new_status): - """ - Handle put request to modify region status + """Handle put request to modify region status :param region_id: :param new_status: :return: 200 for updated, 404 for region not found diff --git a/orm/services/region_manager/rms/controllers/v2/orm/root.py b/orm/services/region_manager/rms/controllers/v2/orm/root.py index 655ca4c3..7bc93ee2 100755 --- a/orm/services/region_manager/rms/controllers/v2/orm/root.py +++ b/orm/services/region_manager/rms/controllers/v2/orm/root.py @@ -1,6 +1,5 @@ """ORM controller module.""" -from rms.controllers.v2.orm.resources import groups -from rms.controllers.v2.orm.resources import regions +from rms.controllers.v2.orm.resources import groups, regions class OrmController(object): diff --git a/orm/services/region_manager/rms/model/__init__.py b/orm/services/region_manager/rms/model/__init__.py index d983f7bc..2eef4a20 100644 --- a/orm/services/region_manager/rms/model/__init__.py +++ b/orm/services/region_manager/rms/model/__init__.py @@ -2,8 +2,7 @@ from pecan import conf # noqa def init_model(): - """ - This is a stub method which is called at application startup time. + """This is a stub method which is called at application startup time. If you need to bind to a parsed database configuration, set up tables or ORM classes, or perform any database initialization, this is the diff --git a/orm/services/region_manager/rms/model/model.py b/orm/services/region_manager/rms/model/model.py index ae40bbd0..4ea5c3f3 100755 --- a/orm/services/region_manager/rms/model/model.py +++ b/orm/services/region_manager/rms/model/model.py @@ -1,6 +1,6 @@ """model module.""" -from rms.services import error_base from pecan import conf +from rms.services import error_base class Address(object): @@ -8,7 +8,7 @@ class Address(object): def __init__(self, country=None, state=None, city=None, street=None, zip=None): - """ + """init :param country: :param state: @@ -44,7 +44,7 @@ class RegionData(object): ranger_agent_version=None, design_type=None, location_type=None, vlcp_name=None, open_stack_version=None, address=Address(), metadata={}, endpoints=[EndPoint()]): - """ + """init :param status: :param id: @@ -84,7 +84,7 @@ class RegionData(object): "type {}".format(endpoint.type)) try: endpoints_types_must_have.remove(endpoint.type) - except: + except Exception: pass if len(endpoints_types_must_have) > 0: raise error_base.InputValueError( @@ -173,7 +173,7 @@ class GroupsWrraper(object): """list of groups.""" def __init__(self, groups=None): - """ + """init :param groups: """ diff --git a/orm/services/region_manager/rms/services/services.py b/orm/services/region_manager/rms/services/services.py index c5d07827..9b959ff6 100755 --- a/orm/services/region_manager/rms/services/services.py +++ b/orm/services/region_manager/rms/services/services.py @@ -1,10 +1,9 @@ """DB actions wrapper module.""" import logging -from rms.model.model import Groups -from rms.model.model import Regions + +from rms.model.model import Groups, Regions from rms.services import error_base -from rms.storage import base_data_manager -from rms.storage import data_manager_factory +from rms.storage import base_data_manager, data_manager_factory LOG = logging.getLogger(__name__) @@ -25,7 +24,7 @@ def get_regions_data(url_parms): def get_region_by_id_or_name(region_id_or_name): - """ + """get region by id :param region_id_or_name: :return: region object (wsme format) @@ -46,7 +45,7 @@ def get_region_by_id_or_name(region_id_or_name): def update_region(region_id, region): - """ + """update region :param region: :return: """ @@ -72,7 +71,7 @@ def update_region(region_id, region): def delete_region(region_id): - """ + """delete region :param region_id: :return: @@ -181,7 +180,7 @@ def get_groups_data(name): def get_all_groups(): - """ + """list all groups :return: """ @@ -200,7 +199,7 @@ def get_all_groups(): def delete_group(group_id): - """ + """delete group :param group_id: :return: diff --git a/orm/services/region_manager/rms/storage/data_manager_factory.py b/orm/services/region_manager/rms/storage/data_manager_factory.py index 4e6e0477..90dfadbc 100644 --- a/orm/services/region_manager/rms/storage/data_manager_factory.py +++ b/orm/services/region_manager/rms/storage/data_manager_factory.py @@ -1,7 +1,6 @@ import logging from pecan import conf - from rms.storage.my_sql.data_manager import DataManager LOG = logging.getLogger(__name__) diff --git a/orm/services/region_manager/rms/storage/my_sql/data_manager.py b/orm/services/region_manager/rms/storage/my_sql/data_manager.py index b5628a8b..d54b258a 100755 --- a/orm/services/region_manager/rms/storage/my_sql/data_manager.py +++ b/orm/services/region_manager/rms/storage/my_sql/data_manager.py @@ -1,17 +1,16 @@ import logging import oslo_db +from data_models import (Group, GroupRegion, Region, RegionEndPoint, + RegionMetaData) from oslo_db.sqlalchemy import session as db_session +from rms.model import model as PythonModels +from rms.services import error_base as ServiceBase +from rms.storage.base_data_manager import (BaseDataManager, + DuplicateEntryError, EntityNotFound) from sqlalchemy.ext.declarative.api import declarative_base from sqlalchemy.sql import or_ -from rms.services import error_base as ServiceBase -from data_models import Region, RegionEndPoint, Group -from data_models import RegionMetaData, GroupRegion -from rms.services import error_base -from rms.storage.base_data_manager import BaseDataManager, DuplicateEntryError, EntityNotFound -from rms.model import model as PythonModels - Base = declarative_base() logger = logging.getLogger(__name__) @@ -258,7 +257,7 @@ class DataManager(BaseDataManager): def add_meta_data_to_region(self, region_id, metadata_dict): - """ + """add metadata :param region_id: :param metadata_dict: :return: @@ -290,8 +289,7 @@ class DataManager(BaseDataManager): def update_region_meta_data(self, region_id, metadata_dict): - """ - Replace existing metadata for given region_id + """Replace existing metadata for given region_id :param region_id: :param metadata_dict: :return: diff --git a/orm/services/region_manager/rms/storage/my_sql/data_models.py b/orm/services/region_manager/rms/storage/my_sql/data_models.py index b5b17561..ca7eb4cb 100755 --- a/orm/services/region_manager/rms/storage/my_sql/data_models.py +++ b/orm/services/region_manager/rms/storage/my_sql/data_models.py @@ -1,9 +1,8 @@ # coding: utf-8 -from sqlalchemy import Column, ForeignKey, Index, Integer, String, Table -from sqlalchemy.orm import relationship +from rms.model.model import Address, EndPoint, RegionData +from sqlalchemy import Column, ForeignKey, Integer, String from sqlalchemy.ext.declarative import declarative_base - -from rms.model.model import EndPoint, RegionData, Regions, Address +from sqlalchemy.orm import relationship Base = declarative_base() metadata = Base.metadata diff --git a/orm/services/region_manager/rms/tests/__init__.py b/orm/services/region_manager/rms/tests/__init__.py index 78ea5274..8fcee68f 100644 --- a/orm/services/region_manager/rms/tests/__init__.py +++ b/orm/services/region_manager/rms/tests/__init__.py @@ -1,14 +1,13 @@ import os -from unittest import TestCase from pecan import set_config from pecan.testing import load_test_app +from unittest import TestCase __all__ = ['FunctionalTest'] class FunctionalTest(TestCase): - """ - Used for functional tests where you need to test your + """Used for functional tests where you need to test your literal application and its integration with the framework. """ diff --git a/orm/services/region_manager/rms/tests/controllers/v1/orm/resources/test_groups.py b/orm/services/region_manager/rms/tests/controllers/v1/orm/resources/test_groups.py index 7354a6e2..75724552 100755 --- a/orm/services/region_manager/rms/tests/controllers/v1/orm/resources/test_groups.py +++ b/orm/services/region_manager/rms/tests/controllers/v1/orm/resources/test_groups.py @@ -1,12 +1,9 @@ """get_groups unittests module.""" import json -from mock import patch, MagicMock +from mock import MagicMock, patch from rms.controllers.v2.orm.resources import groups -from rms.services import error_base - from rms.tests import FunctionalTest - from wsme.exc import ClientSideError res = {"regions": ["aaaa", "bbbb", "ccccc"], diff --git a/orm/services/region_manager/rms/tests/controllers/v1/orm/resources/test_metadata.py b/orm/services/region_manager/rms/tests/controllers/v1/orm/resources/test_metadata.py index ffb0c0b8..38961e52 100755 --- a/orm/services/region_manager/rms/tests/controllers/v1/orm/resources/test_metadata.py +++ b/orm/services/region_manager/rms/tests/controllers/v1/orm/resources/test_metadata.py @@ -1,11 +1,9 @@ import json -from mock import patch, MagicMock - +from mock import MagicMock, patch from rms.controllers.v2.orm.resources import metadata from rms.model.model import * from rms.tests import FunctionalTest - from wsme.exc import ClientSideError result_inst = RegionData("1", "2", "3", "4", "5", "6", diff --git a/orm/services/region_manager/rms/tests/controllers/v1/orm/resources/test_region.py b/orm/services/region_manager/rms/tests/controllers/v1/orm/resources/test_region.py index 5ede6fc9..9081c0f6 100755 --- a/orm/services/region_manager/rms/tests/controllers/v1/orm/resources/test_region.py +++ b/orm/services/region_manager/rms/tests/controllers/v1/orm/resources/test_region.py @@ -1,13 +1,11 @@ import json -from mock import patch, MagicMock +from mock import MagicMock, patch from rms.controllers.v2.orm.resources import regions from rms.model import model as PyModels from rms.tests import FunctionalTest - from wsme.exc import ClientSideError - result_inst = PyModels.Regions([PyModels.RegionData("2", "3", "4", "5", "6", address=PyModels.Address("US", "NY", "HANEGEV", "AIRPORT_CITY", "5"), endpoints=[ diff --git a/orm/services/region_manager/rms/tests/controllers/v1/orm/resources/test_status.py b/orm/services/region_manager/rms/tests/controllers/v1/orm/resources/test_status.py index fb818711..c9c3ec3e 100755 --- a/orm/services/region_manager/rms/tests/controllers/v1/orm/resources/test_status.py +++ b/orm/services/region_manager/rms/tests/controllers/v1/orm/resources/test_status.py @@ -1,9 +1,8 @@ import json -from mock import patch +from mock import patch from rms.controllers.v2.orm.resources import status from rms.tests import FunctionalTest - from wsme.exc import ClientSideError diff --git a/orm/services/region_manager/rms/tests/services/test_services.py b/orm/services/region_manager/rms/tests/services/test_services.py index c422dfbb..f62f8c4b 100755 --- a/orm/services/region_manager/rms/tests/services/test_services.py +++ b/orm/services/region_manager/rms/tests/services/test_services.py @@ -1,14 +1,13 @@ """Services module unittests.""" import mock from mock import patch -from rms.services import services -# from rms.model import url_parm as parms - -from rms.tests import FunctionalTest -from rms.tests.controllers.v1.orm.resources.test_region import full_region -from rms.controllers.v2.orm.resources import regions from pecan import conf -from rms.model import model as PyModels +from rms.controllers.v2.orm.resources import regions +from rms.services import services +from rms.tests.controllers.v1.orm.resources.test_region import full_region +from rms.tests import FunctionalTest + +# from rms.model import url_parm as parms class db(object): diff --git a/orm/services/region_manager/rms/tests/storage/my_sql/test_data_manager.py b/orm/services/region_manager/rms/tests/storage/my_sql/test_data_manager.py index 7f3603d9..65c98548 100755 --- a/orm/services/region_manager/rms/tests/storage/my_sql/test_data_manager.py +++ b/orm/services/region_manager/rms/tests/storage/my_sql/test_data_manager.py @@ -1,10 +1,9 @@ import unittest import mock - from rms.services import error_base -from rms.storage.my_sql import data_manager, data_models from rms.storage.base_data_manager import DuplicateEntryError +from rms.storage.my_sql import data_manager, data_models end_point_list = [{"type": "ord", "url": "http://ord.com"}] diff --git a/orm/services/region_manager/rms/tests/storage/test_data_manager_factory.py b/orm/services/region_manager/rms/tests/storage/test_data_manager_factory.py index 657ed8eb..6490ae62 100644 --- a/orm/services/region_manager/rms/tests/storage/test_data_manager_factory.py +++ b/orm/services/region_manager/rms/tests/storage/test_data_manager_factory.py @@ -1,9 +1,9 @@ -from mock import patch import unittest +from mock import patch from rms.storage import data_manager_factory -from rms.storage.my_sql.data_manager import DataManager from rms.storage.my_sql import data_manager +from rms.storage.my_sql.data_manager import DataManager class StorageFactoryTests(unittest.TestCase): diff --git a/orm/services/region_manager/rms/tests/test_logs.py b/orm/services/region_manager/rms/tests/test_logs.py index 24f122e4..7b1f628c 100755 --- a/orm/services/region_manager/rms/tests/test_logs.py +++ b/orm/services/region_manager/rms/tests/test_logs.py @@ -1,12 +1,11 @@ import json import logging -from mock import patch, MagicMock -from wsme.exc import ClientSideError - import rms.controllers.logs as logs +from mock import MagicMock, patch from rms.controllers.logs import LogsController as logs_controller from rms.tests import FunctionalTest +from wsme.exc import ClientSideError class TestGetConfiguration(FunctionalTest): diff --git a/orm/services/region_manager/rms/tests/tests_lcp_controller.py b/orm/services/region_manager/rms/tests/tests_lcp_controller.py index fff36de2..06af9b80 100755 --- a/orm/services/region_manager/rms/tests/tests_lcp_controller.py +++ b/orm/services/region_manager/rms/tests/tests_lcp_controller.py @@ -1,18 +1,12 @@ -from mock import patch, MagicMock -from wsme.exc import ClientSideError - -from rms.services import services -from rms.controllers import lcp_controller - -from rms.model.model import RegionData, Regions, EndPoint -from rms.services.error_base import NotFoundError - import json +from mock import MagicMock, patch from rms.controllers import lcp_controller as lcps - +from rms.model.model import EndPoint, RegionData, Regions +from rms.services.error_base import NotFoundError +from rms.services import services from rms.tests import FunctionalTest - +from wsme.exc import ClientSideError TEST_REGIONS_DATA = [ { diff --git a/orm/services/region_manager/rms/tests/utils/test_authentication.py b/orm/services/region_manager/rms/tests/utils/test_authentication.py index b05fbf74..766eaec7 100755 --- a/orm/services/region_manager/rms/tests/utils/test_authentication.py +++ b/orm/services/region_manager/rms/tests/utils/test_authentication.py @@ -1,7 +1,7 @@ """Authentication utilities module unittests.""" import mock -from rms.utils import authentication from rms.tests import FunctionalTest +from rms.utils import authentication class TestGetConfiguration(FunctionalTest): diff --git a/orm/services/region_manager/rms/utils/authentication.py b/orm/services/region_manager/rms/utils/authentication.py index ae93d2ac..c48999d4 100755 --- a/orm/services/region_manager/rms/utils/authentication.py +++ b/orm/services/region_manager/rms/utils/authentication.py @@ -2,13 +2,9 @@ import logging from keystone_utils import tokens from orm_common.policy import policy -from orm_common.utils import api_error_utils as err_utils - from pecan import conf - from rms.services import services as RegionService - logger = logging.getLogger(__name__) diff --git a/orm/services/region_manager/rms_mock/rms_mock/app.py b/orm/services/region_manager/rms_mock/rms_mock/app.py index f53f79bb..ded90984 100644 --- a/orm/services/region_manager/rms_mock/rms_mock/app.py +++ b/orm/services/region_manager/rms_mock/rms_mock/app.py @@ -1,9 +1,7 @@ -from pecan import make_app -from rms_mock import model -from pecan import make_app, conf from pecan.commands import CommandRunner - +from pecan import make_app from rms import model +from rms_mock import model def setup_app(config): diff --git a/orm/services/region_manager/rms_mock/rms_mock/controllers/lcp_controller.py b/orm/services/region_manager/rms_mock/rms_mock/controllers/lcp_controller.py index 96e4cdb9..a2ef0834 100644 --- a/orm/services/region_manager/rms_mock/rms_mock/controllers/lcp_controller.py +++ b/orm/services/region_manager/rms_mock/rms_mock/controllers/lcp_controller.py @@ -1,22 +1,17 @@ -import pecan import logging +import pecan from pecan import rest LOG = logging.getLogger(__name__) class LcpController(rest.RestController): - """ - this class is for getting the lcp list from AIC Formation. - """ + """this class is for getting the lcp list from AIC Formation.""" @pecan.expose() def get(self): - """ - when a get call is received in RestAPI this function return a - list of lcp - """ + """when a get is received this function returns a list of lcp""" LOG.info('int get function') file = open('data/zones.json', 'r') diff --git a/orm/services/region_manager/rms_mock/rms_mock/controllers/root.py b/orm/services/region_manager/rms_mock/rms_mock/controllers/root.py index 3366e46a..6f87c573 100644 --- a/orm/services/region_manager/rms_mock/rms_mock/controllers/root.py +++ b/orm/services/region_manager/rms_mock/rms_mock/controllers/root.py @@ -1,12 +1,10 @@ -from pecan import expose, redirect -from webob.exc import status_map from lcp_controller import LcpController +from pecan import expose +from webob.exc import status_map class RootController(object): - """ - in charge of RestAPI in the root directory - """ + """in charge of RestAPI in the root directory""" lcp = LcpController() @expose('error.html') diff --git a/orm/services/region_manager/rms_mock/rms_mock/model/__init__.py b/orm/services/region_manager/rms_mock/rms_mock/model/__init__.py index d983f7bc..2eef4a20 100644 --- a/orm/services/region_manager/rms_mock/rms_mock/model/__init__.py +++ b/orm/services/region_manager/rms_mock/rms_mock/model/__init__.py @@ -2,8 +2,7 @@ from pecan import conf # noqa def init_model(): - """ - This is a stub method which is called at application startup time. + """This is a stub method which is called at application startup time. If you need to bind to a parsed database configuration, set up tables or ORM classes, or perform any database initialization, this is the diff --git a/orm/services/resource_distributor/config.py b/orm/services/resource_distributor/config.py index 0b7abbaa..53154e1f 100755 --- a/orm/services/resource_distributor/config.py +++ b/orm/services/resource_distributor/config.py @@ -81,7 +81,7 @@ yaml_configs = { } } }, - 'flavor_yaml':{ + 'flavor_yaml': { 'yaml_version': '2013-05-23', 'yaml_args': { 'rxtx_factor': 1 @@ -159,7 +159,7 @@ logging = { }, 'color': { '()': 'pecan.log.ColorFormatter', - 'format':'%(asctime)s [%(padded_color_levelname)s] [%(name)s] [%(threadName)s] %(message)s', + 'format': '%(asctime)s [%(padded_color_levelname)s] [%(name)s] [%(threadName)s] %(message)s', '__force_dict__': True } } diff --git a/orm/services/resource_distributor/ordmockserver/config.py b/orm/services/resource_distributor/ordmockserver/config.py index 0f2429e7..c054949a 100755 --- a/orm/services/resource_distributor/ordmockserver/config.py +++ b/orm/services/resource_distributor/ordmockserver/config.py @@ -42,7 +42,7 @@ verify = False logging = { 'root': {'level': 'INFO', 'handlers': ['console']}, 'loggers': { - 'restapi': {'level': 'DEBUG', 'handlers': ['console','logfile'], 'propagate': False}, + 'restapi': {'level': 'DEBUG', 'handlers': ['console', 'logfile'], 'propagate': False}, 'pecan': {'level': 'DEBUG', 'handlers': ['console'], 'propagate': False}, 'py.warnings': {'handlers': ['console']}, '__force_dict__': True @@ -69,7 +69,7 @@ logging = { '()': 'pecan.log.ColorFormatter', 'format': ('%(asctime)s [%(padded_color_levelname)s] [%(name)s]' '[%(threadName)s] %(message)s'), - '__force_dict__': True + '__force_dict__': True } } } diff --git a/orm/services/resource_distributor/ordmockserver/ordmockserver/app.py b/orm/services/resource_distributor/ordmockserver/ordmockserver/app.py index 6e5140dd..0a9930d4 100644 --- a/orm/services/resource_distributor/ordmockserver/ordmockserver/app.py +++ b/orm/services/resource_distributor/ordmockserver/ordmockserver/app.py @@ -1,5 +1,5 @@ -from pecan import make_app from ordmockserver import model +from pecan import make_app def setup_app(config): diff --git a/orm/services/resource_distributor/ordmockserver/ordmockserver/controllers/OrdNotifier/root.py b/orm/services/resource_distributor/ordmockserver/ordmockserver/controllers/OrdNotifier/root.py index 5a2e76f9..707a9216 100755 --- a/orm/services/resource_distributor/ordmockserver/ordmockserver/controllers/OrdNotifier/root.py +++ b/orm/services/resource_distributor/ordmockserver/ordmockserver/controllers/OrdNotifier/root.py @@ -1,11 +1,12 @@ import json import logging.handlers -from pecan import conf -from pecan import request -import pecan.rest -import requests import threading import time + +import requests + +from pecan import conf +import pecan.rest import wsme from wsme import types as wtypes from wsmeext.pecan import wsexpose diff --git a/orm/services/resource_distributor/ordmockserver/ordmockserver/controllers/root.py b/orm/services/resource_distributor/ordmockserver/ordmockserver/controllers/root.py index 60e409e6..0c3da319 100755 --- a/orm/services/resource_distributor/ordmockserver/ordmockserver/controllers/root.py +++ b/orm/services/resource_distributor/ordmockserver/ordmockserver/controllers/root.py @@ -1,7 +1,7 @@ -from pecan import expose, redirect, response -from pecan import * -from webob.exc import status_map from OrdNotifier import root +from pecan import * +from pecan import expose +from webob.exc import status_map class CatalogController(object): @@ -43,5 +43,4 @@ class RootController(object): return dict(status=status, message=message) cat = CatalogController() - #customer=root.CreateNewCustomer() v1 = RootOne() diff --git a/orm/services/resource_distributor/ordmockserver/ordmockserver/model/__init__.py b/orm/services/resource_distributor/ordmockserver/ordmockserver/model/__init__.py index d983f7bc..2eef4a20 100644 --- a/orm/services/resource_distributor/ordmockserver/ordmockserver/model/__init__.py +++ b/orm/services/resource_distributor/ordmockserver/ordmockserver/model/__init__.py @@ -2,8 +2,7 @@ from pecan import conf # noqa def init_model(): - """ - This is a stub method which is called at application startup time. + """This is a stub method which is called at application startup time. If you need to bind to a parsed database configuration, set up tables or ORM classes, or perform any database initialization, this is the diff --git a/orm/services/resource_distributor/rds/app.py b/orm/services/resource_distributor/rds/app.py index 4e4c5f04..a90ebbc3 100755 --- a/orm/services/resource_distributor/rds/app.py +++ b/orm/services/resource_distributor/rds/app.py @@ -1,15 +1,12 @@ import logging import os -from pecan import make_app, conf -from pecan.commands import CommandRunner - -from services import region_resource_id_status -from storage import factory -from sot import sot_factory - from audit_client.api import audit - +from pecan import conf, make_app +from pecan.commands import CommandRunner +from services import region_resource_id_status +from sot import sot_factory +from storage import factory logger = logging.getLogger(__name__) @@ -70,7 +67,7 @@ def main(): drive, path_and_file = os.path.splitdrive(dir_name) path, filename = os.path.split(path_and_file) runner = CommandRunner() - runner.run(['serve', path+'/config.py']) + runner.run(['serve', path + '/config.py']) if __name__ == "__main__": main() diff --git a/orm/services/resource_distributor/rds/controllers/v1/configuration/root.py b/orm/services/resource_distributor/rds/controllers/v1/configuration/root.py index 5c70a0b4..4e758929 100644 --- a/orm/services/resource_distributor/rds/controllers/v1/configuration/root.py +++ b/orm/services/resource_distributor/rds/controllers/v1/configuration/root.py @@ -1,9 +1,9 @@ """Configuration rest API input module.""" import logging + from orm_common.utils import utils -from pecan import conf -from pecan import rest +from pecan import conf, rest from wsmeext.pecan import wsexpose logger = logging.getLogger(__name__) diff --git a/orm/services/resource_distributor/rds/controllers/v1/resources/root.py b/orm/services/resource_distributor/rds/controllers/v1/resources/root.py index ab202b0b..a9889788 100755 --- a/orm/services/resource_distributor/rds/controllers/v1/resources/root.py +++ b/orm/services/resource_distributor/rds/controllers/v1/resources/root.py @@ -5,17 +5,15 @@ import logging.handlers import time import pecan -import wsme from pecan import rest +from rds.controllers.v1.base import (ClientSideError, LockedEntity, + NotAllowedError) +from rds.services.base import ConflictValue +from rds.services import resource as ResourceService +import wsme from wsme import types as wtypes from wsmeext.pecan import wsexpose -from rds.controllers.v1.base import ClientSideError -from rds.controllers.v1.base import LockedEntity -from rds.controllers.v1.base import NotAllowedError -from rds.services import resource as ResourceService -from rds.services.base import ConflictValue - my_logger = logging.getLogger(__name__) resources_operation_list = { @@ -192,7 +190,7 @@ class CreateNewResource(rest.RestController): resource_type, resource_id) res = Result(**{resource_type: CreatedResource(id=resource_id, - created='%d' % (time.time()*1000), + created='%d' % (time.time() * 1000), links=Links(site_link))}) return res except ConflictValue as e: @@ -233,11 +231,11 @@ class CreateNewResource(rest.RestController): site_link = "%s/v1/rds/%s/%s" % (base_url, resource_type, resource_id) - res = Result(**{resource_type: CreatedResource(id=resource_id, - updated='%d' % ( - time.time() * 1000), - links=Links( - site_link))}) + res = Result(**{ + resource_type: CreatedResource( + id=resource_id, + updated='%d' % (time.time() * 1000), + links=Links(site_link))}) return res except ConflictValue as e: my_logger.error("the request blocked need to wait " diff --git a/orm/services/resource_distributor/rds/controllers/v1/root.py b/orm/services/resource_distributor/rds/controllers/v1/root.py index 10fe5c89..68631860 100755 --- a/orm/services/resource_distributor/rds/controllers/v1/root.py +++ b/orm/services/resource_distributor/rds/controllers/v1/root.py @@ -1,8 +1,7 @@ """v1 controller.""" -from rds.controllers.v1 import logs from rds.controllers.v1.configuration import root as config_root +from rds.controllers.v1 import logs from rds.controllers.v1.resources import root as Rds - from rds.controllers.v1.status import resource_status diff --git a/orm/services/resource_distributor/rds/controllers/v1/status/get_resource.py b/orm/services/resource_distributor/rds/controllers/v1/status/get_resource.py index 5194cb9f..e2f516ce 100755 --- a/orm/services/resource_distributor/rds/controllers/v1/status/get_resource.py +++ b/orm/services/resource_distributor/rds/controllers/v1/status/get_resource.py @@ -1,13 +1,12 @@ """handle get resource module.""" import logging -import wsme from pecan import rest -from wsme import types as wtypes -from wsmeext.pecan import wsexpose - from rds.controllers.v1.base import EntityNotFoundError from rds.services import region_resource_id_status as regionResourceIdStatus +import wsme +from wsme import types as wtypes +from wsmeext.pecan import wsexpose logger = logging.getLogger(__name__) @@ -20,7 +19,7 @@ class ResourceMetaData(wtypes.DynamicBase): size = wsme.wsattr(wtypes.text, mandatory=True) def __init__(self, size='', virtual_size='', checksum=''): - """ + """init :param size: :param virtual_size: diff --git a/orm/services/resource_distributor/rds/controllers/v1/status/resource_status.py b/orm/services/resource_distributor/rds/controllers/v1/status/resource_status.py index 34792d51..7d369a2b 100755 --- a/orm/services/resource_distributor/rds/controllers/v1/status/resource_status.py +++ b/orm/services/resource_distributor/rds/controllers/v1/status/resource_status.py @@ -2,17 +2,16 @@ import logging import time -import wsme from pecan import rest -from rds.controllers.v1.base import InputValueError, ClientSideError +from rds.controllers.v1.base import InputValueError +from rds.controllers.v1.status import get_resource +from rds.services.base import ErrorMesage, InputError +from rds.services import region_resource_id_status as regionResourceIdStatus +from rds.utils import utils +import wsme from wsme import types as wtypes from wsmeext.pecan import wsexpose -from rds.controllers.v1.status import get_resource -from rds.services import region_resource_id_status as regionResourceIdStatus -from rds.services.base import InputError, ErrorMesage -from rds.utils import utils - logger = logging.getLogger(__name__) @@ -23,7 +22,7 @@ class MetaData(wtypes.DynamicBase): size = wsme.wsattr(wtypes.text, mandatory=True) def __init__(self, checksum=None, virtual_size=None, size=None): - """ + """init :param checksum: :param virtual_size: @@ -126,7 +125,7 @@ class Status(rest.RestController): logger.info("post status") logger.debug("parse json!") data_to_save = dict( - timestamp=int(time.time())*1000, + timestamp=int(time.time()) * 1000, region=status_input.rds_listener.region, resource_id=status_input.rds_listener.resource_id, status=status_input.rds_listener.status, diff --git a/orm/services/resource_distributor/rds/ordupdate/ord_notifier.py b/orm/services/resource_distributor/rds/ordupdate/ord_notifier.py index c4a2d1fe..538cc0a7 100755 --- a/orm/services/resource_distributor/rds/ordupdate/ord_notifier.py +++ b/orm/services/resource_distributor/rds/ordupdate/ord_notifier.py @@ -1,15 +1,13 @@ """ORD trigger main module.""" import json +import logging import time -import logging import requests -from pecan import conf - from audit_client.api import audit - +from pecan import conf from rds.services import region_resource_id_status as regionResourceIdStatus # REST API constants @@ -145,9 +143,9 @@ def _notify(ord_url, # Make sure the ORD sent an ACK if response.status_code != ACK_CODE: message = 'Did not receive an ACK from ORD %s, status code: %d' % ( - ord_url, response.status_code, ) + ord_url, response.status_code, ) encoded_message = message.replace('\n', '_').replace('\r', '_') - if encoded_message != message: + if encoded_message != message: encoded_message = encoded_message + "(encoded)" logger.error(encoded_message) raise NotifyNotAcknowledgedError(message) @@ -284,5 +282,6 @@ def notify_ord(transaction_id, _update_audit(region_id, application_id, tracking_id, transaction_id, transaction_type, resource_id, user_id, external_id, event_details, status) - logger.debug("Create Resource Requested to ORD: region=%s resource_id=%s status=%s" - % (region_id, resource_id, status)) + logger.debug( + "Create Resource Requested to ORD: region=%s resource_id=%s status=%s" % ( + region_id, resource_id, status)) diff --git a/orm/services/resource_distributor/rds/proxies/ims_proxy.py b/orm/services/resource_distributor/rds/proxies/ims_proxy.py index bb6e47f9..39cca688 100755 --- a/orm/services/resource_distributor/rds/proxies/ims_proxy.py +++ b/orm/services/resource_distributor/rds/proxies/ims_proxy.py @@ -1,12 +1,11 @@ -import requests import json import logging +import requests + from pecan import conf - -from rds.utils import authentication as AuthService from rds.services.base import ErrorMesage - +from rds.utils import authentication as AuthService logger = logging.getLogger(__name__) @@ -20,7 +19,7 @@ def _set_headers(): if token_id: headers['X-Auth-Token'] = token_id headers['X-Auth-Region'] = region - except: + except Exception: logger.error("no token") diff --git a/orm/services/resource_distributor/rds/proxies/rms_proxy.py b/orm/services/resource_distributor/rds/proxies/rms_proxy.py index b2d3c544..5b9839fc 100755 --- a/orm/services/resource_distributor/rds/proxies/rms_proxy.py +++ b/orm/services/resource_distributor/rds/proxies/rms_proxy.py @@ -1,12 +1,10 @@ """python module.""" -import json import logging + import requests from pecan import conf -from rds.services.base import ErrorMesage - logger = logging.getLogger(__name__) diff --git a/orm/services/resource_distributor/rds/services/base.py b/orm/services/resource_distributor/rds/services/base.py index 199f60dc..056efd3a 100644 --- a/orm/services/resource_distributor/rds/services/base.py +++ b/orm/services/resource_distributor/rds/services/base.py @@ -15,8 +15,5 @@ class ErrorMesage(Error): class ConflictValue(Error): - """ - block values if operation still in progress - """ + """block values if operation still in progress""" pass - diff --git a/orm/services/resource_distributor/rds/services/model/resource_input.py b/orm/services/resource_distributor/rds/services/model/resource_input.py index 887a7572..51635632 100644 --- a/orm/services/resource_distributor/rds/services/model/resource_input.py +++ b/orm/services/resource_distributor/rds/services/model/resource_input.py @@ -10,4 +10,4 @@ class ResourceData(object): self.operation = operation self.transaction_id = transaction_id self.model = model - self.external_transaction_id = external_transaction_id \ No newline at end of file + self.external_transaction_id = external_transaction_id diff --git a/orm/services/resource_distributor/rds/services/region_resource_id_status.py b/orm/services/resource_distributor/rds/services/region_resource_id_status.py index fede1382..6fc9f04f 100755 --- a/orm/services/resource_distributor/rds/services/region_resource_id_status.py +++ b/orm/services/resource_distributor/rds/services/region_resource_id_status.py @@ -1,6 +1,5 @@ import logging import sys -import time from rds.services.base import Error, InputError from rds.storage import factory @@ -22,14 +21,14 @@ def add_status(data): ", transaction_id [{}] and resource_id [{}], ord_notifier_id [{}], " "error message [{}], error code [{}] and " "resource_extra_metadata [{}]".format(data['timestamp'], - data['region'], - data['status'], - data['transaction_id'], - data['resource_id'], - data['ord_notifier_id'], - data['error_msg'], - data['error_code'], - data.get('resource_extra_metadata', None))) + data['region'], + data['status'], + data['transaction_id'], + data['resource_id'], + data['ord_notifier_id'], + data['error_msg'], + data['error_code'], + data.get('resource_extra_metadata', None))) try: validate_status_value(data['status']) @@ -47,7 +46,7 @@ def add_status(data): except Error as e: logger.exception("invalid inputs error") raise - except: + except Exception: logger.exception("Unexpected error: {}".format(sys.exc_info()[0])) raise @@ -93,4 +92,4 @@ def validate_status_value(status): # logger.debug("send metadata {} to ims :- {} for region {}".format( # data['resource_extra_metadata'], data['resource_id'], data['region'])) # # ims_proxy.send_image_metadata(data['resource_extra_metadata'], data['resource_id'], data['region']) -# return \ No newline at end of file +# return diff --git a/orm/services/resource_distributor/rds/services/resource.py b/orm/services/resource_distributor/rds/services/resource.py index a7442447..195bc9ca 100755 --- a/orm/services/resource_distributor/rds/services/resource.py +++ b/orm/services/resource_distributor/rds/services/resource.py @@ -2,19 +2,14 @@ import logging import time -from pecan import conf -from pecan import request +from pecan import conf, request from rds.services import region_resource_id_status as regionResourceIdStatus -from rds.services import yaml_customer_builder -from rds.services import yaml_flavor_bulder -from rds.services import yaml_image_builder -from rds.services.base import ConflictValue -from rds.services.base import ErrorMesage +from rds.services import (yaml_customer_builder, yaml_flavor_bulder, + yaml_image_builder) +from rds.services.base import ConflictValue, ErrorMesage from rds.services.model.resource_input import ResourceData as InputData from rds.sot import sot_factory -from rds.utils import uuid_utils -from rds.utils import utils - +from rds.utils import utils, uuid_utils my_logger = logging.getLogger(__name__) @@ -43,8 +38,8 @@ def _get_inputs_from_resource_type(jsondata, def _region_valid(region): - if 'rms_status' in region and region[ - 'rms_status'] not in conf.allow_region_statuses: + if ('rms_status' in region + and region['rms_status'] not in conf.allow_region_statuses): return False return True @@ -141,8 +136,9 @@ def _check_resource_status(input_data): def update_sot(input_data): """create resource.""" - my_logger.debug("build yaml file for %s id: %s" % (input_data.resource_type, - input_data.resource_id)) + my_logger.debug( + "build yaml file for %s id: %s" % (input_data.resource_type, + input_data.resource_id)) targetslist = _create_data_to_sot(input_data) my_logger.debug("upload yaml to SoT") _upload_to_sot(input_data.resource_id, diff --git a/orm/services/resource_distributor/rds/services/yaml_customer_builder.py b/orm/services/resource_distributor/rds/services/yaml_customer_builder.py index 0756839a..33699b83 100755 --- a/orm/services/resource_distributor/rds/services/yaml_customer_builder.py +++ b/orm/services/resource_distributor/rds/services/yaml_customer_builder.py @@ -1,6 +1,7 @@ """yaml build build yaml from json input.""" import logging import re + import yaml from pecan import conf @@ -40,9 +41,9 @@ def creat_final_yaml(title, description, resources, outputs): default_flow_style=False)) resources_yaml = re.sub("'", '', resourcesyaml) yamldata = title_yaml - yamldata = yamldata + "\n"+description_yaml - yamldata = yamldata + "\n"+resources_yaml - yamldata = yamldata + "\n"+yaml.dump(outputs) + yamldata = yamldata + "\n" + description_yaml + yamldata = yamldata + "\n" + resources_yaml + yamldata = yamldata + "\n" + yaml.dump(outputs) return yamldata @@ -103,9 +104,6 @@ def yamlbuilder(alldata, region): {"role": role_format % role, 'project': "{'get_resource': '%s'}" % alldata['uuid']} ) - # create the output for roles - # outputs['outputs']["%s_id" % role] =\ - # {"value": {"get_resource": "%s" % role}} # no support for group when type is ldap if yaml_type != 'ldap': @@ -156,7 +154,6 @@ def yamlbuilder(alldata, region): if ite in quotas_keys: items[item][quotas_keys[ite]] = items[item][ite] del items[item][ite] - #------------------------------------ # adding tenant to each quota items[item]['tenant'] = \ diff --git a/orm/services/resource_distributor/rds/services/yaml_flavor_bulder.py b/orm/services/resource_distributor/rds/services/yaml_flavor_bulder.py index b1492f8f..14d1cbc5 100755 --- a/orm/services/resource_distributor/rds/services/yaml_flavor_bulder.py +++ b/orm/services/resource_distributor/rds/services/yaml_flavor_bulder.py @@ -3,6 +3,7 @@ import logging import re import yaml + from pecan import conf my_logger = logging.getLogger(__name__) diff --git a/orm/services/resource_distributor/rds/services/yaml_image_builder.py b/orm/services/resource_distributor/rds/services/yaml_image_builder.py index 953dff01..cf75106c 100755 --- a/orm/services/resource_distributor/rds/services/yaml_image_builder.py +++ b/orm/services/resource_distributor/rds/services/yaml_image_builder.py @@ -2,6 +2,7 @@ import logging import re import yaml + from pecan import conf my_logger = logging.getLogger(__name__) diff --git a/orm/services/resource_distributor/rds/sot/git_sot/git_base.py b/orm/services/resource_distributor/rds/sot/git_sot/git_base.py index 17fd8ad7..899de37a 100644 --- a/orm/services/resource_distributor/rds/sot/git_sot/git_base.py +++ b/orm/services/resource_distributor/rds/sot/git_sot/git_base.py @@ -1,6 +1,3 @@ -import subprocess - -from pecan import conf class BaseGit(object): @@ -32,4 +29,3 @@ class GitResetError(Exception): class GitValidateError(Exception): pass - diff --git a/orm/services/resource_distributor/rds/sot/git_sot/git_gittle.py b/orm/services/resource_distributor/rds/sot/git_sot/git_gittle.py index c7c0a93f..d71ed951 100755 --- a/orm/services/resource_distributor/rds/sot/git_sot/git_gittle.py +++ b/orm/services/resource_distributor/rds/sot/git_sot/git_gittle.py @@ -1,9 +1,8 @@ import logging -from pecan import conf -from gittle import Gittle - from git_base import BaseGit, GitInitError, GitUploadError +from gittle import Gittle +from pecan import conf logger = logging.getLogger(__name__) diff --git a/orm/services/resource_distributor/rds/sot/git_sot/git_native.py b/orm/services/resource_distributor/rds/sot/git_sot/git_native.py index 587b869b..4fb207c7 100644 --- a/orm/services/resource_distributor/rds/sot/git_sot/git_native.py +++ b/orm/services/resource_distributor/rds/sot/git_sot/git_native.py @@ -1,14 +1,13 @@ """Native (bash commands) Git module.""" import logging -import subprocess, shlex +import shlex +import subprocess from threading import Timer - import time -from pecan import conf -from git_base import BaseGit -from git_base import GitUploadError, GitInitError, GitResetError -from git_base import GitValidateError +from git_base import (BaseGit, GitInitError, GitResetError, GitUploadError, + GitValidateError) +from pecan import conf logger = logging.getLogger(__name__) @@ -23,8 +22,8 @@ class GitNative(BaseGit): "Git server url: {}, " "Git command timeout: " "{} seconds".format(conf.git.local_repository_path, - conf.git.git_server_url, - conf.git.git_cmd_timeout)) + conf.git.git_server_url, + conf.git.git_cmd_timeout)) out, error = self._git_pull(conf.git.local_repository_path) if self._is_conflict(out) or self._is_error(error): diff --git a/orm/services/resource_distributor/rds/sot/git_sot/git_sot.py b/orm/services/resource_distributor/rds/sot/git_sot/git_sot.py index 21f9df4a..d359ba88 100755 --- a/orm/services/resource_distributor/rds/sot/git_sot/git_sot.py +++ b/orm/services/resource_distributor/rds/sot/git_sot/git_sot.py @@ -2,14 +2,13 @@ import logging import os import threading +import git_factory +from git_base import (GitInitError, GitResetError, GitUploadError, + GitValidateError) from rds.ordupdate.ord_notifier import notify_ord from rds.sot import base_sot from rds.sot.base_sot import SoTError -import git_factory -from git_base import GitUploadError, GitInitError, GitResetError -from git_base import GitValidateError - logger = logging.getLogger(__name__) lock = threading.Lock() @@ -226,8 +225,3 @@ def cleanup(git_impl): except GitResetError as exc: logger.error(exc.message) raise SoTError(exc.message) - - - - - diff --git a/orm/services/resource_distributor/rds/storage/factory.py b/orm/services/resource_distributor/rds/storage/factory.py index f487e121..3e010821 100644 --- a/orm/services/resource_distributor/rds/storage/factory.py +++ b/orm/services/resource_distributor/rds/storage/factory.py @@ -1,4 +1,5 @@ -from rds.storage.mysql.region_resource_id_status import Connection as RegionResourceIdStatusConnection +from rds.storage.mysql.region_resource_id_status import \ + Connection as RegionResourceIdStatusConnection database = { 'url': 'na' @@ -7,4 +8,3 @@ database = { def get_region_resource_id_status_connection(): return RegionResourceIdStatusConnection(database['url']) - diff --git a/orm/services/resource_distributor/rds/storage/mysql/region_resource_id_status.py b/orm/services/resource_distributor/rds/storage/mysql/region_resource_id_status.py index 6b172fa7..eef9a49f 100755 --- a/orm/services/resource_distributor/rds/storage/mysql/region_resource_id_status.py +++ b/orm/services/resource_distributor/rds/storage/mysql/region_resource_id_status.py @@ -1,16 +1,14 @@ +import logging import time +import oslo_db from oslo_db.sqlalchemy import session as db_session -from sqlalchemy import Column, Integer, Text, BigInteger, ForeignKey -from sqlalchemy.orm import relationship -from sqlalchemy.ext.declarative.api import declarative_base - +from pecan import conf from rds.services.model.region_resource_id_status import Model, StatusModel from rds.storage import region_resource_id_status -import logging -import oslo_db - -from pecan import conf +from sqlalchemy import BigInteger, Column, ForeignKey, Integer, Text +from sqlalchemy.ext.declarative.api import declarative_base +from sqlalchemy.orm import relationship Base = declarative_base() logger = logging.getLogger(__name__) @@ -203,10 +201,8 @@ class Connection(region_resource_id_status.Base): return None def get_timstamp_pair(self): - timestamp = int(time.time())*1000 + timestamp = int(time.time()) * 1000 # assume same time period for all resource types max_interval_time_in_seconds = conf.region_resource_id_status.max_interval_time.default * 60 ref_timestamp = (int(time.time()) - max_interval_time_in_seconds) * 1000 return timestamp, ref_timestamp - - diff --git a/orm/services/resource_distributor/rds/storage/region_resource_id_status.py b/orm/services/resource_distributor/rds/storage/region_resource_id_status.py index 38361516..b2a65c53 100644 --- a/orm/services/resource_distributor/rds/storage/region_resource_id_status.py +++ b/orm/services/resource_distributor/rds/storage/region_resource_id_status.py @@ -21,4 +21,4 @@ class Base(object): raise NotImplementedError("Please Implement this method") def get_records_by_filter_args(self, **filter_args): - raise NotImplementedError("Please Implement this method") \ No newline at end of file + raise NotImplementedError("Please Implement this method") diff --git a/orm/services/resource_distributor/rds/tests/config.py b/orm/services/resource_distributor/rds/tests/config.py index b54b6ba1..b5e5bd10 100755 --- a/orm/services/resource_distributor/rds/tests/config.py +++ b/orm/services/resource_distributor/rds/tests/config.py @@ -74,7 +74,7 @@ yaml_configs = { } } }, - 'flavor_yaml':{ + 'flavor_yaml': { 'yaml_version': '2013-05-23', 'yaml_args': { 'rxtx_factor': 1 @@ -161,10 +161,8 @@ logging = { }, 'color': { '()': 'pecan.log.ColorFormatter', - 'format':'%(asctime)s [%(padded_color_levelname)s] [%(name)s] [%(threadName)s] %(message)s', + 'format': '%(asctime)s [%(padded_color_levelname)s] [%(name)s] [%(threadName)s] %(message)s', '__force_dict__': True } } } - - diff --git a/orm/services/resource_distributor/rds/tests/controllers/v1/configuration/test_get_configuration.py b/orm/services/resource_distributor/rds/tests/controllers/v1/configuration/test_get_configuration.py index 5abfc309..401c09dc 100755 --- a/orm/services/resource_distributor/rds/tests/controllers/v1/configuration/test_get_configuration.py +++ b/orm/services/resource_distributor/rds/tests/controllers/v1/configuration/test_get_configuration.py @@ -1,7 +1,7 @@ """Get configuration module unittests.""" -from rds.tests.controllers.v1.functional_test import FunctionalTest -from rds.controllers.v1.configuration import root from mock import patch +from rds.controllers.v1.configuration import root +from rds.tests.controllers.v1.functional_test import FunctionalTest class TestGetConfiguration(FunctionalTest): diff --git a/orm/services/resource_distributor/rds/tests/controllers/v1/resources/test_create_resource.py b/orm/services/resource_distributor/rds/tests/controllers/v1/resources/test_create_resource.py index f881564e..6c7a673f 100755 --- a/orm/services/resource_distributor/rds/tests/controllers/v1/resources/test_create_resource.py +++ b/orm/services/resource_distributor/rds/tests/controllers/v1/resources/test_create_resource.py @@ -1,6 +1,5 @@ """unittest get resource.""" from mock import patch - import rds.controllers.v1.resources.root as root from rds.tests.controllers.v1.functional_test import FunctionalTest diff --git a/orm/services/resource_distributor/rds/tests/controllers/v1/status/test_base.py b/orm/services/resource_distributor/rds/tests/controllers/v1/status/test_base.py index af48fd4c..7d0a6ed2 100644 --- a/orm/services/resource_distributor/rds/tests/controllers/v1/status/test_base.py +++ b/orm/services/resource_distributor/rds/tests/controllers/v1/status/test_base.py @@ -5,9 +5,9 @@ from rds.controllers.v1.base import ClientSideError class Test(unittest.TestCase): - #Test the creation of ClientSideError + # Test the creation of ClientSideError def test_ClientSideError(self): error_str = "This is an error message" clientSideError = ClientSideError(error=error_str) self.assertEqual(clientSideError.msg, error_str) - self.assertEqual(clientSideError.code, 400) \ No newline at end of file + self.assertEqual(clientSideError.code, 400) diff --git a/orm/services/resource_distributor/rds/tests/controllers/v1/status/test_get_resource_status.py b/orm/services/resource_distributor/rds/tests/controllers/v1/status/test_get_resource_status.py index 3f455ba3..792576a7 100755 --- a/orm/services/resource_distributor/rds/tests/controllers/v1/status/test_get_resource_status.py +++ b/orm/services/resource_distributor/rds/tests/controllers/v1/status/test_get_resource_status.py @@ -1,9 +1,7 @@ """unittest get resource status.""" from mock import MagicMock - import rds.controllers.v1.status.get_resource as resource -from rds.services.model.region_resource_id_status import Model -from rds.services.model.region_resource_id_status import StatusModel +from rds.services.model.region_resource_id_status import Model, StatusModel from rds.tests.controllers.v1.functional_test import FunctionalTest diff --git a/orm/services/resource_distributor/rds/tests/controllers/v1/status/test_resource_status.py b/orm/services/resource_distributor/rds/tests/controllers/v1/status/test_resource_status.py index d8a7dea4..4559d35d 100644 --- a/orm/services/resource_distributor/rds/tests/controllers/v1/status/test_resource_status.py +++ b/orm/services/resource_distributor/rds/tests/controllers/v1/status/test_resource_status.py @@ -1,6 +1,5 @@ """unittest for post resource.""" from mock import patch - import rds.controllers.v1.status.resource_status as resource from rds.tests.controllers.v1.functional_test import FunctionalTest diff --git a/orm/services/resource_distributor/rds/tests/controllers/v1/test_logs.py b/orm/services/resource_distributor/rds/tests/controllers/v1/test_logs.py index e2902d27..15631eb7 100755 --- a/orm/services/resource_distributor/rds/tests/controllers/v1/test_logs.py +++ b/orm/services/resource_distributor/rds/tests/controllers/v1/test_logs.py @@ -1,8 +1,5 @@ """Logs module unittests.""" -import logging from rds.tests.controllers.v1.functional_test import FunctionalTest -from rds.controllers.v1.configuration import root -from mock import patch class TestLogs(FunctionalTest): diff --git a/orm/services/resource_distributor/rds/tests/functional_test.py b/orm/services/resource_distributor/rds/tests/functional_test.py index f44d59c6..ebc86047 100644 --- a/orm/services/resource_distributor/rds/tests/functional_test.py +++ b/orm/services/resource_distributor/rds/tests/functional_test.py @@ -1,11 +1,12 @@ """Base classes for API tests. """ +import os +import unittest + import pecan import pecan.testing -import unittest from pecan.testing import load_test_app -import os class FunctionalTest(unittest.TestCase): diff --git a/orm/services/resource_distributor/rds/tests/ordupdate/test_ord_notifier.py b/orm/services/resource_distributor/rds/tests/ordupdate/test_ord_notifier.py index 435730df..46cf91cd 100755 --- a/orm/services/resource_distributor/rds/tests/ordupdate/test_ord_notifier.py +++ b/orm/services/resource_distributor/rds/tests/ordupdate/test_ord_notifier.py @@ -1,8 +1,8 @@ +import unittest + import mock from mock import patch - from rds.ordupdate import ord_notifier -import unittest class MyResponse(object): @@ -114,30 +114,13 @@ class MainTest(unittest.TestCase): '(expected NotifyNotAcknowledgedError)') except ord_notifier.NotifyNotAcknowledgedError: pass - # @mock.patch.object(ord_notifier, 'conf') - # def test_notify_sanity(self, mock_conf): - # ord_notifier.requests.post = mock.MagicMock( - # return_value=MyResponse(ord_notifier.ACK_CODE, None)) - # ord_notifier._notify(*("1", )*8) - -# @mock.patch.object(ord_notifier, 'conf') - # def test_notify_not_acknowledged(self, mock_conf): - # ord_notifier.requests.post = mock.MagicMock( - # return_value=MyResponse(404, None)) -# - # try: - # ord_notifier._notify(*("1", )*8) - # self.fail('notify() passed successfully' - # '(expected NotifyNotAcknowledgedError)') - # except ord_notifier.NotifyNotAcknowledgedError: - # pass @mock.patch.object(ord_notifier, 'conf') def test_notify_https_disabled_but_received(self, mock_conf): ord_notifier.requests.post = validate_http_post mock_conf.ordupdate.https_enabled = False mock_conf.ordupdate.template_type = 'a' - ord_notifier._notify('https://127.0.0.1:1337', *("1", )*7) + ord_notifier._notify('https://127.0.0.1:1337', * ("1", ) * 7) @mock.patch.object(ord_notifier, 'conf') @mock.patch.object(ord_notifier.json, 'dumps') @@ -158,22 +141,6 @@ class MainTest(unittest.TestCase): self.assertRaises(ord_notifier.requests.exceptions.SSLError, ord_notifier._notify, 'https://127.0.0.1:1337', *("1",) * 7) -# @mock.patch.object(ord_notifier, 'conf') - # def test_notify_https_enabled_and_no_certificate(self, mock_conf): - # ord_notifier.requests.post = validate_https_post - # mock_conf.ordupdate.https_enabled = True - # mock_conf.ordupdate.cert_path = '' - # ord_notifier._notify('https://127.0.0.1:1337', *("1", )*7) - -# @mock.patch.object(ord_notifier, 'conf') - # def test_notify_https_enabled_and_ssl_error(self, mock_conf): - # ord_notifier.requests.post = mock.MagicMock( - # side_effect=ord_notifier.requests.exceptions.SSLError('test')) - # mock_conf.ordupdate.https_enabled = True - # mock_conf.ordupdate.cert_path = '' - # self.assertRaises(ord_notifier.requests.exceptions.SSLError, - # ord_notifier._notify, 'https://127.0.0.1:1337', - # *("1", )*7) @patch.object(ord_notifier.audit, 'audit') @patch.object(ord_notifier, 'regionResourceIdStatus') @@ -189,35 +156,6 @@ class MainTest(unittest.TestCase): self.assertEqual(e.message, 'ORD of LCP %s not found' % ( 'gigi', )) - #@patch.object(ord_notifier.audit, 'audit') - #@patch.object(ord_notifier, 'regionResourceIdStatus') - # @mock.patch.object(ord_notifier, 'conf') - # @mock.patch.object(ord_notifier.json, 'dumps') - #def test_main_sanity(self, mock_dumps, mock_conf, mock_region, mock_audit): - # ord_notifier.requests.get = mock.MagicMock( - # return_value=MyResponse(ord_notifier.OK_CODE, - # {ord_notifier.LCP_ID: 'gigi', - # ord_notifier.ORD_URL: 'test'})) - # ord_notifier.requests.post = mock.MagicMock( - # return_value=MyResponse(ord_notifier.ACK_CODE, None)) - - # ord_notifier.notify_ord('test', '1', '2', '3', '4', '5', '6', '7', - # '8', '') - # @patch.object(ord_notifier.audit, 'audit') - # @patch.object(ord_notifier, 'regionResourceIdStatus') -# @mock.patch.object(ord_notifier, 'conf') -# def test_main_sanity(self, mock_audit, mock_region, mock_conf): - # ord_notifier.requests.get = mock.MagicMock( - # return_value=MyResponse(ord_notifier.OK_CODE, - # {'regions': [{'endpoints': [ - # {'publicurl': 'test', - # 'type': 'ord'}]}]})) - # ord_notifier.requests.post = mock.MagicMock( - # return_value=MyResponse(ord_notifier.ACK_CODE, None)) - - #ord_notifier.notify_ord('test', '1', '2', '3', '4', '5', '6', '7', - # '8', '') - @patch.object(ord_notifier.audit, 'audit') @patch.object(ord_notifier, 'regionResourceIdStatus') @mock.patch.object(ord_notifier, 'conf') diff --git a/orm/services/resource_distributor/rds/tests/services/test_create_resource.py b/orm/services/resource_distributor/rds/tests/services/test_create_resource.py index 53a1c230..4b8d5b5f 100755 --- a/orm/services/resource_distributor/rds/tests/services/test_create_resource.py +++ b/orm/services/resource_distributor/rds/tests/services/test_create_resource.py @@ -2,16 +2,16 @@ import unittest from mock import patch - from rds.services import resource as ResourceService -from rds.services.model.region_resource_id_status import Model, ResourceMetaData -from rds.services.model.region_resource_id_status import StatusModel +from rds.services.model.region_resource_id_status import (Model, + ResourceMetaData, + StatusModel) result = Model( status="success", timestamp="123456789", region="name", transaction_id=5, resource_id="1", ord_notifier="", err_msg="123", err_code="12", operation="create", - resource_extra_metadata=[ResourceMetaData(checksum=1,virtual_size=2,size=3)] + resource_extra_metadata=[ResourceMetaData(checksum=1, virtual_size=2, size=3)] ) uuid = "uuid-12345" @@ -26,13 +26,13 @@ class InputData(object): external_transaction_id=""): """init function. - :param resource_id: - :param resource_type: - :param targets: - :param operation: - :param transaction_id: - :param model: - :param external_transaction_id: + : param resource_id: + : param resource_type: + : param targets: + : param operation: + : param transaction_id: + : param model: + : param external_transaction_id: """ self.resource_id = resource_id self.targets = targets @@ -298,17 +298,17 @@ jsondata = { "ram": "10", "keypairs": "10", "injected_files": "10" - }, + }, "storage": {"gigabytes": "10", "snapshots": "10", "volumes": "10" }, - "network":{ - "router": "10", - "floatingip": "10", - "port": "10", - "network": "10", - "subnet": "10" + "network": { + "router": "10", + "floatingip": "10", + "port": "10", + "network": "10", + "subnet": "10" }}], "users": [ @@ -552,64 +552,64 @@ targets = [{'users': [{'id': 'userId1', 'roles': ['admin', 'other']}, 'floatingip': '10'}}]}] json_data_image = { - "internal_id":1, - "id":"uuu1id12-uuid-uuid-uuid", - "name":"Ubuntu", - "enabled": 1, - "protected": 1, - "url": "https://mirrors.it.att.com/images/image-name", - "visibility": "public", - "disk_format": "raw", - "container_format": "bare", - "min_disk":2, - "min_ram":0, - "regions":[ - { - "name":"North", - "type":"single", - "action": "delete", - "image_internal_id":1 - }, - { - "name":"North", - "action": "create", - "type":"single", - "image_internal_id":1 - } - ], - "image_properties":[ - { - "key_name":"Key1", - "key_value":"Key1.value", - "image_internal_id":1 - }, - { - "key_name":"Key2", - "key_value":"Key2.value", - "image_internal_id":1 - } - ], - "image_tenant":[ - { - "tenant_id":"abcd-efgh-ijkl-4567", - "image_internal_id":1 - }, - { - "tenant_id":"abcd-efgh-ijkl-4567", - "image_internal_id":1 - } - ], - "image_tags":[ - { - "tag":"abcd-efgh-ijkl-4567", - "image_internal_id":1 - }, - { - "tag":"abcd-efgh-ijkl-4567", - "image_internal_id":1 - } - ], - "status":"complete", + "internal_id": 1, + "id": "uuu1id12-uuid-uuid-uuid", + "name": "Ubuntu", + "enabled": 1, + "protected": 1, + "url": "https://mirrors.it.att.com/images/image-name", + "visibility": "public", + "disk_format": "raw", + "container_format": "bare", + "min_disk": 2, + "min_ram": 0, + "regions": [ + { + "name": "North", + "type": "single", + "action": "delete", + "image_internal_id": 1 + }, + { + "name": "North", + "action": "create", + "type": "single", + "image_internal_id": 1 + } + ], + "image_properties": [ + { + "key_name": "Key1", + "key_value": "Key1.value", + "image_internal_id": 1 + }, + { + "key_name": "Key2", + "key_value": "Key2.value", + "image_internal_id": 1 + } + ], + "image_tenant": [ + { + "tenant_id": "abcd-efgh-ijkl-4567", + "image_internal_id": 1 + }, + { + "tenant_id": "abcd-efgh-ijkl-4567", + "image_internal_id": 1 + } + ], + "image_tags": [ + { + "tag": "abcd-efgh-ijkl-4567", + "image_internal_id": 1 + }, + { + "tag": "abcd-efgh-ijkl-4567", + "image_internal_id": 1 + } + ], + "status": "complete", } input_data_resource = {'resource_id': '1e24981a-fa51-11e5-86aa-5e5517507c66', @@ -692,44 +692,46 @@ input_data_resource = {'resource_id': '1e24981a-fa51-11e5-86aa-5e5517507c66', 'operation': 'create', 'transaction_id': ''} -expected_image_input_data = {'resource_id': 'uuu1id12-uuid-uuid-uuid', - 'targets': [ - {'action': 'delete', 'image_internal_id': 1, - 'type': 'single', 'name': 'North'}, - {'action': 'create', 'image_internal_id': 1, - 'type': 'single', 'name': 'North'}], - 'resource_type': 'image', - 'model': {'status': 'complete', 'name': 'Ubuntu', - 'internal_id': 1, - 'url': 'https://mirrors.it.att.com/images/image-name', - 'disk_format': 'raw', 'min_ram': 0, - 'enabled': 1, 'visibility': 'public', - 'image_tags': [{'image_internal_id': 1, - 'tag': 'abcd-efgh-ijkl-4567'}, - {'image_internal_id': 1, - 'tag': 'abcd-efgh-ijkl-4567'}], - 'regions': [{'action': 'delete', - 'image_internal_id': 1, - 'type': 'single', - 'name': 'North'}, - {'action': 'create', - 'image_internal_id': 1, - 'type': 'single', - 'name': 'North'}], - 'image_properties': [ - {'key_name': 'Key1', - 'key_value': 'Key1.value', - 'image_internal_id': 1}, - {'key_name': 'Key2', - 'key_value': 'Key2.value', - 'image_internal_id': 1}], - 'protected': 1, 'image_tenant': [ - {'tenant_id': 'abcd-efgh-ijkl-4567', - 'image_internal_id': 1}, - {'tenant_id': 'abcd-efgh-ijkl-4567', - 'image_internal_id': 1}], - 'container_format': 'bare', - 'min_disk': 2, - 'id': 'uuu1id12-uuid-uuid-uuid'}, - 'external_transaction_id': 'uuid-12345', - 'operation': 'create', 'transaction_id': ''} +expected_image_input_data = { + 'resource_id': 'uuu1id12-uuid-uuid-uuid', + 'targets': [ + { + 'action': 'delete', 'image_internal_id': 1, + 'type': 'single', 'name': 'North'}, + { + 'action': 'create', 'image_internal_id': 1, + 'type': 'single', 'name': 'North'}], + 'resource_type': 'image', + 'model': { + 'status': 'complete', 'name': 'Ubuntu', + 'internal_id': 1, + 'url': 'https://mirrors.it.att.com/images/image-name', + 'disk_format': 'raw', 'min_ram': 0, + 'enabled': 1, 'visibility': 'public', + 'image_tags': [ + {'image_internal_id': 1, 'tag': 'abcd-efgh-ijkl-4567'}, + {'image_internal_id': 1, 'tag': 'abcd-efgh-ijkl-4567'}], + 'regions': [ + { + 'action': 'delete', 'image_internal_id': 1, + 'type': 'single', 'name': 'North'}, + { + 'action': 'create', 'image_internal_id': 1, + 'type': 'single', 'name': 'North'}], + 'image_properties': [ + { + 'key_name': 'Key1', + 'key_value': 'Key1.value', + 'image_internal_id': 1}, + { + 'key_name': 'Key2', + 'key_value': 'Key2.value', + 'image_internal_id': 1}], + 'protected': 1, 'image_tenant': [ + {'tenant_id': 'abcd-efgh-ijkl-4567', 'image_internal_id': 1}, + {'tenant_id': 'abcd-efgh-ijkl-4567', 'image_internal_id': 1}], + 'container_format': 'bare', + 'min_disk': 2, + 'id': 'uuu1id12-uuid-uuid-uuid'}, + 'external_transaction_id': 'uuid-12345', + 'operation': 'create', 'transaction_id': ''} diff --git a/orm/services/resource_distributor/rds/tests/services/test_customer_yaml.py b/orm/services/resource_distributor/rds/tests/services/test_customer_yaml.py index e918f4b8..de4fedbd 100755 --- a/orm/services/resource_distributor/rds/tests/services/test_customer_yaml.py +++ b/orm/services/resource_distributor/rds/tests/services/test_customer_yaml.py @@ -2,13 +2,13 @@ import unittest import yaml -from mock import patch +from mock import patch from rds.services import yaml_customer_builder as CustomerBuild alldata = { 'uuid': '1e24981a-fa51-11e5-86aa-5e5517507c66', - 'metadata': [{'my_server_name': 'Apache1'},{'ocx_cust': '123456889'}], + 'metadata': [{'my_server_name': 'Apache1'}, {'ocx_cust': '123456889'}], 'default_region': {'users': [{'id': 'userId1zzzz', 'roles': ['adminzzzz', 'otherzzzzz']}, {'id': 'userId2zzz', diff --git a/orm/services/resource_distributor/rds/tests/services/test_flavor_yaml.py b/orm/services/resource_distributor/rds/tests/services/test_flavor_yaml.py index 81c05724..56adf81e 100755 --- a/orm/services/resource_distributor/rds/tests/services/test_flavor_yaml.py +++ b/orm/services/resource_distributor/rds/tests/services/test_flavor_yaml.py @@ -1,9 +1,10 @@ """flavor unittest module.""" -from mock import patch -from rds.services import yaml_flavor_bulder as FlavorBuild import unittest + import yaml +from mock import patch +from rds.services import yaml_flavor_bulder as FlavorBuild alldata = {'status': 'complete', 'series': 'P2', 'description': 'First flavor for AMAR', diff --git a/orm/services/resource_distributor/rds/tests/services/test_image_yaml.py b/orm/services/resource_distributor/rds/tests/services/test_image_yaml.py index 2cc2f004..b175304f 100755 --- a/orm/services/resource_distributor/rds/tests/services/test_image_yaml.py +++ b/orm/services/resource_distributor/rds/tests/services/test_image_yaml.py @@ -1,45 +1,60 @@ import unittest + +import yaml + from mock import patch from rds.services import yaml_image_builder as ImageBuild -import yaml -import datetime -json_input = {'status': 'complete', 'name': 'Ubuntu', 'internal_id': 1, - 'url': 'https://mirrors.it.att.com/images/image-name', - 'disk_format': 'raw', 'min_ram': 0, 'enabled': 1, - 'visibility': 'public', 'owner': 'unknown', 'image_tags': [ +json_input = { + 'status': 'complete', 'name': 'Ubuntu', 'internal_id': 1, + 'url': 'https://mirrors.it.att.com/images/image-name', + 'disk_format': 'raw', 'min_ram': 0, 'enabled': 1, + 'visibility': 'public', 'owner': 'unknown', 'image_tags': [ {'image_internal_id': 1, 'tag': 'abcd-efgh-ijkl-4567'}, - {'image_internal_id': 1, 'tag': 'abcd-efgh-ijkl-4567'}], 'regions': [ - {'action': 'delete', 'image_internal_id': 1, 'type': 'single', - 'name': 'North'}, - {'action': 'create', 'image_internal_id': 1, 'type': 'single', - 'name': 'North'}], 'image_properties': [ - {'key_name': 'Key1', 'key_value': 'Key1.value', - 'image_internal_id': 1}, - {'key_name': 'Key2', 'key_value': 'Key2.value', - 'image_internal_id': 1}], 'protected': 1, 'customers': [ + {'image_internal_id': 1, 'tag': 'abcd-efgh-ijkl-4567'}], + 'regions': [ + { + 'action': 'delete', 'image_internal_id': 1, + 'type': 'single', 'name': 'North'}, + { + 'action': 'create', 'image_internal_id': 1, + 'type': 'single', 'name': 'North'}], + 'image_properties': [ + { + 'key_name': 'Key1', 'key_value': 'Key1.value', + 'image_internal_id': 1}, + { + 'key_name': 'Key2', 'key_value': 'Key2.value', + 'image_internal_id': 1}], + 'protected': 1, + 'customers': [ {'customer_id': 'abcd-efgh-ijkl-4567', 'image_id': 1}, {'customer_id': 'abcd-efgh-ijkl-4567', 'image_id': 1}], - 'container_format': 'bare', 'min_disk': 2, - 'id': 'uuu1id12-uuid-uuid-uuid'} + 'container_format': 'bare', 'min_disk': 2, + 'id': 'uuu1id12-uuid-uuid-uuid'} region = {'action': 'delete', 'image_internal_id': 1, 'type': 'single', 'name': 'North'} -yaml_output = {'description': 'yaml file for region - North', - 'resources': {'glance_image': {'properties': {'container_format': 'bare', - 'disk_format': 'raw', - 'is_public': True, - 'copy_from': 'https://mirrors.it.att.com/images/image-name', - 'min_disk': 2, - 'min_ram': 0, - 'name': 'North', - 'owner': 'unknown', - 'protected': True, - 'tenants': ['abcd-efgh-ijkl-4567', 'abcd-efgh-ijkl-4567']}, - 'type': 'OS::Glance::Image2'}}, - 'heat_template_version': '2015-1-1', - 'outputs': {'glance_image_id': {'value': {'get_resource': 'glance_image'}}}} +yaml_output = { + 'description': 'yaml file for region - North', + 'resources': { + 'glance_image': { + 'properties': { + 'container_format': 'bare', + 'disk_format': 'raw', + 'is_public': True, + 'copy_from': 'https://mirrors.it.att.com/images/image-name', + 'min_disk': 2, + 'min_ram': 0, + 'name': 'North', + 'owner': 'unknown', + 'protected': True, + 'tenants': ['abcd-efgh-ijkl-4567', 'abcd-efgh-ijkl-4567']}, + 'type': 'OS::Glance::Image2'}}, + 'heat_template_version': '2015-1-1', + 'outputs': {'glance_image_id': {'value': {'get_resource': 'glance_image'}}} +} class CreateImage(unittest.TestCase): diff --git a/orm/services/resource_distributor/rds/tests/services/test_region_resource_id_status.py b/orm/services/resource_distributor/rds/tests/services/test_region_resource_id_status.py index 3ac9b3e4..9d1458f2 100755 --- a/orm/services/resource_distributor/rds/tests/services/test_region_resource_id_status.py +++ b/orm/services/resource_distributor/rds/tests/services/test_region_resource_id_status.py @@ -1,9 +1,8 @@ -from rds.tests import config as conf -import mock -import time import unittest +import mock from rds.services import region_resource_id_status +from rds.tests import config as conf class MyResult(object): diff --git a/orm/services/resource_distributor/rds/tests/sot/git_sot/test_git_base.py b/orm/services/resource_distributor/rds/tests/sot/git_sot/test_git_base.py index 1f93eb47..2580de2c 100644 --- a/orm/services/resource_distributor/rds/tests/sot/git_sot/test_git_base.py +++ b/orm/services/resource_distributor/rds/tests/sot/git_sot/test_git_base.py @@ -1,10 +1,6 @@ -import subprocess import unittest -import mock -from mock import patch -from rds.sot.git_sot import git_base -from rds.sot.git_sot.git_base import BaseGit, GitResetError +from rds.sot.git_sot.git_base import BaseGit class BaseGitTests(unittest.TestCase): @@ -60,4 +56,3 @@ class BaseGitTests(unittest.TestCase): with self.assertRaises(NotImplementedError): base_git = BaseGit() base_git.validate_git() - diff --git a/orm/services/resource_distributor/rds/tests/sot/git_sot/test_git_factory.py b/orm/services/resource_distributor/rds/tests/sot/git_sot/test_git_factory.py index abcb5744..1c4df9bc 100644 --- a/orm/services/resource_distributor/rds/tests/sot/git_sot/test_git_factory.py +++ b/orm/services/resource_distributor/rds/tests/sot/git_sot/test_git_factory.py @@ -22,4 +22,4 @@ class GitFactoryTests(unittest.TestCase): def test_get_sot_no_sot_type(self): """Test that when given unknown type, exception raised""" with self.assertRaises(RuntimeError): - git_factory.get_git_impl("unknown") \ No newline at end of file + git_factory.get_git_impl("unknown") diff --git a/orm/services/resource_distributor/rds/tests/sot/git_sot/test_git_gittle.py b/orm/services/resource_distributor/rds/tests/sot/git_sot/test_git_gittle.py index 709e1212..bfce37f1 100644 --- a/orm/services/resource_distributor/rds/tests/sot/git_sot/test_git_gittle.py +++ b/orm/services/resource_distributor/rds/tests/sot/git_sot/test_git_gittle.py @@ -1,11 +1,10 @@ -import mock -from mock import patch - import unittest +import mock +from mock import patch from rds.sot.git_sot import git_gittle -from rds.sot.git_sot.git_gittle import GitGittle from rds.sot.git_sot.git_base import GitInitError, GitUploadError +from rds.sot.git_sot.git_gittle import GitGittle class GitGittleTests(unittest.TestCase): @@ -53,4 +52,3 @@ class GitGittleTests(unittest.TestCase): self.my_git.repo = mock.MagicMock() self.my_git.repo.commit = mock.MagicMock(side_effect=Exception("Failed to commit")) self.assertRaises(GitUploadError, self.my_git.git_upload_changes) - diff --git a/orm/services/resource_distributor/rds/tests/sot/git_sot/test_git_native.py b/orm/services/resource_distributor/rds/tests/sot/git_sot/test_git_native.py index b18eec20..bce79427 100644 --- a/orm/services/resource_distributor/rds/tests/sot/git_sot/test_git_native.py +++ b/orm/services/resource_distributor/rds/tests/sot/git_sot/test_git_native.py @@ -1,8 +1,8 @@ """Unittest module for git_native.""" -import mock -from mock import patch import unittest +import mock +from mock import patch from rds.sot.git_sot import git_native from rds.sot.git_sot.git_native import GitNativeError, GitValidateError @@ -82,11 +82,11 @@ class GitNativeTest(unittest.TestCase): @patch.object(git_native.subprocess, 'Popen') @patch.object(git_native.GitNative, '_git_config', side_effect=GitNativeError("Could not write to file")) - def test_git_native_validate_git_config_fail(self, conf,mock_popen, result): + def test_git_native_validate_git_config_fail(self, conf, mock_popen, result): """Test that no exception is raised when calling git_init.aein""" my_pipe = mock.MagicMock() my_pipe.communicate = mock.MagicMock(return_value=('1', '2',)) mock_popen.return_value = my_pipe test_git = git_native.GitNative() with self.assertRaises(GitValidateError): - test_git.validate_git() \ No newline at end of file + test_git.validate_git() diff --git a/orm/services/resource_distributor/rds/tests/sot/git_sot/test_git_sot.py b/orm/services/resource_distributor/rds/tests/sot/git_sot/test_git_sot.py index 651f0d28..64d7f596 100755 --- a/orm/services/resource_distributor/rds/tests/sot/git_sot/test_git_sot.py +++ b/orm/services/resource_distributor/rds/tests/sot/git_sot/test_git_sot.py @@ -1,33 +1,32 @@ import os -import mock -import unittest import threading +import unittest + +import mock from mock import patch - -from rds.sot.git_sot import git_sot as sot from rds.sot.base_sot import SoTError -from rds.sot.git_sot.git_base import GitUploadError, GitInitError, GitResetError -from rds.sot.git_sot.git_base import GitValidateError +from rds.sot.git_sot.git_base import (GitInitError, GitResetError, + GitUploadError, GitValidateError) +from rds.sot.git_sot import git_sot as sot from rds.sot import sot_factory - from rds.tests import config as conf lock = mock.MagicMock() resource = { - "operation": "create", - "region_id": '1', - "resource_type": '2', - "resource_name": '3', - "template_data": '4' + "operation": "create", + "region_id": '1', + "resource_type": '2', + "resource_name": '3', + "template_data": '4' } resource_delete = { - "operation": "delete", - "region_id": '1', - "resource_type": '2', - "resource_name": '3', - "template_data": '4' + "operation": "delete", + "region_id": '1', + "resource_type": '2', + "resource_name": '3', + "template_data": '4' } @@ -43,15 +42,12 @@ class GitSoTTest(unittest.TestCase): git_factory = mock.MagicMock() git_factory.get_git_impl = mock.MagicMock() - ################## - ### update_sot ### - ################## - + # update_sot @patch.object(sot, 'init_git', side_effect=GitInitError("Failed to initialize Git")) def test_git_sot_update_sot_init_git_fail(self, result): """" init_git fails and raise exception""" try: - sot.update_sot("", lock, '1', '2', ['3','5'], '4', '6') + sot.update_sot("", lock, '1', '2', ['3', '5'], '4', '6') except SoTError: self.fail("Exception should have been handled inside method") @@ -71,7 +67,7 @@ class GitSoTTest(unittest.TestCase): def test_git_sot_update_sot_update_git_fail(self, git_repo, files_created, result, clean_result): """" update git fails and raise exception""" try: - sot.update_sot("",lock, 'a', 'b', ['c', 'd'], 'e', 'f') + sot.update_sot("", lock, 'a', 'b', ['c', 'd'], 'e', 'f') except GitUploadError: self.fail("Exception should have been handled inside method") @@ -288,5 +284,3 @@ class GitSoTTest(unittest.TestCase): sot.validate_git(git_impl, lock) except GitInitError: self.fail("No exceptions should be thrown in this case") - - diff --git a/orm/services/resource_distributor/rds/tests/sot/test_base_sot.py b/orm/services/resource_distributor/rds/tests/sot/test_base_sot.py index bfad0531..3642cf9c 100644 --- a/orm/services/resource_distributor/rds/tests/sot/test_base_sot.py +++ b/orm/services/resource_distributor/rds/tests/sot/test_base_sot.py @@ -9,12 +9,10 @@ class BaseSoTTests(unittest.TestCase): """ Check if creating an instance and calling save method fail""" with self.assertRaises(Exception): sot = BaseSoT() - sot.save_resource_to_sot('1','2',[]) + sot.save_resource_to_sot('1', '2', []) def test_base_sot_no_method_validate_implemented(self): """ Check if creating an instance and calling validate method fail""" with self.assertRaises(Exception): sot = BaseSoT() sot.validate_sot_state() - - diff --git a/orm/services/resource_distributor/rds/tests/sot/test_sot_factory.py b/orm/services/resource_distributor/rds/tests/sot/test_sot_factory.py index bbda0a6a..e0947284 100644 --- a/orm/services/resource_distributor/rds/tests/sot/test_sot_factory.py +++ b/orm/services/resource_distributor/rds/tests/sot/test_sot_factory.py @@ -1,8 +1,8 @@ import unittest -import mock -from rds.sot import sot_factory +import mock from rds.sot.git_sot.git_sot import GitSoT +from rds.sot import sot_factory class SoTFactoryTests(unittest.TestCase): @@ -46,11 +46,3 @@ class SoTFactoryTests(unittest.TestCase): self.assertEqual(GitSoT.commit_email, "6", "commit_email not match") self.assertEqual(GitSoT.git_server_url, "7", "git_server_url not match") self.assertEqual(GitSoT.git_type, "gittle", "git_type not match") - - - - - - - - diff --git a/orm/services/resource_distributor/rds/tests/storage/mysql/test_region_resource_id_status.py b/orm/services/resource_distributor/rds/tests/storage/mysql/test_region_resource_id_status.py index 99f3b8f0..a953a4a8 100755 --- a/orm/services/resource_distributor/rds/tests/storage/mysql/test_region_resource_id_status.py +++ b/orm/services/resource_distributor/rds/tests/storage/mysql/test_region_resource_id_status.py @@ -1,11 +1,10 @@ """Unittest module for mysql.region_resource_id_status.""" import time +import unittest import mock from mock import patch - from rds.storage.mysql import region_resource_id_status -import unittest class RecordMock(object): @@ -104,7 +103,7 @@ class MysqlRegionResourceIdStatusTest(unittest.TestCase): 'err_code') @mock.patch.object(region_resource_id_status.db_session, 'EngineFacade', - return_value=MyFacade(True,False)) + return_value=MyFacade(True, False)) def test_add_update_status_record_duplicate_entry(self, mock_db_session): """No exception is raised when trying to add a duplicate entry.""" my_connection = region_resource_id_status.Connection('url') @@ -121,10 +120,10 @@ class MysqlRegionResourceIdStatusTest(unittest.TestCase): @mock.patch.object(region_resource_id_status, 'StatusModel') @patch.object(region_resource_id_status.Connection, 'get_timstamp_pair', - return_value=(1,2)) + return_value=(1, 2)) @mock.patch.object(region_resource_id_status, 'Model') @mock.patch.object(region_resource_id_status.db_session, 'EngineFacade', - return_value=MyFacade(False,False,True)) + return_value=MyFacade(False, False, True)) def test_get_records_by_filter_args_no_records(self, mock_db_session, mock_get_timestamp, mock_model, @@ -140,10 +139,11 @@ class MysqlRegionResourceIdStatusTest(unittest.TestCase): @mock.patch.object(region_resource_id_status, 'Model') @mock.patch.object(region_resource_id_status.db_session, 'EngineFacade', return_value=MyFacade(False, True, True)) - def test_get_records_by_filter_args_with_records(self, mock_db_session, - mock_get_timestamp, - mock_model, - mock_statusmodel): + def test_get_records_by_filter_args_with_records(self, + mock_db_session, + mock_get_timestamp, + mock_model, + mock_statusmodel): """Test that the function returns None when it got records.""" my_connection = region_resource_id_status.Connection('url') my_connection.get_records_by_filter_args() @@ -214,4 +214,3 @@ class MysqlRegionResourceIdStatusTest(unittest.TestCase): mock_statusmodel): my_connection = region_resource_id_status.Connection('url') my_connection.get_records_by_resource_id_and_status('1', '2') - diff --git a/orm/services/resource_distributor/rds/tests/storage/test_region_resource_id_status.py b/orm/services/resource_distributor/rds/tests/storage/test_region_resource_id_status.py index 82245fea..3a2f7b97 100644 --- a/orm/services/resource_distributor/rds/tests/storage/test_region_resource_id_status.py +++ b/orm/services/resource_distributor/rds/tests/storage/test_region_resource_id_status.py @@ -8,7 +8,7 @@ class BaseStorageTests(unittest.TestCase): def test_storage_add_status_record_not_implemented(self): """ Check if creating an instance and calling add_update_status_record method fail""" with self.assertRaises(Exception): - Base("").add_update_status_record('1','2','3','4','5','6','7','8') + Base("").add_update_status_record('1', '2', '3', '4', '5', '6', '7', '8') def test_storage_get_records_by_resource_id_implemented(self): """ Check if creating an instance and calling get_records_by_resource_id method fail""" diff --git a/orm/services/resource_distributor/rds/tests/utils/test_uuid_utils.py b/orm/services/resource_distributor/rds/tests/utils/test_uuid_utils.py index 3e5cffef..3017dd7c 100755 --- a/orm/services/resource_distributor/rds/tests/utils/test_uuid_utils.py +++ b/orm/services/resource_distributor/rds/tests/utils/test_uuid_utils.py @@ -1,9 +1,5 @@ """UUID utils test module.""" -import mock -from rds.utils import uuid_utils -import unittest - class MyResponse(object): """A test response class.""" diff --git a/orm/services/resource_distributor/rds/utils/authentication.py b/orm/services/resource_distributor/rds/utils/authentication.py index 08c02408..359f14ae 100755 --- a/orm/services/resource_distributor/rds/utils/authentication.py +++ b/orm/services/resource_distributor/rds/utils/authentication.py @@ -1,10 +1,11 @@ -import logging -import requests import json -from pecan import conf -from keystone_utils import tokens -from rds.proxies import rms_proxy as RmsService +import logging +import requests + +from keystone_utils import tokens +from pecan import conf +from rds.proxies import rms_proxy as RmsService enabled = False mech_id = "" diff --git a/orm/services/resource_distributor/rds/utils/module_mocks/orm_common/utils/utils.py b/orm/services/resource_distributor/rds/utils/module_mocks/orm_common/utils/utils.py index b5436b6e..ba516a7a 100755 --- a/orm/services/resource_distributor/rds/utils/module_mocks/orm_common/utils/utils.py +++ b/orm/services/resource_distributor/rds/utils/module_mocks/orm_common/utils/utils.py @@ -11,4 +11,3 @@ def set_utils_conf(conf): """Mock set_utils_conf function.""" pass - diff --git a/orm/services/resource_distributor/rds/utils/utils.py b/orm/services/resource_distributor/rds/utils/utils.py index ae96f0bc..a9a20de5 100755 --- a/orm/services/resource_distributor/rds/utils/utils.py +++ b/orm/services/resource_distributor/rds/utils/utils.py @@ -1,9 +1,11 @@ """module""" import logging + import requests + from pecan import conf -from rds.services.base import ErrorMesage from rds.proxies import ims_proxy +from rds.services.base import ErrorMesage logger = logging.getLogger(__name__) @@ -71,4 +73,3 @@ def add_rms_status_to_regions(resource_regions, resource_type): # if region not found in rms region['rms_status'] = "region_not_found_in_rms" return resource_regions - diff --git a/orm/tests/__init__.py b/orm/tests/__init__.py index 78ea5274..8fcee68f 100644 --- a/orm/tests/__init__.py +++ b/orm/tests/__init__.py @@ -1,14 +1,13 @@ import os -from unittest import TestCase from pecan import set_config from pecan.testing import load_test_app +from unittest import TestCase __all__ = ['FunctionalTest'] class FunctionalTest(TestCase): - """ - Used for functional tests where you need to test your + """Used for functional tests where you need to test your literal application and its integration with the framework. """ diff --git a/orm/tests/test_functional.py b/orm/tests/test_functional.py index 8ecb5357..4f794a23 100644 --- a/orm/tests/test_functional.py +++ b/orm/tests/test_functional.py @@ -1,5 +1,3 @@ -from unittest import TestCase -from webtest import TestApp from orm.tests import FunctionalTest diff --git a/tox.ini b/tox.ini index 02b0cb4b..962ab749 100644 --- a/tox.ini +++ b/tox.ini @@ -31,9 +31,7 @@ commands = commands = oslo_debug_helper {posargs} [flake8] -# E123, E125 skipped as they are invalid PEP-8. - show-source = True -ignore = F821,H202,E125,H101,H104,H238,H401,H404,H405,H306,E901,E128,E226,E501,F401,F841,F841,W191,W391,E101,E121,E122,E126,E231,H233,H301,H303,H304,F403,F811,E401,H201,E265,E111,W292,E201 +ignore = H301,F821,H202,H101,H104,H238,H401,H405,E501,F811,F403,H233,F841 builtins = _ exclude=.venv,.git,.tox,dist,doc,*lib/python*,*egg,build