From 92590ca7434d19004c66ce1f2115bf861f99b99b Mon Sep 17 00:00:00 2001 From: Nicholas Jones Date: Wed, 30 Aug 2017 09:30:01 -0500 Subject: [PATCH] Move ims tests to top level folder Moves unit tests under the ims directory to the root test directory Change-Id: Idc8e356ce74970bacf16c3046b72e57fe9cbe5eb --- .../fang/resource_provider_register.py | 6 +-- orm/services/image_manager/ims/app.py | 9 ++-- .../image_manager/ims/controllers/__init__.py | 6 +-- .../image_manager/ims/controllers/root.py | 2 +- .../ims/controllers/v1/orm/configuration.py | 5 ++- .../controllers/v1/orm/images/customers.py | 13 +++--- .../ims/controllers/v1/orm/images/enabled.py | 13 +++--- .../ims/controllers/v1/orm/images/images.py | 19 ++++---- .../ims/controllers/v1/orm/images/metadata.py | 13 +++--- .../ims/controllers/v1/orm/images/regions.py | 15 ++++--- .../ims/controllers/v1/orm/orm.py | 9 ++-- .../image_manager/ims/controllers/v1/v1.py | 5 ++- .../ims/di_providers/prod_providers.py | 10 ++--- .../image_manager/ims/logic/image_logic.py | 14 +++--- .../image_manager/ims/logic/metadata_logic.py | 6 +-- .../persistency/sql_alchemy/data_manager.py | 5 ++- .../ims/persistency/sql_alchemy/db_models.py | 8 ++-- .../sql_alchemy/image/image_record.py | 8 ++-- .../persistency/sql_alchemy/infra/record.py | 2 +- .../ims/persistency/wsme/models.py | 10 ++--- .../image_manager/ims/proxies/rds_proxy.py | 7 +-- .../image_manager/ims/utils/authentication.py | 7 +-- .../ims/tests => tests/unit/ims}/__init__.py | 0 .../ims/tests => tests/unit/ims}/config.py | 8 ++-- .../unit/ims}/controllers/__init__.py | 0 .../unit/ims}/controllers/v1/__init__.py | 0 .../unit/ims}/controllers/v1/orm/__init__.py | 0 .../controllers/v1/orm/images/__init__.py | 0 .../v1/orm/images/test_customers.py | 11 ++--- .../controllers/v1/orm/images/test_enabled.py | 11 ++--- .../controllers/v1/orm/images/test_images.py | 11 ++--- .../v1/orm/images/test_metadata.py | 5 ++- .../controllers/v1/orm/images/test_regions.py | 11 ++--- .../unit/ims}/controllers/v1/orm/test_logs.py | 2 +- .../unit/ims}/logic/__init__.py | 0 .../unit/ims}/logic/test_image_logic.py | 45 ++++++------------- .../unit/ims}/logic/test_meta_data.py | 9 ++-- .../unit/ims}/persistency/__init__.py | 0 .../ims}/persistency/sql_alchemy/__init__.py | 0 .../sql_alchemy/images/__init__.py | 0 .../sql_alchemy/images/test_image_record.py | 7 +-- .../unit/ims}/proxies/__init__.py | 0 .../unit/ims}/proxies/rds_proxy.py | 0 .../unit/ims}/simple_hook_mock.py | 0 .../tests => tests/unit/ims}/test_models.py | 5 ++- 45 files changed, 161 insertions(+), 156 deletions(-) rename orm/{services/image_manager/ims/tests => tests/unit/ims}/__init__.py (100%) rename orm/{services/image_manager/ims/tests => tests/unit/ims}/config.py (91%) rename orm/{services/image_manager/ims/tests => tests/unit/ims}/controllers/__init__.py (100%) rename orm/{services/image_manager/ims/tests => tests/unit/ims}/controllers/v1/__init__.py (100%) rename orm/{services/image_manager/ims/tests => tests/unit/ims}/controllers/v1/orm/__init__.py (100%) rename orm/{services/image_manager/ims/tests => tests/unit/ims}/controllers/v1/orm/images/__init__.py (100%) rename orm/{services/image_manager/ims/tests => tests/unit/ims}/controllers/v1/orm/images/test_customers.py (94%) rename orm/{services/image_manager/ims/tests => tests/unit/ims}/controllers/v1/orm/images/test_enabled.py (90%) rename orm/{services/image_manager/ims/tests => tests/unit/ims}/controllers/v1/orm/images/test_images.py (96%) rename orm/{services/image_manager/ims/tests => tests/unit/ims}/controllers/v1/orm/images/test_metadata.py (95%) rename orm/{services/image_manager/ims/tests => tests/unit/ims}/controllers/v1/orm/images/test_regions.py (94%) rename orm/{services/image_manager/ims/tests => tests/unit/ims}/controllers/v1/orm/test_logs.py (97%) rename orm/{services/image_manager/ims/tests => tests/unit/ims}/logic/__init__.py (100%) rename orm/{services/image_manager/ims/tests => tests/unit/ims}/logic/test_image_logic.py (94%) rename orm/{services/image_manager/ims/tests => tests/unit/ims}/logic/test_meta_data.py (86%) rename orm/{services/image_manager/ims/tests => tests/unit/ims}/persistency/__init__.py (100%) rename orm/{services/image_manager/ims/tests => tests/unit/ims}/persistency/sql_alchemy/__init__.py (100%) rename orm/{services/image_manager/ims/tests => tests/unit/ims}/persistency/sql_alchemy/images/__init__.py (100%) rename orm/{services/image_manager/ims/tests => tests/unit/ims}/persistency/sql_alchemy/images/test_image_record.py (96%) rename orm/{services/image_manager/ims/tests => tests/unit/ims}/proxies/__init__.py (100%) rename orm/{services/image_manager/ims/tests => tests/unit/ims}/proxies/rds_proxy.py (100%) rename orm/{services/image_manager/ims/tests => tests/unit/ims}/simple_hook_mock.py (100%) rename orm/{services/image_manager/ims/tests => tests/unit/ims}/test_models.py (88%) 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 bc08dfa1..1a7e3fbf 100755 --- a/orm/common/orm_common/injector/fang/resource_provider_register.py +++ b/orm/common/orm_common/injector/fang/resource_provider_register.py @@ -1,7 +1,7 @@ from functools import partial -from .errors import (FangError, ProviderAlreadyRegisteredError, - ProviderNotFoundError) +from orm.common.orm_common.injector.fang.errors import (FangError, ProviderAlreadyRegisteredError, + ProviderNotFoundError) class ResourceProviderRegister: @@ -10,7 +10,7 @@ class ResourceProviderRegister: # Maps resource names to a provider self.resource_providers = {} - def register(self, resource_name, provider=None, allow_override=False): + def register(self, resource_name, provider=None, allow_override=True): if provider is None: # Give a partial usable as a decorator return partial( diff --git a/orm/services/image_manager/ims/app.py b/orm/services/image_manager/ims/app.py index 7b2ed883..2b13ffbe 100755 --- a/orm/services/image_manager/ims/app.py +++ b/orm/services/image_manager/ims/app.py @@ -1,9 +1,10 @@ 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 orm.common.orm_common.policy import policy +from orm.common.orm_common.utils.utils import set_utils_conf +from orm.services.image_manager.ims.logger import get_logger +from orm.services.image_manager.ims.utils import authentication as auth + from pecan import conf, make_app from pecan.commands import CommandRunner diff --git a/orm/services/image_manager/ims/controllers/__init__.py b/orm/services/image_manager/ims/controllers/__init__.py index c705b745..b45e7e79 100755 --- a/orm/services/image_manager/ims/controllers/__init__.py +++ b/orm/services/image_manager/ims/controllers/__init__.py @@ -1,9 +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 +from orm.common.orm_common.injector import injector +import orm.services.image_manager.ims.di_providers as di_providers +from orm.services.image_manager.ims.logger import get_logger 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 94d02091..4ae2e26d 100755 --- a/orm/services/image_manager/ims/controllers/root.py +++ b/orm/services/image_manager/ims/controllers/root.py @@ -1,4 +1,4 @@ -from ims.controllers.v1.v1 import V1Controller +from orm.services.image_manager.ims.controllers.v1.v1 import V1Controller from pecan import conf, expose from webob.exc import status_map 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 c619f82d..e97be2b8 100755 --- a/orm/services/image_manager/ims/controllers/v1/orm/configuration.py +++ b/orm/services/image_manager/ims/controllers/v1/orm/configuration.py @@ -1,8 +1,9 @@ """Configuration rest API input module.""" - +from __future__ import absolute_import 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/image_manager/ims/controllers/v1/orm/images/customers.py b/orm/services/image_manager/ims/controllers/v1/orm/images/customers.py index c404be1d..0e5ad066 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,9 +1,10 @@ -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 orm.common.orm_common.injector import injector +from orm.common.orm_common.utils import api_error_utils as err_utils +from orm.services.image_manager.ims.logger import get_logger +from orm.services.image_manager.ims.logic.error_base import ErrorStatus +from orm.services.image_manager.ims.persistency.wsme.models import CustomerWrapper, ImageWrapper +from orm.services.image_manager.ims.utils import authentication as auth + from pecan import request, rest from wsmeext.pecan import wsexpose 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 789622c7..8106dc50 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,11 +1,12 @@ """Status (activate/deactivate) Image rest API input module.""" -from ims.logger import get_logger -from ims.logic.error_base import ErrorStatus -from ims.persistency.wsme.models import Enabled, 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 orm.common.orm_common.injector import injector +from orm.common.orm_common.utils import api_error_utils as err_utils +from orm.services.image_manager.ims.logger import get_logger +from orm.services.image_manager.ims.logic.error_base import ErrorStatus +from orm.services.image_manager.ims.persistency.wsme.models import Enabled, ImageWrapper +from orm.services.image_manager.ims.utils import authentication as auth + from pecan import request, rest from wsmeext.pecan import wsexpose 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 fb89cfb3..42ef8f55 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,14 +1,15 @@ import oslo_db -from ims.controllers.v1.orm.images.customers import CustomerController -from ims.controllers.v1.orm.images.enabled import EnabledController -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 orm.common.orm_common.injector import injector +from orm.common.orm_common.utils import api_error_utils as err_utils +from orm.services.image_manager.ims.controllers.v1.orm.images.customers import CustomerController +from orm.services.image_manager.ims.controllers.v1.orm.images.enabled import EnabledController +from orm.services.image_manager.ims.controllers.v1.orm.images.regions import RegionController +from orm.services.image_manager.ims.logger import get_logger +from orm.services.image_manager.ims.logic.error_base import ErrorStatus +from orm.services.image_manager.ims.persistency.wsme.models import ImageSummaryResponse, ImageWrapper +from orm.services.image_manager.ims.utils import authentication as auth + from pecan import request, rest from wsmeext.pecan import wsexpose 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 48e5f5a7..7c7e1fb4 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,9 +1,10 @@ -from ims.logger import get_logger -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 orm.common.orm_common.injector import injector +from orm.common.orm_common.utils import api_error_utils as err_utils +from orm.services.image_manager.ims.logger import get_logger +from orm.services.image_manager.ims.logic.error_base import ErrorStatus +from orm.services.image_manager.ims.persistency.wsme.models import MetadataWrapper +from orm.services.image_manager.ims.utils import authentication as auth + from pecan import request, rest from wsmeext.pecan import wsexpose 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 8ba4c66f..f90ca3d3 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,10 +1,11 @@ -from ims.controllers.v1.orm.images.metadata import MetadataController -from ims.logger import get_logger -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 orm.common.orm_common.injector import injector +from orm.common.orm_common.utils import api_error_utils as err_utils +from orm.services.image_manager.ims.controllers.v1.orm.images.metadata import MetadataController +from orm.services.image_manager.ims.logger import get_logger +from orm.services.image_manager.ims.logic.error_base import ErrorStatus +from orm.services.image_manager.ims.persistency.wsme.models import RegionWrapper +from orm.services.image_manager.ims.utils import authentication as auth + from pecan import request, rest from wsmeext.pecan import wsexpose diff --git a/orm/services/image_manager/ims/controllers/v1/orm/orm.py b/orm/services/image_manager/ims/controllers/v1/orm/orm.py index 0f648c6b..6c1d5159 100644 --- a/orm/services/image_manager/ims/controllers/v1/orm/orm.py +++ b/orm/services/image_manager/ims/controllers/v1/orm/orm.py @@ -1,6 +1,9 @@ -from ims.controllers.v1.orm.configuration import ConfigurationController -from ims.controllers.v1.orm.images.images import ImageController -from ims.controllers.v1.orm.logs import LogsController +from __future__ import absolute_import + +from orm.services.image_manager.ims.controllers.v1.orm.configuration import ConfigurationController +from orm.services.image_manager.ims.controllers.v1.orm.images.images import ImageController +from orm.services.image_manager.ims.controllers.v1.orm.logs import LogsController + from pecan.rest import RestController diff --git a/orm/services/image_manager/ims/controllers/v1/v1.py b/orm/services/image_manager/ims/controllers/v1/v1.py index 41549fab..83680ff4 100644 --- a/orm/services/image_manager/ims/controllers/v1/v1.py +++ b/orm/services/image_manager/ims/controllers/v1/v1.py @@ -1,4 +1,7 @@ -from ims.controllers.v1.orm.orm import OrmController +from __future__ import absolute_import + +from orm.services.image_manager.ims.controllers.v1.orm.orm import OrmController + from pecan.rest import RestController 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 e8bbe902..435828ec 100644 --- a/orm/services/image_manager/ims/di_providers/prod_providers.py +++ b/orm/services/image_manager/ims/di_providers/prod_providers.py @@ -1,10 +1,10 @@ import requests -from audit_client.api import audit -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 +from orm.common.client.audit.audit_client.api import audit +from orm.common.orm_common.utils import utils +from orm.services.image_manager.ims.logic import image_logic, metadata_logic +from orm.services.image_manager.ims.persistency.sql_alchemy.data_manager import DataManager +from orm.services.image_manager.ims.proxies import rds_proxy providers = [ ('rds_proxy', rds_proxy), diff --git a/orm/services/image_manager/ims/logic/image_logic.py b/orm/services/image_manager/ims/logic/image_logic.py index 88d5e25b..52677740 100755 --- a/orm/services/image_manager/ims/logic/image_logic.py +++ b/orm/services/image_manager/ims/logic/image_logic.py @@ -1,12 +1,12 @@ import time -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 +from orm.common.orm_common.injector import injector +from orm.services.image_manager.ims.logger import get_logger +from orm.services.image_manager.ims.logic.error_base import ErrorStatus, NotFoundError +from orm.services.image_manager.ims.persistency.sql_alchemy.db_models import ImageCustomer, ImageRegion +from orm.services.image_manager.ims.persistency.wsme.models import (ImageSummary, ImageSummaryResponse, + ImageWrapper, RegionWrapper) +from orm.services.image_manager.ims.utils import utils as ImsUtils LOG = get_logger(__name__) diff --git a/orm/services/image_manager/ims/logic/metadata_logic.py b/orm/services/image_manager/ims/logic/metadata_logic.py index 5b42f958..38feb0bb 100644 --- a/orm/services/image_manager/ims/logic/metadata_logic.py +++ b/orm/services/image_manager/ims/logic/metadata_logic.py @@ -1,6 +1,6 @@ -from ims.logger import get_logger -from ims.logic.error_base import ErrorStatus -from orm_common.injector import injector +from orm.common.orm_common.injector import injector +from orm.services.image_manager.ims.logger import get_logger +from orm.services.image_manager.ims.logic.error_base import ErrorStatus 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 b637d292..98340872 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,5 +1,6 @@ -from ims.logger import get_logger -from ims.persistency.sql_alchemy.image.image_record import ImageRecord +from orm.services.image_manager.ims.logger import get_logger +from orm.services.image_manager.ims.persistency.sql_alchemy.image.image_record import ImageRecord + from oslo_db.sqlalchemy import session as db_session from pecan import conf from sqlalchemy.event import listen 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 a8932005..9e704d2b 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,10 +9,10 @@ # For more information visit http://www.igenxsoft.com ### -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 orm.services.image_manager.ims.logger import get_logger +from orm.services.image_manager.ims.logic.error_base import ErrorStatus, NotFoundError +from orm.common.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, 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 c115d7c3..e1393be7 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,7 +1,7 @@ -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 +from orm.services.image_manager.ims.logger import get_logger +from orm.services.image_manager.ims.persistency.sql_alchemy.db_models import (Image, ImageCustomer, + ImageRegion) +from orm.services.image_manager.ims.persistency.sql_alchemy.infra.record import Record LOG = get_logger(__name__) diff --git a/orm/services/image_manager/ims/persistency/sql_alchemy/infra/record.py b/orm/services/image_manager/ims/persistency/sql_alchemy/infra/record.py index 69327707..ff0051b2 100755 --- a/orm/services/image_manager/ims/persistency/sql_alchemy/infra/record.py +++ b/orm/services/image_manager/ims/persistency/sql_alchemy/infra/record.py @@ -1,4 +1,4 @@ -from ims.logger import get_logger +from orm.services.image_manager.ims.logger import get_logger 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 ef8aea03..728f9324 100755 --- a/orm/services/image_manager/ims/persistency/wsme/models.py +++ b/orm/services/image_manager/ims/persistency/wsme/models.py @@ -1,9 +1,9 @@ """Image model module.""" -from ims.logic.error_base import ErrorStatus -from ims.persistency.sql_alchemy import db_models -from ims.persistency.wsme.base import Model -from orm_common.utils.cross_api_utils import (get_regions_of_group, - set_utils_conf) +from orm.services.image_manager.ims.logic.error_base import ErrorStatus +from orm.services.image_manager.ims.persistency.sql_alchemy import db_models +from orm.services.image_manager.ims.persistency.wsme.base import Model +from orm.common.orm_common.utils.cross_api_utils import (get_regions_of_group, + set_utils_conf) from pecan import conf, request import wsme diff --git a/orm/services/image_manager/ims/proxies/rds_proxy.py b/orm/services/image_manager/ims/proxies/rds_proxy.py index 4156eed0..0728158c 100755 --- a/orm/services/image_manager/ims/proxies/rds_proxy.py +++ b/orm/services/image_manager/ims/proxies/rds_proxy.py @@ -1,9 +1,10 @@ import json import pprint -from ims.logger import get_logger -from ims.logic.error_base import ErrorStatus -from orm_common.injector import injector +from orm.common.orm_common.injector import injector +from orm.services.image_manager.ims.logger import get_logger +from orm.services.image_manager.ims.logic.error_base import ErrorStatus + from pecan import conf, request di = injector.get_di() diff --git a/orm/services/image_manager/ims/utils/authentication.py b/orm/services/image_manager/ims/utils/authentication.py index 3bf4a836..6036dd85 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 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/image_manager/ims/tests/__init__.py b/orm/tests/unit/ims/__init__.py similarity index 100% rename from orm/services/image_manager/ims/tests/__init__.py rename to orm/tests/unit/ims/__init__.py diff --git a/orm/services/image_manager/ims/tests/config.py b/orm/tests/unit/ims/config.py similarity index 91% rename from orm/services/image_manager/ims/tests/config.py rename to orm/tests/unit/ims/config.py index 369e24be..8e10bea3 100755 --- a/orm/services/image_manager/ims/tests/config.py +++ b/orm/tests/unit/ims/config.py @@ -1,4 +1,4 @@ -from ims.tests.simple_hook_mock import SimpleHookMock +from orm.tests.unit.ims.simple_hook_mock import SimpleHookMock global SimpleHookMock @@ -11,8 +11,8 @@ server = { # Pecan Application Configurations app = { - 'root': 'ims.controllers.root.RootController', - 'modules': ['ims'], + 'root': 'orm.services.image_manager.ims.controllers.root.RootController', + 'modules': ['orm.services.image_manager.ims'], 'static_root': '%(confdir)s/public', 'template_path': '%(confdir)s/ims/templates', 'debug': True, @@ -101,5 +101,5 @@ authentication = { "tenant_name": "admin", "keystone_version": "2.0", "token_role": "admin", - "policy_file": "ims/etc/policy.json" + "policy_file": "orm/services/image_manager/ims/etc/policy.json" } diff --git a/orm/services/image_manager/ims/tests/controllers/__init__.py b/orm/tests/unit/ims/controllers/__init__.py similarity index 100% rename from orm/services/image_manager/ims/tests/controllers/__init__.py rename to orm/tests/unit/ims/controllers/__init__.py diff --git a/orm/services/image_manager/ims/tests/controllers/v1/__init__.py b/orm/tests/unit/ims/controllers/v1/__init__.py similarity index 100% rename from orm/services/image_manager/ims/tests/controllers/v1/__init__.py rename to orm/tests/unit/ims/controllers/v1/__init__.py diff --git a/orm/services/image_manager/ims/tests/controllers/v1/orm/__init__.py b/orm/tests/unit/ims/controllers/v1/orm/__init__.py similarity index 100% rename from orm/services/image_manager/ims/tests/controllers/v1/orm/__init__.py rename to orm/tests/unit/ims/controllers/v1/orm/__init__.py diff --git a/orm/services/image_manager/ims/tests/controllers/v1/orm/images/__init__.py b/orm/tests/unit/ims/controllers/v1/orm/images/__init__.py similarity index 100% rename from orm/services/image_manager/ims/tests/controllers/v1/orm/images/__init__.py rename to orm/tests/unit/ims/controllers/v1/orm/images/__init__.py diff --git a/orm/services/image_manager/ims/tests/controllers/v1/orm/images/test_customers.py b/orm/tests/unit/ims/controllers/v1/orm/images/test_customers.py similarity index 94% rename from orm/services/image_manager/ims/tests/controllers/v1/orm/images/test_customers.py rename to orm/tests/unit/ims/controllers/v1/orm/images/test_customers.py index 6ecba533..d2c3a327 100755 --- a/orm/services/image_manager/ims/tests/controllers/v1/orm/images/test_customers.py +++ b/orm/tests/unit/ims/controllers/v1/orm/images/test_customers.py @@ -1,11 +1,12 @@ import json -from ims.controllers.v1.orm.images import customers -from ims.logic.error_base import ErrorStatus -from ims.persistency.wsme.models import ImageWrapper -from ims.tests import FunctionalTest +from orm.common.orm_common.injector import injector +from orm.services.image_manager.ims.controllers.v1.orm.images import customers +from orm.services.image_manager.ims.logic.error_base import ErrorStatus +from orm.services.image_manager.ims.persistency.wsme.models import ImageWrapper +from orm.tests.unit.ims import FunctionalTest + import mock -from orm_common.injector import injector from wsme.exc import ClientSideError utils_mock = None diff --git a/orm/services/image_manager/ims/tests/controllers/v1/orm/images/test_enabled.py b/orm/tests/unit/ims/controllers/v1/orm/images/test_enabled.py similarity index 90% rename from orm/services/image_manager/ims/tests/controllers/v1/orm/images/test_enabled.py rename to orm/tests/unit/ims/controllers/v1/orm/images/test_enabled.py index 688baef7..19c26ff7 100755 --- a/orm/services/image_manager/ims/tests/controllers/v1/orm/images/test_enabled.py +++ b/orm/tests/unit/ims/controllers/v1/orm/images/test_enabled.py @@ -1,11 +1,12 @@ import json -from ims.controllers.v1.orm.images import enabled -from ims.logic.error_base import ErrorStatus -from ims.persistency.wsme.models import ImageWrapper -from ims.tests import FunctionalTest +from orm.common.orm_common.injector import injector +from orm.services.image_manager.ims.controllers.v1.orm.images import enabled +from orm.services.image_manager.ims.logic.error_base import ErrorStatus +from orm.services.image_manager.ims.persistency.wsme.models import ImageWrapper +from orm.tests.unit.ims import FunctionalTest + 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/tests/unit/ims/controllers/v1/orm/images/test_images.py similarity index 96% rename from orm/services/image_manager/ims/tests/controllers/v1/orm/images/test_images.py rename to orm/tests/unit/ims/controllers/v1/orm/images/test_images.py index d5261730..db99dc0a 100755 --- a/orm/services/image_manager/ims/tests/controllers/v1/orm/images/test_images.py +++ b/orm/tests/unit/ims/controllers/v1/orm/images/test_images.py @@ -1,12 +1,13 @@ """Images unittests module.""" import json -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 +from orm.common.orm_common.injector import injector +from orm.services.image_manager.ims.controllers.v1.orm.images import images +from orm.services.image_manager.ims.logic.error_base import ErrorStatus +from orm.services.image_manager.ims.persistency.wsme.models import ImageSummaryResponse, ImageWrapper +from orm.tests.unit.ims import FunctionalTest + import mock -from orm_common.injector import injector from wsme.exc import ClientSideError utils_mock = None diff --git a/orm/services/image_manager/ims/tests/controllers/v1/orm/images/test_metadata.py b/orm/tests/unit/ims/controllers/v1/orm/images/test_metadata.py similarity index 95% rename from orm/services/image_manager/ims/tests/controllers/v1/orm/images/test_metadata.py rename to orm/tests/unit/ims/controllers/v1/orm/images/test_metadata.py index 708811ae..4ad15b8e 100755 --- a/orm/services/image_manager/ims/tests/controllers/v1/orm/images/test_metadata.py +++ b/orm/tests/unit/ims/controllers/v1/orm/images/test_metadata.py @@ -1,7 +1,8 @@ import json -from ims.controllers.v1.orm.images import metadata -from ims.tests import FunctionalTest +from orm.services.image_manager.ims.controllers.v1.orm.images import metadata +from orm.tests.unit.ims import FunctionalTest + import mock from wsme.exc import ClientSideError diff --git a/orm/services/image_manager/ims/tests/controllers/v1/orm/images/test_regions.py b/orm/tests/unit/ims/controllers/v1/orm/images/test_regions.py similarity index 94% rename from orm/services/image_manager/ims/tests/controllers/v1/orm/images/test_regions.py rename to orm/tests/unit/ims/controllers/v1/orm/images/test_regions.py index 5aaf2a24..9429aada 100755 --- a/orm/services/image_manager/ims/tests/controllers/v1/orm/images/test_regions.py +++ b/orm/tests/unit/ims/controllers/v1/orm/images/test_regions.py @@ -1,11 +1,12 @@ import json -from ims.controllers.v1.orm.images import regions -from ims.logic.error_base import ErrorStatus -from ims.persistency.wsme.models import RegionWrapper -from ims.tests import FunctionalTest +from orm.common.orm_common.injector import injector +from orm.services.image_manager.ims.controllers.v1.orm.images import regions +from orm.services.image_manager.ims.logic.error_base import ErrorStatus +from orm.services.image_manager.ims.persistency.wsme.models import RegionWrapper +from orm.tests.unit.ims import FunctionalTest + import mock -from orm_common.injector import injector from wsme.exc import ClientSideError utils_mock = None diff --git a/orm/services/image_manager/ims/tests/controllers/v1/orm/test_logs.py b/orm/tests/unit/ims/controllers/v1/orm/test_logs.py similarity index 97% rename from orm/services/image_manager/ims/tests/controllers/v1/orm/test_logs.py rename to orm/tests/unit/ims/controllers/v1/orm/test_logs.py index e7cca83e..6672a47f 100755 --- a/orm/services/image_manager/ims/tests/controllers/v1/orm/test_logs.py +++ b/orm/tests/unit/ims/controllers/v1/orm/test_logs.py @@ -1,4 +1,4 @@ -from ims.tests import FunctionalTest +from orm.tests.unit.ims import FunctionalTest class TestLogsController(FunctionalTest): diff --git a/orm/services/image_manager/ims/tests/logic/__init__.py b/orm/tests/unit/ims/logic/__init__.py similarity index 100% rename from orm/services/image_manager/ims/tests/logic/__init__.py rename to orm/tests/unit/ims/logic/__init__.py diff --git a/orm/services/image_manager/ims/tests/logic/test_image_logic.py b/orm/tests/unit/ims/logic/test_image_logic.py similarity index 94% rename from orm/services/image_manager/ims/tests/logic/test_image_logic.py rename to orm/tests/unit/ims/logic/test_image_logic.py index 6686e32c..f1901db0 100755 --- a/orm/services/image_manager/ims/tests/logic/test_image_logic.py +++ b/orm/tests/unit/ims/logic/test_image_logic.py @@ -1,7 +1,8 @@ -from ims.logic import image_logic -from ims.persistency.sql_alchemy.db_models import Image -from ims.persistency.wsme import models -from ims.tests import FunctionalTest +from orm.services.image_manager.ims.logic import image_logic +from orm.services.image_manager.ims.persistency.sql_alchemy.db_models import Image +from orm.services.image_manager.ims.persistency.wsme import models +from orm.tests.unit.ims import FunctionalTest + import mock @@ -92,10 +93,9 @@ class TestImageLogic(FunctionalTest): @mock.patch.object(image_logic.ImsUtils, 'get_server_links', return_value=["ip", "path"]) @mock.patch.object(image_logic, 'di') - @mock.patch.object(image_logic, 'utils') @mock.patch.object(image_logic, 'ImageWrapper') def test_get_image_by_uuid_image_no_status(self, mock_image, - mock_utils, mock_di, mock_links): + mock_di, mock_links): mock_rds_proxy = mock.MagicMock() mock_rds_proxy.get_status.return_value = RDSGetStatus(status_code=404) mock_image.from_db_model.return_value = ImageWrapperTest() @@ -111,13 +111,11 @@ class TestImageLogic(FunctionalTest): @mock.patch.object(image_logic.ImsUtils, 'get_server_links', return_value=["ip", "path"]) @mock.patch.object(image_logic, 'di') - @mock.patch.object(image_logic, 'utils') @mock.patch.object(image_logic, 'ImageWrapper') def test_get_image_by_uuid_image_sanity(self, mock_image, - mock_utils, mock_di, mock_links): + mock_di, mock_links): mock_rds_proxy = mock.MagicMock() mock_rds_proxy.get_status.return_value = RDSGetStatus() - mock_utils.get_resource_status.return_value = {'status': 'Success'} my_get_image = mock.MagicMock() my_get_record = mock.MagicMock() my_get_record.get_record.return_value = my_get_image @@ -183,14 +181,12 @@ class TestDeleteImageLogic(FunctionalTest): class TestUpdateImage(FunctionalTest): """tests for update image.""" - @mock.patch.object(image_logic, 'request') @mock.patch.object(image_logic, 'get_image_by_uuid', return_value=ImageTest(id="image_id")) @mock.patch.object(image_logic, 'send_to_rds_if_needed', return_value=True) @mock.patch.object(image_logic, 'di') def test_update_image_success(self, mock_di, mock_send_to_rds_if_needed, - mock_get_image_by_uuid, request): - request.headers = {'X-RANGER-Requester': "orm_orm"} + mock_get_image_by_uuid): rds_proxy, mock_data_manager = get_data_manager_mock() mock_di.resolver.unpack.return_value = mock_data_manager result = image_logic.update_image(ImageTest(), "imgae_id", @@ -198,13 +194,12 @@ class TestUpdateImage(FunctionalTest): self.assertEqual("image_id", result.id) - @mock.patch.object(image_logic, 'request') @mock.patch.object(image_logic, 'get_image_by_uuid', return_value=ImageTest(id="image_id")) @mock.patch.object(image_logic, 'send_to_rds_if_needed', return_value=True) @mock.patch.object(image_logic, 'di') def test_update_image_notfound(self, mock_di, mock_send_to_rds_if_needed, - mock_get_image_by_uuid, request): + mock_get_image_by_uuid): rds_proxy, mock_data_manager = get_data_manager_mock( mock_sql_image=None) mock_di.resolver.unpack.return_value = mock_data_manager @@ -214,14 +209,13 @@ class TestUpdateImage(FunctionalTest): except Exception as e: self.assertEqual(404, e.status_code) - @mock.patch.object(image_logic, 'request') @mock.patch.object(image_logic, 'get_image_by_uuid', return_value=ImageTest(id="image_id")) @mock.patch.object(image_logic, 'send_to_rds_if_needed', side_effect=Exception("rds not found")) @mock.patch.object(image_logic, 'di') def test_update_image_anyerror(self, mock_di, mock_send_to_rds_if_needed, - mock_get_image_by_uuid, request): + mock_get_image_by_uuid): rds_proxy, mock_data_manager = get_data_manager_mock() mock_di.resolver.unpack.return_value = mock_data_manager @@ -235,14 +229,11 @@ class TestActivateImageLogic(FunctionalTest): @mock.patch.object(image_logic, 'get_image_by_uuid', return_value=ImageTest(**{'status': 'Success'})) @mock.patch.object(image_logic, 'di') - @mock.patch.object(image_logic, 'utils') @mock.patch.object(image_logic, 'ImageWrapper') def test_activate_image_activate_no_activated_image(self, mock_image, - mock_utils, mock_di, mock_by_uuid): - mock_utils.get_resource_status.return_value = {'status': 'Success'} my_enabled = mock.MagicMock() my_enabled.enabled = 0 @@ -261,13 +252,11 @@ class TestActivateImageLogic(FunctionalTest): @mock.patch.object(image_logic, 'get_image_by_uuid', return_value=ImageTest(**{'status': 'Success'})) @mock.patch.object(image_logic, 'di') - @mock.patch.object(image_logic, 'utils') @mock.patch.object(image_logic, 'ImageWrapper') - def test_activate_image_already_activated(self, mock_image, mock_utils, + def test_activate_image_already_activated(self, mock_image, mock_di, mock_get_image_by_uuid): - mock_utils.get_resource_status.return_value = {'status': 'Success'} my_enabled = mock.MagicMock() my_enabled.enabled = 1 @@ -283,12 +272,9 @@ class TestActivateImageLogic(FunctionalTest): self.assertEqual(result.status, 'Success') @mock.patch.object(image_logic, 'di') - @mock.patch.object(image_logic, 'utils') @mock.patch.object(image_logic, 'ImageWrapper') def test_activate_image_image_not_found(self, mock_image, - mock_utils, mock_di): - mock_utils.get_resource_status.return_value = {'status': 'Success'} my_get_image = mock.MagicMock() my_get_image.get_image.return_value = None my_get_record = mock.MagicMock() @@ -303,11 +289,9 @@ class TestActivateImageLogic(FunctionalTest): @mock.patch.object(image_logic, 'LOG') @mock.patch.object(image_logic, 'di') - @mock.patch.object(image_logic, 'utils') @mock.patch.object(image_logic, 'ImageWrapper') def test_activate_image_image_other_exception(self, mock_image, - mock_utils, mock_di, log_moc): my_get_image = mock.MagicMock() @@ -377,11 +361,10 @@ class TestCreateImage(FunctionalTest): def tearDown(self): FunctionalTest.tearDown(self) - @mock.patch.object(image_logic, 'request') @mock.patch.object(image_logic, 'di') @mock.patch.object(image_logic, 'ImageWrapper') @mock.patch.object(image_logic, 'get_image_by_uuid', return_value='test') - def test_create_image_sanity(self, mock_image, mock_di, mock_req, mock_get): + def test_create_image_sanity(self, mock_image, mock_di, mock_req): my_image = mock.MagicMock() my_dm = mock.MagicMock() my_dm.get_record.return_value = my_image @@ -391,11 +374,9 @@ class TestCreateImage(FunctionalTest): result = image_logic.create_image(mock.MagicMock(), 'test1', 'test2') self.assertEqual('test', result) - @mock.patch.object(image_logic, 'request') @mock.patch.object(image_logic, 'di') @mock.patch.object(image_logic, 'ImageWrapper') - def test_create_image_validate_model_failure(self, mock_image, mock_di, - mock_request): + def test_create_image_validate_model_failure(self, mock_image, mock_di): image = mock.MagicMock() image.validate_model.side_effect = ValueError('test') diff --git a/orm/services/image_manager/ims/tests/logic/test_meta_data.py b/orm/tests/unit/ims/logic/test_meta_data.py similarity index 86% rename from orm/services/image_manager/ims/tests/logic/test_meta_data.py rename to orm/tests/unit/ims/logic/test_meta_data.py index 664fbfa5..d5ec6ef0 100755 --- a/orm/services/image_manager/ims/tests/logic/test_meta_data.py +++ b/orm/tests/unit/ims/logic/test_meta_data.py @@ -1,7 +1,8 @@ -from ims.logic import metadata_logic -from ims.persistency.sql_alchemy.db_models import ImageRegion -from ims.persistency.wsme.models import Metadata, MetadataWrapper -from ims.tests import FunctionalTest +from orm.services.image_manager.ims.logic import metadata_logic +from orm.services.image_manager.ims.persistency.sql_alchemy.db_models import ImageRegion +from orm.services.image_manager.ims.persistency.wsme.models import Metadata, MetadataWrapper +from orm.tests.unit.ims import FunctionalTest + import mock diff --git a/orm/services/image_manager/ims/tests/persistency/__init__.py b/orm/tests/unit/ims/persistency/__init__.py similarity index 100% rename from orm/services/image_manager/ims/tests/persistency/__init__.py rename to orm/tests/unit/ims/persistency/__init__.py diff --git a/orm/services/image_manager/ims/tests/persistency/sql_alchemy/__init__.py b/orm/tests/unit/ims/persistency/sql_alchemy/__init__.py similarity index 100% rename from orm/services/image_manager/ims/tests/persistency/sql_alchemy/__init__.py rename to orm/tests/unit/ims/persistency/sql_alchemy/__init__.py diff --git a/orm/services/image_manager/ims/tests/persistency/sql_alchemy/images/__init__.py b/orm/tests/unit/ims/persistency/sql_alchemy/images/__init__.py similarity index 100% rename from orm/services/image_manager/ims/tests/persistency/sql_alchemy/images/__init__.py rename to orm/tests/unit/ims/persistency/sql_alchemy/images/__init__.py diff --git a/orm/services/image_manager/ims/tests/persistency/sql_alchemy/images/test_image_record.py b/orm/tests/unit/ims/persistency/sql_alchemy/images/test_image_record.py similarity index 96% rename from orm/services/image_manager/ims/tests/persistency/sql_alchemy/images/test_image_record.py rename to orm/tests/unit/ims/persistency/sql_alchemy/images/test_image_record.py index 3da27dce..e0d1ebec 100755 --- a/orm/services/image_manager/ims/tests/persistency/sql_alchemy/images/test_image_record.py +++ b/orm/tests/unit/ims/persistency/sql_alchemy/images/test_image_record.py @@ -1,6 +1,7 @@ -from ims.persistency.sql_alchemy import data_manager -from ims.persistency.sql_alchemy.db_models import Image -from ims.tests import FunctionalTest +from orm.services.image_manager.ims.persistency.sql_alchemy import data_manager +from orm.services.image_manager.ims.persistency.sql_alchemy.db_models import Image +from orm.tests.unit.ims import FunctionalTest + import mock diff --git a/orm/services/image_manager/ims/tests/proxies/__init__.py b/orm/tests/unit/ims/proxies/__init__.py similarity index 100% rename from orm/services/image_manager/ims/tests/proxies/__init__.py rename to orm/tests/unit/ims/proxies/__init__.py diff --git a/orm/services/image_manager/ims/tests/proxies/rds_proxy.py b/orm/tests/unit/ims/proxies/rds_proxy.py similarity index 100% rename from orm/services/image_manager/ims/tests/proxies/rds_proxy.py rename to orm/tests/unit/ims/proxies/rds_proxy.py diff --git a/orm/services/image_manager/ims/tests/simple_hook_mock.py b/orm/tests/unit/ims/simple_hook_mock.py similarity index 100% rename from orm/services/image_manager/ims/tests/simple_hook_mock.py rename to orm/tests/unit/ims/simple_hook_mock.py diff --git a/orm/services/image_manager/ims/tests/test_models.py b/orm/tests/unit/ims/test_models.py similarity index 88% rename from orm/services/image_manager/ims/tests/test_models.py rename to orm/tests/unit/ims/test_models.py index cb0d824a..7915c9f6 100644 --- a/orm/services/image_manager/ims/tests/test_models.py +++ b/orm/tests/unit/ims/test_models.py @@ -1,5 +1,6 @@ -from ims.persistency.wsme import models -from ims.tests import FunctionalTest +from orm.services.image_manager.ims.persistency.wsme import models +from orm.tests.unit.ims import FunctionalTest + import mock GROUP_REGIONS = [