From 57a812acd15b5b298d2409370dad119b942fdb1a Mon Sep 17 00:00:00 2001 From: Nicholas Jones Date: Thu, 17 Aug 2017 10:03:38 -0500 Subject: [PATCH] Move services/cms tests to top level test folder Moves tests out of subfolders so they can be picked up by tox/jenkins Change-Id: I76369941dff73774f55dd77efd8d396fa9942d7d --- orm/services/customer_manager/cms_rest/app.py | 12 ++++---- .../cms_rest/controllers/root.py | 2 +- .../controllers/v1/orm/configuration.py | 2 +- .../controllers/v1/orm/customer/enabled.py | 15 +++++----- .../controllers/v1/orm/customer/metadata.py | 15 +++++----- .../controllers/v1/orm/customer/regions.py | 17 +++++------ .../controllers/v1/orm/customer/root.py | 23 ++++++++------- .../controllers/v1/orm/customer/users.py | 15 +++++----- .../cms_rest/controllers/v1/orm/root.py | 8 ++++-- .../cms_rest/controllers/v1/root.py | 2 +- .../cms_rest/data/data_manager.py | 17 ++++++----- .../data/sql_alchemy/cms_user_record.py | 4 +-- .../data/sql_alchemy/customer_record.py | 9 +++--- .../sql_alchemy/customer_region_record.py | 8 +++--- .../cms_rest/data/sql_alchemy/models.py | 4 +-- .../data/sql_alchemy/region_record.py | 4 +-- .../data/sql_alchemy/user_role_record.py | 12 ++++---- .../cms_rest/logic/customer_logic.py | 28 +++++++++---------- .../cms_rest/logic/metadata_logic.py | 14 +++++----- .../customer_manager/cms_rest/model/Models.py | 8 +++--- .../customer_manager/cms_rest/rds_proxy.py | 4 +-- .../cms_rest/tests/logic/__init__.py | 0 .../cms_rest/tests/rest/__init__.py | 0 .../cms_rest/utils/authentication.py | 6 ++-- .../tests => tests/unit/cms}/__init__.py | 0 .../tests => tests/unit/cms}/config.py | 8 +++--- .../unit/cms}/simple_hook_mock.py | 0 .../unit/cms}/test_authentication.py | 23 +++++++-------- .../unit/cms}/test_configuration.py | 5 ++-- .../rest => tests/unit/cms}/test_customer.py | 8 +++--- .../unit/cms}/test_customer_logic.py | 10 +++---- .../rest => tests/unit/cms}/test_enable.py | 10 +++---- .../rest => tests/unit/cms}/test_metadata.py | 10 +++---- .../tests => tests/unit/cms}/test_models.py | 5 ++-- .../unit/cms}/test_rds_proxy.py | 15 +++++----- .../rest => tests/unit/cms}/test_regions.py | 12 ++++---- .../rest => tests/unit/cms}/test_users.py | 12 ++++---- .../tests => tests/unit/cms}/test_utils.py | 0 38 files changed, 178 insertions(+), 169 deletions(-) delete mode 100644 orm/services/customer_manager/cms_rest/tests/logic/__init__.py delete mode 100644 orm/services/customer_manager/cms_rest/tests/rest/__init__.py rename orm/{services/customer_manager/cms_rest/tests => tests/unit/cms}/__init__.py (100%) rename orm/{services/customer_manager/cms_rest/tests => tests/unit/cms}/config.py (92%) rename orm/{services/customer_manager/cms_rest/tests => tests/unit/cms}/simple_hook_mock.py (100%) rename orm/{services/customer_manager/cms_rest/tests => tests/unit/cms}/test_authentication.py (67%) rename orm/{services/customer_manager/cms_rest/tests => tests/unit/cms}/test_configuration.py (80%) rename orm/{services/customer_manager/cms_rest/tests/rest => tests/unit/cms}/test_customer.py (98%) rename orm/{services/customer_manager/cms_rest/tests/logic => tests/unit/cms}/test_customer_logic.py (98%) rename orm/{services/customer_manager/cms_rest/tests/rest => tests/unit/cms}/test_enable.py (91%) rename orm/{services/customer_manager/cms_rest/tests/rest => tests/unit/cms}/test_metadata.py (96%) rename orm/{services/customer_manager/cms_rest/tests => tests/unit/cms}/test_models.py (91%) rename orm/{services/customer_manager/cms_rest/tests => tests/unit/cms}/test_rds_proxy.py (79%) rename orm/{services/customer_manager/cms_rest/tests/rest => tests/unit/cms}/test_regions.py (96%) rename orm/{services/customer_manager/cms_rest/tests/rest => tests/unit/cms}/test_users.py (97%) rename orm/{services/customer_manager/cms_rest/tests => tests/unit/cms}/test_utils.py (100%) diff --git a/orm/services/customer_manager/cms_rest/app.py b/orm/services/customer_manager/cms_rest/app.py index c33c908c..12d1b370 100755 --- a/orm/services/customer_manager/cms_rest/app.py +++ b/orm/services/customer_manager/cms_rest/app.py @@ -1,13 +1,13 @@ 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 +from orm.common.orm_common.policy import policy +from orm.common.orm_common.utils import utils +from orm.services.customer_manager.cms_rest.logger import get_logger +from orm.services.customer_manager.cms_rest import model +from orm.services.customer_manager.cms_rest.utils import authentication + logger = get_logger(__name__) diff --git a/orm/services/customer_manager/cms_rest/controllers/root.py b/orm/services/customer_manager/cms_rest/controllers/root.py index 39688a98..3cf215b5 100755 --- a/orm/services/customer_manager/cms_rest/controllers/root.py +++ b/orm/services/customer_manager/cms_rest/controllers/root.py @@ -1,4 +1,4 @@ -from cms_rest.controllers.v1 import root as v1 +from orm.services.customer_manager.cms_rest.controllers.v1 import root as v1 from pecan import expose 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 c619f82d..1bb4a5d6 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 @@ -2,7 +2,7 @@ import logging -from orm_common.utils import utils +from orm.common.orm_common.utils import utils from pecan import conf, rest from wsmeext.pecan import wsexpose 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 386631c7..5b108afe 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,13 +1,14 @@ -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 orm.common.orm_common.utils import api_error_utils as err_utils +from orm.common.orm_common.utils import utils +from orm.services.customer_manager.cms_rest.logger import get_logger +from orm.services.customer_manager.cms_rest.logic.customer_logic import CustomerLogic +from orm.services.customer_manager.cms_rest.logic.error_base import ErrorStatus +from orm.services.customer_manager.cms_rest.model.Models import CustomerResultWrapper, Enabled +from orm.services.customer_manager.cms_rest.utils import authentication + 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 41cfb501..0dd688d4 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,13 +1,14 @@ -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 +from orm.common.orm_common.utils import api_error_utils as err_utils +from orm.common.orm_common.utils import utils +from orm.services.customer_manager.cms_rest.logger import get_logger +from orm.services.customer_manager.cms_rest.logic.error_base import ErrorStatus +import orm.services.customer_manager.cms_rest.logic.metadata_logic as logic +from orm.services.customer_manager.cms_rest.model.Models import CustomerResultWrapper, MetadataWrapper +from orm.services.customer_manager.cms_rest.utils import authentication + 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 a31514ff..58ef78ef 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,15 +1,16 @@ -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 request, rest from wsmeext.pecan import wsexpose +from orm.common.orm_common.utils import api_error_utils as err_utils +from orm.common.orm_common.utils import utils +from orm.services.customer_manager.cms_rest.controllers.v1.orm.customer.users import UserController +from orm.services.customer_manager.cms_rest.logger import get_logger +from orm.services.customer_manager.cms_rest.logic.customer_logic import CustomerLogic +from orm.services.customer_manager.cms_rest.logic.error_base import ErrorStatus +from orm.services.customer_manager.cms_rest.model.Models import Region, RegionResultWrapper +from orm.services.customer_manager.cms_rest.utils import authentication + 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 ac80c51c..96e51daf 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,18 +2,17 @@ from pecan import rest, request, response import oslo_db from wsmeext.pecan import wsexpose -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 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 +from orm.common.orm_common.utils import api_error_utils as err_utils +from orm.common.orm_common.utils import utils +from orm.services.customer_manager.cms_rest.controllers.v1.orm.customer.enabled import EnabledController +from orm.services.customer_manager.cms_rest.controllers.v1.orm.customer.metadata import MetadataController +from orm.services.customer_manager.cms_rest.controllers.v1.orm.customer.regions import RegionController +from orm.services.customer_manager.cms_rest.controllers.v1.orm.customer.users import DefaultUserController +from orm.services.customer_manager.cms_rest.logger import get_logger +from orm.services.customer_manager.cms_rest.logic.customer_logic import CustomerLogic +from orm.services.customer_manager.cms_rest.logic.error_base import ErrorStatus +from orm.services.customer_manager.cms_rest.model.Models import Customer, CustomerResultWrapper, CustomerSummaryResponse +from orm.services.customer_manager.cms_rest.utils import authentication LOG = get_logger(__name__) 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 bae532c9..a29eeea8 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,13 +1,14 @@ -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 orm.common.orm_common.utils import api_error_utils as err_utils +from orm.common.orm_common.utils import utils +from orm.services.customer_manager.cms_rest.logger import get_logger +from orm.services.customer_manager.cms_rest.logic.customer_logic import CustomerLogic +from orm.services.customer_manager.cms_rest.logic.error_base import ErrorStatus, NotFound +from orm.services.customer_manager.cms_rest.model.Models import User, UserResultWrapper +from orm.services.customer_manager.cms_rest.utils import authentication + 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 8472f180..6e892f26 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,8 @@ -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 __future__ import absolute_import + +from ..orm.configuration import ConfigurationController +from ..orm.customer.root import CustomerController +from ..orm.logs import LogsController from pecan.rest import RestController diff --git a/orm/services/customer_manager/cms_rest/controllers/v1/root.py b/orm/services/customer_manager/cms_rest/controllers/v1/root.py index e471f361..4d25741d 100644 --- a/orm/services/customer_manager/cms_rest/controllers/v1/root.py +++ b/orm/services/customer_manager/cms_rest/controllers/v1/root.py @@ -1,4 +1,4 @@ -from cms_rest.controllers.v1.orm.root import OrmController +from orm.root import OrmController 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 fa953466..8751f4f6 100755 --- a/orm/services/customer_manager/cms_rest/data/data_manager.py +++ b/orm/services/customer_manager/cms_rest/data/data_manager.py @@ -1,14 +1,13 @@ import logging -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 +from orm.services.customer_manager.cms_rest.data.sql_alchemy.customer_record import CustomerRecord +from orm.services.customer_manager.cms_rest.data.sql_alchemy.customer_region_record import CustomerRegionRecord +from orm.services.customer_manager.cms_rest.data.sql_alchemy.models import (CmsRole, CmsUser, Customer, + CustomerRegion, Quota, + QuotaFieldDetail, Region, + UserRole) +from orm.services.customer_manager.cms_rest.data.sql_alchemy.user_role_record import UserRoleRecord +from orm.services.customer_manager.cms_rest.logic.error_base import ErrorStatus import oslo_db from oslo_db.sqlalchemy import session as db_session from pecan import conf 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 4a556007..3b8ab57a 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,5 +1,5 @@ -from cms_rest.data.sql_alchemy.models import CmsUser -from cms_rest.logger import get_logger +from orm.services.customer_manager.cms_rest.data.sql_alchemy.models import CmsUser +from orm.services.customer_manager.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 7e12d232..8420e608 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,11 +1,12 @@ 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 +from orm.services.customer_manager.cms_rest.data.sql_alchemy.models import (CmsUser, Customer, + CustomerMetadata, CustomerRegion, + Region, UserRole) +from orm.services.customer_manager.cms_rest.logger import get_logger + LOG = get_logger(__name__) 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 1d81323b..7403c1bb 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,7 @@ -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 +from orm.services.customer_manager.cms_rest.data.sql_alchemy.customer_record import CustomerRecord +from orm.services.customer_manager.cms_rest.data.sql_alchemy.models import CustomerRegion +from orm.services.customer_manager.cms_rest.data.sql_alchemy.region_record import RegionRecord +from orm.services.customer_manager.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 f95ce1ce..bac388b2 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,5 +1,5 @@ -from cms_rest.data.sql_alchemy.base import Base -import cms_rest.model.Models as WsmeModels +from orm.services.customer_manager.cms_rest.data.sql_alchemy.base import Base +import orm.services.customer_manager.cms_rest.model.Models as WsmeModels from oslo_db.sqlalchemy import models from sqlalchemy import Column, ForeignKey, Integer, SmallInteger, String 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 a0386d8b..9801c209 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,5 +1,5 @@ -from cms_rest.data.sql_alchemy.models import Region -from cms_rest.logger import get_logger +from orm.services.customer_manager.cms_rest.data.sql_alchemy.models import Region +from orm.services.customer_manager.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 c44b1856..c3940dc4 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,9 +1,9 @@ -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 orm.services.customer_manager.cms_rest.data.sql_alchemy.cms_user_record import CmsUserRecord +from orm.services.customer_manager.cms_rest.data.sql_alchemy.customer_record import CustomerRecord +from orm.services.customer_manager.cms_rest.data.sql_alchemy.models import * +from orm.services.customer_manager.cms_rest.data.sql_alchemy.region_record import RegionRecord +from orm.services.customer_manager.cms_rest.logger import get_logger +from orm.services.customer_manager.cms_rest.logic.error_base import NotFound 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 2bdfd8ca..1521f6e2 100755 --- a/orm/services/customer_manager/cms_rest/logic/customer_logic.py +++ b/orm/services/customer_manager/cms_rest/logic/customer_logic.py @@ -1,19 +1,19 @@ -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 +import requests + +from orm.common.orm_common.utils import utils +from orm.common.orm_common.utils.cross_api_utils import (get_regions_of_group, + set_utils_conf) +from orm.services.customer_manager.cms_rest.data.data_manager import DataManager +from orm.services.customer_manager.cms_rest.data.sql_alchemy.models import CustomerMetadata, UserRole +from orm.services.customer_manager.cms_rest.logger import get_logger +from orm.services.customer_manager.cms_rest.logic.error_base import (DuplicateEntryError, ErrorStatus, + NotFound) +from orm.services.customer_manager.cms_rest.model.Models import (CustomerResultWrapper, CustomerSummary, + CustomerSummaryResponse, + RegionResultWrapper, UserResultWrapper) +from orm.services.customer_manager.cms_rest.rds_proxy import RdsProxy LOG = get_logger(__name__) 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 14cc7db7..7feef53d 100755 --- a/orm/services/customer_manager/cms_rest/logic/metadata_logic.py +++ b/orm/services/customer_manager/cms_rest/logic/metadata_logic.py @@ -1,13 +1,13 @@ import json - -from cms_rest.data.data_manager import DataManager -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 orm.common.orm_common.utils import utils +from orm.services.customer_manager.cms_rest.data.data_manager import DataManager +from orm.services.customer_manager.cms_rest.data.sql_alchemy.models import CustomerMetadata +from orm.services.customer_manager.cms_rest.logger import get_logger +from orm.services.customer_manager.cms_rest.model.Models import CustomerResultWrapper +from orm.services.customer_manager.cms_rest.rds_proxy import RdsProxy + logger = get_logger(__name__) diff --git a/orm/services/customer_manager/cms_rest/model/Models.py b/orm/services/customer_manager/cms_rest/model/Models.py index 25abc981..24c03b25 100755 --- a/orm/services/customer_manager/cms_rest/model/Models.py +++ b/orm/services/customer_manager/cms_rest/model/Models.py @@ -1,7 +1,7 @@ -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 orm.services.customer_manager.cms_rest.logic.error_base import ErrorStatus +from orm.services.customer_manager.cms_rest.model.Model import Model +from orm.common.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 diff --git a/orm/services/customer_manager/cms_rest/rds_proxy.py b/orm/services/customer_manager/cms_rest/rds_proxy.py index 8e885c59..de6f0e9b 100755 --- a/orm/services/customer_manager/cms_rest/rds_proxy.py +++ b/orm/services/customer_manager/cms_rest/rds_proxy.py @@ -3,8 +3,8 @@ import pprint import requests -from cms_rest.logger import get_logger -from cms_rest.logic.error_base import ErrorStatus +from orm.services.customer_manager.cms_rest.logger import get_logger +from orm.services.customer_manager.cms_rest.logic.error_base import ErrorStatus from pecan import conf, request LOG = get_logger(__name__) diff --git a/orm/services/customer_manager/cms_rest/tests/logic/__init__.py b/orm/services/customer_manager/cms_rest/tests/logic/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/orm/services/customer_manager/cms_rest/tests/rest/__init__.py b/orm/services/customer_manager/cms_rest/tests/rest/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/orm/services/customer_manager/cms_rest/utils/authentication.py b/orm/services/customer_manager/cms_rest/utils/authentication.py index b8553e33..b8512b0b 100755 --- a/orm/services/customer_manager/cms_rest/utils/authentication.py +++ b/orm/services/customer_manager/cms_rest/utils/authentication.py @@ -1,8 +1,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 orm.common.client.keystone.keystone_utils import tokens +from orm.common.orm_common.policy import policy +from orm.common.orm_common.utils import api_error_utils as err_utils from pecan import conf logger = logging.getLogger(__name__) diff --git a/orm/services/customer_manager/cms_rest/tests/__init__.py b/orm/tests/unit/cms/__init__.py similarity index 100% rename from orm/services/customer_manager/cms_rest/tests/__init__.py rename to orm/tests/unit/cms/__init__.py diff --git a/orm/services/customer_manager/cms_rest/tests/config.py b/orm/tests/unit/cms/config.py similarity index 92% rename from orm/services/customer_manager/cms_rest/tests/config.py rename to orm/tests/unit/cms/config.py index 7c7ddcb6..743cefde 100755 --- a/orm/services/customer_manager/cms_rest/tests/config.py +++ b/orm/tests/unit/cms/config.py @@ -1,6 +1,6 @@ import os -from cms_rest.tests.simple_hook_mock import SimpleHookMock +from orm.tests.unit.cms.simple_hook_mock import SimpleHookMock global SimpleHookMock @@ -14,8 +14,8 @@ server = { # Pecan Application Configurations app = { - 'root': 'cms_rest.controllers.root.RootController', - 'modules': ['cms_rest'], + 'root': 'orm.services.customer_manager.cms_rest.controllers.root.RootController', + 'modules': ['orm.services.customer_manager.cms_rest'], 'static_root': '%(confdir)s/../../public', 'template_path': '%(confdir)s/../templates', 'debug': True, @@ -127,5 +127,5 @@ authentication = { "token_role": "admin", "role_location": {"tenant": "admin"}, "keystone_version": "2.0", - "policy_file": "cms_rest/etc/policy.json" + "policy_file": "orm/services/customer_manager/cms_rest/etc/policy.json" } diff --git a/orm/services/customer_manager/cms_rest/tests/simple_hook_mock.py b/orm/tests/unit/cms/simple_hook_mock.py similarity index 100% rename from orm/services/customer_manager/cms_rest/tests/simple_hook_mock.py rename to orm/tests/unit/cms/simple_hook_mock.py diff --git a/orm/services/customer_manager/cms_rest/tests/test_authentication.py b/orm/tests/unit/cms/test_authentication.py similarity index 67% rename from orm/services/customer_manager/cms_rest/tests/test_authentication.py rename to orm/tests/unit/cms/test_authentication.py index 18afceba..ec0e6d48 100644 --- a/orm/services/customer_manager/cms_rest/tests/test_authentication.py +++ b/orm/tests/unit/cms/test_authentication.py @@ -1,8 +1,9 @@ -from cms_rest.tests import FunctionalTest -from cms_rest.utils import authentication import mock from pecan import conf +from orm.services.customer_manager.cms_rest.utils import authentication +from orm.tests.unit.cms import FunctionalTest + class TestUtil(FunctionalTest): @@ -10,14 +11,14 @@ class TestUtil(FunctionalTest): FunctionalTest.setUp(self) self.mock_response = mock.Mock() - @mock.patch('keystone_utils.tokens.TokenConf') + @mock.patch('orm.common.client.keystone.keystone_utils.tokens.TokenConf') def test_get_token_conf(self, mock_TokenConf): mock_TokenConf.return_value = 123 token_conf = authentication._get_token_conf(conf) self.assertEqual(token_conf, 123) - @mock.patch('keystone_utils.tokens.is_token_valid') - @mock.patch('keystone_utils.tokens.TokenConf') + @mock.patch('orm.common.client.keystone.keystone_utils.tokens.is_token_valid') + @mock.patch('orm.common.client.keystone.keystone_utils.tokens.TokenConf') def test_check_permissions_token_valid(self, mock_get_token_conf, mock_is_token_valid): setattr(conf.authentication, 'enabled', True) mock_get_token_conf.return_value = 123 @@ -25,8 +26,8 @@ class TestUtil(FunctionalTest): is_permitted = authentication.check_permissions(conf, 'asher', 0) self.assertEqual(is_permitted, True) - @mock.patch('keystone_utils.tokens.is_token_valid') - @mock.patch('keystone_utils.tokens.TokenConf') + @mock.patch('orm.common.client.keystone.keystone_utils.tokens.is_token_valid') + @mock.patch('orm.common.client.keystone.keystone_utils.tokens.TokenConf') def test_check_permissions_token_invalid(self, mock_get_token_conf, mock_is_token_valid): setattr(conf.authentication, 'enabled', True) mock_get_token_conf.return_value = 123 @@ -34,8 +35,8 @@ class TestUtil(FunctionalTest): is_permitted = authentication.check_permissions(conf, 'asher', 0) self.assertEqual(is_permitted, False) - @mock.patch('keystone_utils.tokens.is_token_valid') - @mock.patch('keystone_utils.tokens.TokenConf') + @mock.patch('orm.common.client.keystone.keystone_utils.tokens.is_token_valid') + @mock.patch('orm.common.client.keystone.keystone_utils.tokens.TokenConf') def test_check_permissions_disabled(self, mock_get_token_conf, mock_is_token_valid): setattr(conf.authentication, 'enabled', False) mock_get_token_conf.return_value = 123 @@ -43,8 +44,8 @@ class TestUtil(FunctionalTest): is_permitted = authentication.check_permissions(conf, 'asher', 0) self.assertEqual(is_permitted, True) - @mock.patch('keystone_utils.tokens.is_token_valid') - @mock.patch('keystone_utils.tokens.TokenConf') + @mock.patch('orm.common.client.keystone.keystone_utils.tokens.is_token_valid') + @mock.patch('orm.common.client.keystone.keystone_utils.tokens.TokenConf') def test_check_permissions_is_token_valid_breaks(self, mock_get_token_conf, mock_is_token_valid): setattr(conf.authentication, 'enabled', True) mock_is_token_valid.side_effect = Exception('boom') diff --git a/orm/services/customer_manager/cms_rest/tests/test_configuration.py b/orm/tests/unit/cms/test_configuration.py similarity index 80% rename from orm/services/customer_manager/cms_rest/tests/test_configuration.py rename to orm/tests/unit/cms/test_configuration.py index e6b7cc04..a4f0dc0e 100755 --- a/orm/services/customer_manager/cms_rest/tests/test_configuration.py +++ b/orm/tests/unit/cms/test_configuration.py @@ -1,12 +1,13 @@ """Get configuration module unittests.""" -from cms_rest.tests import FunctionalTest from mock import patch +from orm.tests.unit.cms import FunctionalTest + class TestGetConfiguration(FunctionalTest): """Main get configuration test case.""" - @patch('orm_common.utils.utils.report_config') + @patch('orm.common.orm_common.utils.utils.report_config') def test_get_configuration_success(self, mock_report): """Test get_configuration returns the expected value on success.""" mock_report.return_value = '12345' diff --git a/orm/services/customer_manager/cms_rest/tests/rest/test_customer.py b/orm/tests/unit/cms/test_customer.py similarity index 98% rename from orm/services/customer_manager/cms_rest/tests/rest/test_customer.py rename to orm/tests/unit/cms/test_customer.py index 70816a7b..cd2ddb30 100755 --- a/orm/services/customer_manager/cms_rest/tests/rest/test_customer.py +++ b/orm/tests/unit/cms/test_customer.py @@ -1,9 +1,9 @@ import requests -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, test_utils +from orm.services.customer_manager.cms_rest.controllers.v1.orm.customer import root +from orm.services.customer_manager.cms_rest.logic.error_base import ErrorStatus +from orm.services.customer_manager.cms_rest.model import Models +from orm.tests.unit.cms import FunctionalTest, test_utils import mock import sqlalchemy from wsme.exc import ClientSideError diff --git a/orm/services/customer_manager/cms_rest/tests/logic/test_customer_logic.py b/orm/tests/unit/cms/test_customer_logic.py similarity index 98% rename from orm/services/customer_manager/cms_rest/tests/logic/test_customer_logic.py rename to orm/tests/unit/cms/test_customer_logic.py index 52dfd054..c479489e 100755 --- a/orm/services/customer_manager/cms_rest/tests/logic/test_customer_logic.py +++ b/orm/tests/unit/cms/test_customer_logic.py @@ -1,8 +1,8 @@ -from cms_rest.data.sql_alchemy import models as sql_models -from cms_rest.logic import customer_logic -from cms_rest.logic.error_base import ErrorStatus -import cms_rest.model.Models as models -from cms_rest.tests import FunctionalTest +from orm.services.customer_manager.cms_rest.data.sql_alchemy import models as sql_models +from orm.services.customer_manager.cms_rest.logic import customer_logic +from orm.services.customer_manager.cms_rest.logic.error_base import ErrorStatus +import orm.services.customer_manager.cms_rest.model.Models as models +from orm.tests.unit.cms import FunctionalTest import mock diff --git a/orm/services/customer_manager/cms_rest/tests/rest/test_enable.py b/orm/tests/unit/cms/test_enable.py similarity index 91% rename from orm/services/customer_manager/cms_rest/tests/rest/test_enable.py rename to orm/tests/unit/cms/test_enable.py index f74d816e..bef738b6 100755 --- a/orm/services/customer_manager/cms_rest/tests/rest/test_enable.py +++ b/orm/tests/unit/cms/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 +from orm.services.customer_manager.cms_rest.controllers.v1.orm.customer import enabled +from orm.services.customer_manager.cms_rest.logic.error_base import ErrorStatus +from orm.services.customer_manager.cms_rest.model import Models +from orm.tests.unit.cms import FunctionalTest customer_logic_mock = None diff --git a/orm/services/customer_manager/cms_rest/tests/rest/test_metadata.py b/orm/tests/unit/cms/test_metadata.py similarity index 96% rename from orm/services/customer_manager/cms_rest/tests/rest/test_metadata.py rename to orm/tests/unit/cms/test_metadata.py index e61b1848..2b801753 100755 --- a/orm/services/customer_manager/cms_rest/tests/rest/test_metadata.py +++ b/orm/tests/unit/cms/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 +from orm.services.customer_manager.cms_rest.controllers.v1.orm.customer import metadata +from orm.services.customer_manager.cms_rest.logic.error_base import ErrorStatus +from orm.services.customer_manager.cms_rest.model import Models +from orm.tests.unit.cms import FunctionalTest metadata_logic_mock = None diff --git a/orm/services/customer_manager/cms_rest/tests/test_models.py b/orm/tests/unit/cms/test_models.py similarity index 91% rename from orm/services/customer_manager/cms_rest/tests/test_models.py rename to orm/tests/unit/cms/test_models.py index a8150028..8cdf16de 100755 --- a/orm/services/customer_manager/cms_rest/tests/test_models.py +++ b/orm/tests/unit/cms/test_models.py @@ -1,7 +1,8 @@ -from cms_rest.model import Models as models -from cms_rest.tests import FunctionalTest import mock +from orm.services.customer_manager.cms_rest.model import Models as models +from orm.tests.unit.cms import FunctionalTest + GROUP_REGIONS = [ "DPK", "SNA1", diff --git a/orm/services/customer_manager/cms_rest/tests/test_rds_proxy.py b/orm/tests/unit/cms/test_rds_proxy.py similarity index 79% rename from orm/services/customer_manager/cms_rest/tests/test_rds_proxy.py rename to orm/tests/unit/cms/test_rds_proxy.py index 0e318a14..52510d93 100755 --- a/orm/services/customer_manager/cms_rest/tests/test_rds_proxy.py +++ b/orm/tests/unit/cms/test_rds_proxy.py @@ -1,10 +1,11 @@ -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 +from orm.services.customer_manager.cms_rest.data.sql_alchemy import models +from orm.services.customer_manager.cms_rest.logic.error_base import ErrorStatus +from orm.services.customer_manager.cms_rest import rds_proxy +from orm.tests.unit.cms import FunctionalTest + class Response: def __init__(self, status_code, content): @@ -22,7 +23,7 @@ class TestUtil(FunctionalTest): @mock.patch.object(rds_proxy, 'request') @mock.patch('requests.post') - @log_capture('cms_rest.rds_proxy') + @log_capture('orm.services.customer_manager.cms_rest.rds_proxy') def test_send_good(self, mock_post, mock_request, l): resp = Response(200, 'my content') mock_post.return_value = resp @@ -33,7 +34,7 @@ class TestUtil(FunctionalTest): @mock.patch.object(rds_proxy, 'request') @mock.patch('requests.post') - @log_capture('cms_rest.rds_proxy') + @log_capture('orm.services.customer_manager.cms_rest.rds_proxy') def test_bad_status(self, mock_post, mock_request, l): resp = Response(400, 'my content') mock_post.return_value = resp @@ -43,7 +44,7 @@ class TestUtil(FunctionalTest): @mock.patch.object(rds_proxy, 'request') @mock.patch('requests.post') - @log_capture('cms_rest.rds_proxy') + @log_capture('orm.services.customer_manager.cms_rest.rds_proxy') def test_no_content(self, mock_post, mock_request, l): resp = Response(200, None) mock_post.return_value = resp diff --git a/orm/services/customer_manager/cms_rest/tests/rest/test_regions.py b/orm/tests/unit/cms/test_regions.py similarity index 96% rename from orm/services/customer_manager/cms_rest/tests/rest/test_regions.py rename to orm/tests/unit/cms/test_regions.py index bf25a702..c205b5b0 100755 --- a/orm/services/customer_manager/cms_rest/tests/rest/test_regions.py +++ b/orm/tests/unit/cms/test_regions.py @@ -1,12 +1,12 @@ -import requests - -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 +import requests from wsme.exc import ClientSideError +from orm.services.customer_manager.cms_rest.controllers.v1.orm.customer import regions +from orm.services.customer_manager.cms_rest.logic.error_base import ErrorStatus +from orm.services.customer_manager.cms_rest.model import Models +from orm.tests.unit.cms import FunctionalTest + customer_logic_mock = None diff --git a/orm/services/customer_manager/cms_rest/tests/rest/test_users.py b/orm/tests/unit/cms/test_users.py similarity index 97% rename from orm/services/customer_manager/cms_rest/tests/rest/test_users.py rename to orm/tests/unit/cms/test_users.py index a93a3011..54166c2e 100755 --- a/orm/services/customer_manager/cms_rest/tests/rest/test_users.py +++ b/orm/tests/unit/cms/test_users.py @@ -1,12 +1,12 @@ -import requests - -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 +import requests from wsme.exc import ClientSideError +from orm.services.customer_manager.cms_rest.controllers.v1.orm.customer import users +from orm.services.customer_manager.cms_rest.logic.error_base import ErrorStatus +from orm.services.customer_manager.cms_rest.model import Models +from orm.tests.unit.cms import FunctionalTest + customer_logic_mock = None diff --git a/orm/services/customer_manager/cms_rest/tests/test_utils.py b/orm/tests/unit/cms/test_utils.py similarity index 100% rename from orm/services/customer_manager/cms_rest/tests/test_utils.py rename to orm/tests/unit/cms/test_utils.py