From c86c404c31c63509b14add752aa8bc3929dec0d4 Mon Sep 17 00:00:00 2001 From: Nicholas Jones Date: Tue, 22 Aug 2017 13:10:08 -0500 Subject: [PATCH] Move flavor_manager tests to top level folder Moves all tests under orm/services/flavor_manager to top level tests folder, and makes changes to get them passing. Change-Id: I6e1bff032a1a90e60529bd0ed42f1c0b822687df --- orm/services/flavor_manager/config.py | 6 ++-- .../flavor_manager/fms_mocks/audit_mock.py | 2 +- .../flavor_manager/fms_mocks/requests_mock.py | 5 ++-- orm/services/flavor_manager/fms_rest/app.py | 9 +++--- .../fms_rest/controllers/__init__.py | 6 ++-- .../fms_rest/controllers/root.py | 3 +- .../controllers/v1/orm/configuration.py | 5 ++-- .../controllers/v1/orm/flavors/flavors.py | 24 ++++++++-------- .../v1/orm/flavors/os_extra_specs.py | 15 ++++++---- .../controllers/v1/orm/flavors/regions.py | 15 ++++++---- .../controllers/v1/orm/flavors/tags.py | 15 ++++++---- .../controllers/v1/orm/flavors/tenants.py | 13 +++++---- .../fms_rest/controllers/v1/orm/orm.py | 9 ++++-- .../fms_rest/controllers/v1/v1.py | 5 +++- .../fms_rest/data/sql_alchemy/data_manager.py | 5 ++-- .../fms_rest/data/sql_alchemy/db_models.py | 5 ++-- .../data/sql_alchemy/flavor/flavor_record.py | 7 +++-- .../flavor_extra_spec_record.py | 4 +-- .../flavor_options/flavor_option_record.py | 4 +-- .../flavor_region/flavor_region_record.py | 4 +-- .../flavor_tags/flavor_tag_record.py | 4 +-- .../flavor_tenant/flavor_tenant_record.py | 4 +-- .../fms_rest/data/wsme/models.py | 9 +++--- .../fms_rest/di_providers/mock_providers.py | 8 +++--- .../fms_rest/di_providers/prod_providers.py | 10 +++---- .../orm_common/injector/injector.py | 2 +- .../orm_common/utils/cross_api_utils.py | 2 +- .../external_mock/orm_common/utils/utils.py | 2 +- .../fms_rest/hooks/service_hooks.py | 5 ++-- .../fms_rest/logic/flavor_logic.py | 16 +++++------ .../fms_rest/proxies/rds_proxy.py | 7 +++-- .../fms_rest/tests/data/__init__.py | 0 .../fms_rest/tests/logic/__init__.py | 0 .../fms_rest/tests/mocks/__init__.py | 0 .../fms_rest/tests/rest/__init__.py | 0 .../fms_rest/utils/authentication.py | 5 ++-- .../flavor_manager/fms_rest/utils/utils.py | 5 ++-- orm/tests/__init__.py | 21 -------------- orm/tests/config.py | 6 ++-- .../tests => tests/unit/fms}/__init__.py | 5 ++-- .../tests => tests/unit/fms}/config.py | 8 +++--- .../unit/fms}/simple_hook_mock.py | 0 .../unit/fms}/test_authentication.py | 23 +++++++-------- .../unit/fms}/test_configuration.py | 5 ++-- .../unit/fms}/test_flavor_logic.py | 28 ++++++++++--------- .../rest => tests/unit/fms}/test_flavors.py | 12 ++++---- .../rest => tests/unit/fms}/test_logs.py | 2 +- .../tests => tests/unit/fms}/test_models.py | 5 ++-- .../unit/fms}/test_os_extra_specs.py | 9 +++--- .../unit/fms}/test_rds_proxy.py | 13 +++++---- .../rest => tests/unit/fms}/test_regions.py | 12 ++++---- .../rest => tests/unit/fms}/test_tags.py | 9 +++--- .../rest => tests/unit/fms}/test_tenants.py | 9 +++--- .../tests => tests/unit/fms}/test_utils.py | 0 .../unit/fms}/test_wsme_models.py | 18 ++++++------ 55 files changed, 223 insertions(+), 202 deletions(-) delete mode 100644 orm/services/flavor_manager/fms_rest/tests/data/__init__.py delete mode 100644 orm/services/flavor_manager/fms_rest/tests/logic/__init__.py delete mode 100644 orm/services/flavor_manager/fms_rest/tests/mocks/__init__.py delete mode 100755 orm/services/flavor_manager/fms_rest/tests/rest/__init__.py rename orm/{services/flavor_manager/fms_rest/tests => tests/unit/fms}/__init__.py (75%) mode change 100644 => 100755 rename orm/{services/flavor_manager/fms_rest/tests => tests/unit/fms}/config.py (93%) rename orm/{services/flavor_manager/fms_rest/tests => tests/unit/fms}/simple_hook_mock.py (100%) rename orm/{services/flavor_manager/fms_rest/tests => tests/unit/fms}/test_authentication.py (68%) rename orm/{services/flavor_manager/fms_rest/tests => tests/unit/fms}/test_configuration.py (80%) rename orm/{services/flavor_manager/fms_rest/tests/logic => tests/unit/fms}/test_flavor_logic.py (97%) rename orm/{services/flavor_manager/fms_rest/tests/rest => tests/unit/fms}/test_flavors.py (97%) rename orm/{services/flavor_manager/fms_rest/tests/rest => tests/unit/fms}/test_logs.py (95%) rename orm/{services/flavor_manager/fms_rest/tests => tests/unit/fms}/test_models.py (88%) rename orm/{services/flavor_manager/fms_rest/tests/rest => tests/unit/fms}/test_os_extra_specs.py (96%) rename orm/{services/flavor_manager/fms_rest/tests => tests/unit/fms}/test_rds_proxy.py (79%) rename orm/{services/flavor_manager/fms_rest/tests/rest => tests/unit/fms}/test_regions.py (92%) rename orm/{services/flavor_manager/fms_rest/tests/rest => tests/unit/fms}/test_tags.py (97%) rename orm/{services/flavor_manager/fms_rest/tests/rest => tests/unit/fms}/test_tenants.py (94%) rename orm/{services/flavor_manager/fms_rest/tests => tests/unit/fms}/test_utils.py (100%) rename orm/{services/flavor_manager/fms_rest/tests/data => tests/unit/fms}/test_wsme_models.py (84%) diff --git a/orm/services/flavor_manager/config.py b/orm/services/flavor_manager/config.py index 0f664843..1ecf0abd 100755 --- a/orm/services/flavor_manager/config.py +++ b/orm/services/flavor_manager/config.py @@ -1,6 +1,6 @@ -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 +from orm.common.orm_common.hooks.api_error_hook import APIErrorHook +from orm.common.orm_common.hooks.security_headers_hook import SecurityHeadersHook +from orm.services.flavor_manager.fms_rest.hooks.service_hooks import TransIdHook global TransIdHook global APIErrorHook diff --git a/orm/services/flavor_manager/fms_mocks/audit_mock.py b/orm/services/flavor_manager/fms_mocks/audit_mock.py index ce952c75..e9a8f7df 100644 --- a/orm/services/flavor_manager/fms_mocks/audit_mock.py +++ b/orm/services/flavor_manager/fms_mocks/audit_mock.py @@ -1,4 +1,4 @@ -from fms_rest.logger import get_logger +from orm.services.flavor_manager.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 cb9444f1..9c649d26 100644 --- a/orm/services/flavor_manager/fms_mocks/requests_mock.py +++ b/orm/services/flavor_manager/fms_mocks/requests_mock.py @@ -1,8 +1,9 @@ import copy import uuid -from fms_rest.data.sql_alchemy.data_manager import DataManager -from fms_rest.logger import get_logger +from orm.services.flavor_manager.fms_rest.data.sql_alchemy.data_manager import DataManager +from orm.services.flavor_manager.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 d5ab722b..799285fb 100644 --- a/orm/services/flavor_manager/fms_rest/app.py +++ b/orm/services/flavor_manager/fms_rest/app.py @@ -1,9 +1,10 @@ import os -from fms_rest.data import wsme -from fms_rest.logger import get_logger -from fms_rest.utils import authentication -from orm_common.policy import policy +from orm.common.orm_common.policy import policy +from orm.services.flavor_manager.fms_rest.data import wsme +from orm.services.flavor_manager.fms_rest.logger import get_logger +from orm.services.flavor_manager.fms_rest.utils import authentication + from pecan.commands import CommandRunner from pecan import make_app diff --git a/orm/services/flavor_manager/fms_rest/controllers/__init__.py b/orm/services/flavor_manager/fms_rest/controllers/__init__.py index 95881725..483261a1 100644 --- a/orm/services/flavor_manager/fms_rest/controllers/__init__.py +++ b/orm/services/flavor_manager/fms_rest/controllers/__init__.py @@ -1,8 +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 +from orm.common.orm_common.injector import injector +from orm.services.flavor_manager.fms_rest import di_providers +from orm.services.flavor_manager.fms_rest.logger import get_logger 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 bc047167..0055a8eb 100644 --- a/orm/services/flavor_manager/fms_rest/controllers/root.py +++ b/orm/services/flavor_manager/fms_rest/controllers/root.py @@ -1,4 +1,5 @@ -from fms_rest.controllers.v1.v1 import V1Controller +from orm.services.flavor_manager.fms_rest.controllers.v1.v1 import V1Controller + from pecan import conf, expose from webob.exc import status_map 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 c619f82d..e97be2b8 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,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/flavor_manager/fms_rest/controllers/v1/orm/flavors/flavors.py b/orm/services/flavor_manager/fms_rest/controllers/v1/orm/flavors/flavors.py index db56bf5e..bc6f1cb1 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,14 +1,16 @@ -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.tags import TagsController -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 __future__ import absolute_import + +from orm.common.orm_common.injector import injector +from orm.common.orm_common.utils import api_error_utils as err_utils +from orm.services.flavor_manager.fms_rest.controllers.v1.orm.flavors.os_extra_specs import OsExtraSpecsController +from orm.services.flavor_manager.fms_rest.controllers.v1.orm.flavors.regions import RegionController +from orm.services.flavor_manager.fms_rest.controllers.v1.orm.flavors.tags import TagsController +from orm.services.flavor_manager.fms_rest.controllers.v1.orm.flavors.tenants import TenantController +from orm.services.flavor_manager.fms_rest.data.wsme.models import FlavorListFullResponse, FlavorWrapper +from orm.services.flavor_manager.fms_rest.logger import get_logger +from orm.services.flavor_manager.fms_rest.logic.error_base import ErrorStatus +from orm.services.flavor_manager.fms_rest.utils import authentication + from pecan import request, rest from wsmeext.pecan import wsexpose 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 daf2b880..c86f7ee7 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,9 +1,12 @@ -from fms_rest.data.wsme.models import ExtraSpecsWrapper -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 __future__ import absolute_import + +from orm.common.orm_common.injector import injector +from orm.common.orm_common.utils import api_error_utils as err_utils +from orm.services.flavor_manager.fms_rest.data.wsme.models import ExtraSpecsWrapper +from orm.services.flavor_manager.fms_rest.logger import get_logger +from orm.services.flavor_manager.fms_rest.logic.error_base import ErrorStatus +from orm.services.flavor_manager.fms_rest.utils import authentication + from pecan import request, rest from wsmeext.pecan import wsexpose 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 59cc6769..a12607ff 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,9 +1,12 @@ -from fms_rest.data.wsme.models import RegionWrapper -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 __future__ import absolute_import + +from orm.common.orm_common.injector import injector +from orm.common.orm_common.utils import api_error_utils as err_utils +from orm.services.flavor_manager.fms_rest.data.wsme.models import RegionWrapper +from orm.services.flavor_manager.fms_rest.logger import get_logger +from orm.services.flavor_manager.fms_rest.logic.error_base import ErrorStatus +from orm.services.flavor_manager.fms_rest.utils import authentication + from pecan import request, rest from wsmeext.pecan import wsexpose 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 13bfd9ea..c4a9d1bf 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,9 +1,12 @@ -from fms_rest.data.wsme.models import TagsWrapper -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 __future__ import absolute_import + +from orm.common.orm_common.injector import injector +from orm.common.orm_common.utils import api_error_utils as err_utils +from orm.services.flavor_manager.fms_rest.data.wsme.models import TagsWrapper +from orm.services.flavor_manager.fms_rest.logger import get_logger +from orm.services.flavor_manager.fms_rest.logic.error_base import ErrorStatus +from orm.services.flavor_manager.fms_rest.utils import authentication + from pecan import request, rest from wsmeext.pecan import wsexpose 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 c7a13a47..7fb1e22b 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,9 +1,10 @@ -from fms_rest.data.wsme.models import TenantWrapper -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 orm.common.orm_common.injector import injector +from orm.common.orm_common.utils import api_error_utils as err_utils +from orm.services.flavor_manager.fms_rest.data.wsme.models import TenantWrapper +from orm.services.flavor_manager.fms_rest.logger import get_logger +from orm.services.flavor_manager.fms_rest.logic.error_base import ErrorStatus +from orm.services.flavor_manager.fms_rest.utils import authentication + from pecan import request, rest from wsmeext.pecan import wsexpose diff --git a/orm/services/flavor_manager/fms_rest/controllers/v1/orm/orm.py b/orm/services/flavor_manager/fms_rest/controllers/v1/orm/orm.py index e92326cc..1aa0c4fe 100644 --- a/orm/services/flavor_manager/fms_rest/controllers/v1/orm/orm.py +++ b/orm/services/flavor_manager/fms_rest/controllers/v1/orm/orm.py @@ -1,6 +1,9 @@ -from fms_rest.controllers.v1.orm.configuration import ConfigurationController -from fms_rest.controllers.v1.orm.flavors.flavors import FlavorController -from fms_rest.controllers.v1.orm.logs import LogsController +from __future__ import absolute_import + +from orm.services.flavor_manager.fms_rest.controllers.v1.orm.configuration import ConfigurationController +from orm.services.flavor_manager.fms_rest.controllers.v1.orm.flavors.flavors import FlavorController +from orm.services.flavor_manager.fms_rest.controllers.v1.orm.logs import LogsController + from pecan.rest import RestController diff --git a/orm/services/flavor_manager/fms_rest/controllers/v1/v1.py b/orm/services/flavor_manager/fms_rest/controllers/v1/v1.py index 24baa1cb..6adb0fe5 100644 --- a/orm/services/flavor_manager/fms_rest/controllers/v1/v1.py +++ b/orm/services/flavor_manager/fms_rest/controllers/v1/v1.py @@ -1,4 +1,7 @@ -from fms_rest.controllers.v1.orm.orm import OrmController +from __future__ import absolute_import + +from orm.services.flavor_manager.fms_rest.controllers.v1.orm.orm import OrmController + from pecan.rest import RestController 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 bb8f9a3a..80325c7e 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 @@ -12,9 +12,10 @@ import logging -# from fms_rest.logic.error_base import DuplicateEntityError -from fms_rest.data.sql_alchemy.flavor.flavor_record import FlavorRecord +# from orm.services.flavor_manager.fms_rest.logic.error_base import DuplicateEntityError +from orm.services.flavor_manager.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 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 2248b2f5..d879d58a 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,7 +1,8 @@ from __builtin__ import reversed -from fms_rest.logger import get_logger -from fms_rest.logic.error_base import ErrorStatus +from orm.services.flavor_manager.fms_rest.logger import get_logger +from orm.services.flavor_manager.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 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 ba40b77b..ba3380c0 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,7 +1,8 @@ -from fms_rest.data.sql_alchemy.db_models import (Flavor, FlavorRegion, - FlavorTenant) -from fms_rest.logger import get_logger +from orm.services.flavor_manager.fms_rest.data.sql_alchemy.db_models import (Flavor, FlavorRegion, + FlavorTenant) +from orm.services.flavor_manager.fms_rest.logger import get_logger + from sqlalchemy.sql import or_ LOG = get_logger(__name__) 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 bffb2717..4f694f01 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,5 +1,5 @@ -from fms_rest.data.sql_alchemy.db_models import FlavorExtraSpec -from fms_rest.logger import get_logger +from orm.services.flavor_manager.fms_rest.data.sql_alchemy.db_models import FlavorExtraSpec +from orm.services.flavor_manager.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 86235e9e..efe7af4d 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,5 +1,5 @@ -from fms_rest.data.sql_alchemy.db_models import FlavorOption -from fms_rest.logger import get_logger +from orm.services.flavor_manager.fms_rest.data.sql_alchemy.db_models import FlavorOption +from orm.services.flavor_manager.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 16384a3d..cde3359e 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,5 +1,5 @@ -from fms_rest.data.sql_alchemy.db_models import FlavorRegion -from fms_rest.logger import get_logger +from orm.services.flavor_manager.fms_rest.data.sql_alchemy.db_models import FlavorRegion +from orm.services.flavor_manager.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 f3b4a255..8f5271b2 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,5 +1,5 @@ -from fms_rest.data.sql_alchemy.db_models import FlavorTag -from fms_rest.logger import get_logger +from orm.services.flavor_manager.fms_rest.data.sql_alchemy.db_models import FlavorTag +from orm.services.flavor_manager.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 273a0bd2..95f54946 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,5 +1,5 @@ -from fms_rest.data.sql_alchemy.db_models import FlavorTenant -from fms_rest.logger import get_logger +from orm.services.flavor_manager.fms_rest.data.sql_alchemy.db_models import FlavorTenant +from orm.services.flavor_manager.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/models.py b/orm/services/flavor_manager/fms_rest/data/wsme/models.py index 0f6d23ab..19b764b8 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,11 @@ 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 orm.common.orm_common.utils.cross_api_utils import set_utils_conf, get_regions_of_group +from orm.services.flavor_manager.fms_rest.data.sql_alchemy import db_models +from orm.services.flavor_manager.fms_rest.data.wsme.model import Model +from orm.services.flavor_manager.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 class TenantWrapper(Model): 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 e6a0830d..4ece0f98 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,8 +1,8 @@ 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 -from fms_rest.utils import utils +from orm.services.flavor_manager.fms_rest.data.sql_alchemy.data_manager import DataManager +from orm.services.flavor_manager.fms_rest.logic import flavor_logic +from orm.services.flavor_manager.fms_rest.proxies import rds_proxy +from orm.services.flavor_manager.fms_rest.utils import utils providers = [ ('rds_proxy', 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 8e17cb15..4db7d640 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,10 +1,10 @@ import requests -from audit_client.api import audit -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 +from orm.common.client.audit.audit_client.api import audit +from orm.services.flavor_manager.fms_rest.data.sql_alchemy.data_manager import DataManager +from orm.services.flavor_manager.fms_rest.logic import flavor_logic +from orm.services.flavor_manager.fms_rest.proxies import rds_proxy +from orm.services.flavor_manager.fms_rest.utils import utils providers = [ ('rds_proxy', rds_proxy), 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 679f309a..9eeee04e 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,7 +1,7 @@ import imp import os -from orm_common.injector import fang +from orm.common.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 b2183133..3b54abce 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 @@ -2,7 +2,7 @@ import time import requests -from orm_common.logger import get_logger +from orm.common.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 0bdf312e..150ad2a4 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 @@ -4,7 +4,7 @@ import time import requests from audit_client.api import audit -from orm_common.logger import get_logger +from orm.common.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 b348fea1..958e3d8a 100755 --- a/orm/services/flavor_manager/fms_rest/hooks/service_hooks.py +++ b/orm/services/flavor_manager/fms_rest/hooks/service_hooks.py @@ -1,5 +1,6 @@ -from fms_rest.utils import utils -from orm_common.hooks.transaction_id_hook import TransactionIdHook +from orm.common.orm_common.hooks.transaction_id_hook import TransactionIdHook +from orm.services.flavor_manager.fms_rest.utils import utils + from pecan import abort 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 b90b4164..fd4fe2f5 100755 --- a/orm/services/flavor_manager/fms_rest/logic/flavor_logic.py +++ b/orm/services/flavor_manager/fms_rest/logic/flavor_logic.py @@ -1,13 +1,13 @@ 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 +from orm.services.flavor_manager.fms_rest.data.sql_alchemy.db_models import FlavorRegion, FlavorTenant +from orm.services.flavor_manager.fms_rest.data.wsme.models import (ExtraSpecsWrapper, Flavor, + FlavorListFullResponse, FlavorWrapper, + Region, RegionWrapper, TagsWrapper, + TenantWrapper) +from orm.services.flavor_manager.fms_rest.logger import get_logger +from orm.services.flavor_manager.fms_rest.logic.error_base import ConflictError, ErrorStatus, NotFoundError +from orm.common.orm_common.injector import injector LOG = get_logger(__name__) 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 41c5ef38..88d24b18 100755 --- a/orm/services/flavor_manager/fms_rest/proxies/rds_proxy.py +++ b/orm/services/flavor_manager/fms_rest/proxies/rds_proxy.py @@ -1,9 +1,10 @@ import json import pprint -from fms_rest.logger import get_logger -from fms_rest.logic.error_base import ErrorStatus -from orm_common.injector import injector +from orm.common.orm_common.injector import injector +from orm.services.flavor_manager.fms_rest.logger import get_logger +from orm.services.flavor_manager.fms_rest.logic.error_base import ErrorStatus + from pecan import conf, request di = injector.get_di() diff --git a/orm/services/flavor_manager/fms_rest/tests/data/__init__.py b/orm/services/flavor_manager/fms_rest/tests/data/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/orm/services/flavor_manager/fms_rest/tests/logic/__init__.py b/orm/services/flavor_manager/fms_rest/tests/logic/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/orm/services/flavor_manager/fms_rest/tests/mocks/__init__.py b/orm/services/flavor_manager/fms_rest/tests/mocks/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/orm/services/flavor_manager/fms_rest/tests/rest/__init__.py b/orm/services/flavor_manager/fms_rest/tests/rest/__init__.py deleted file mode 100755 index e69de29b..00000000 diff --git a/orm/services/flavor_manager/fms_rest/utils/authentication.py b/orm/services/flavor_manager/fms_rest/utils/authentication.py index 43eaf965..80c1b01d 100644 --- a/orm/services/flavor_manager/fms_rest/utils/authentication.py +++ b/orm/services/flavor_manager/fms_rest/utils/authentication.py @@ -1,7 +1,8 @@ import logging -from keystone_utils import tokens -from orm_common.policy import policy +from orm.common.client.keystone.keystone_utils import tokens +from orm.common.orm_common.policy import policy + 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 388c101c..01188dfd 100755 --- a/orm/services/flavor_manager/fms_rest/utils/utils.py +++ b/orm/services/flavor_manager/fms_rest/utils/utils.py @@ -1,7 +1,8 @@ import time -from fms_rest.logger import get_logger -from orm_common.injector import injector +from orm.common.orm_common.injector import injector +from orm.services.flavor_manager.fms_rest.logger import get_logger + from pecan import conf logger = get_logger(__name__) diff --git a/orm/tests/__init__.py b/orm/tests/__init__.py index 8fcee68f..e69de29b 100644 --- a/orm/tests/__init__.py +++ b/orm/tests/__init__.py @@ -1,21 +0,0 @@ -import os -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. - """ - - def setUp(self): - self.app = load_test_app(os.path.join( - os.path.dirname(__file__), - 'config.py' - )) - - def tearDown(self): - set_config({}, overwrite=True) diff --git a/orm/tests/config.py b/orm/tests/config.py index 74cf0784..3e2dd665 100644 --- a/orm/tests/config.py +++ b/orm/tests/config.py @@ -1,4 +1,4 @@ -from fms_rest.tests.simple_hook_mock import SimpleHookMock +from orm.tests.unit.fms.simple_hook_mock import SimpleHookMock global SimpleHookMock @@ -11,8 +11,8 @@ server = { # Pecan Application Configurations app = { - 'root': 'fms_rest.controllers.root.RootController', - 'modules': ['fms_rest'], + 'root': 'orm.services.flavor_manager.fms_rest.controllers.root.RootController', + 'modules': ['orm.services.flavor_manager.fms_rest'], 'static_root': '%(confdir)s/public', 'template_path': '%(confdir)s/fms_rest/templates', 'debug': True, diff --git a/orm/services/flavor_manager/fms_rest/tests/__init__.py b/orm/tests/unit/fms/__init__.py old mode 100644 new mode 100755 similarity index 75% rename from orm/services/flavor_manager/fms_rest/tests/__init__.py rename to orm/tests/unit/fms/__init__.py index 55396865..8fcee68f --- a/orm/services/flavor_manager/fms_rest/tests/__init__.py +++ b/orm/tests/unit/fms/__init__.py @@ -7,9 +7,8 @@ __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/config.py b/orm/tests/unit/fms/config.py similarity index 93% rename from orm/services/flavor_manager/fms_rest/tests/config.py rename to orm/tests/unit/fms/config.py index 6f8be58d..3e2dd665 100755 --- a/orm/services/flavor_manager/fms_rest/tests/config.py +++ b/orm/tests/unit/fms/config.py @@ -1,4 +1,4 @@ -from fms_rest.tests.simple_hook_mock import SimpleHookMock +from orm.tests.unit.fms.simple_hook_mock import SimpleHookMock global SimpleHookMock @@ -11,8 +11,8 @@ server = { # Pecan Application Configurations app = { - 'root': 'fms_rest.controllers.root.RootController', - 'modules': ['fms_rest'], + 'root': 'orm.services.flavor_manager.fms_rest.controllers.root.RootController', + 'modules': ['orm.services.flavor_manager.fms_rest'], 'static_root': '%(confdir)s/public', 'template_path': '%(confdir)s/fms_rest/templates', 'debug': True, @@ -132,5 +132,5 @@ authentication = { "rms_url": "http://127.0.0.1:8080", "tenant_name": "admin", "keystone_version": "2.0", - "policy_file": "fms_rest/etc/policy.json" + "policy_file": "orm/services/flavor_manager/fms_rest/etc/policy.json" } diff --git a/orm/services/flavor_manager/fms_rest/tests/simple_hook_mock.py b/orm/tests/unit/fms/simple_hook_mock.py similarity index 100% rename from orm/services/flavor_manager/fms_rest/tests/simple_hook_mock.py rename to orm/tests/unit/fms/simple_hook_mock.py diff --git a/orm/services/flavor_manager/fms_rest/tests/test_authentication.py b/orm/tests/unit/fms/test_authentication.py similarity index 68% rename from orm/services/flavor_manager/fms_rest/tests/test_authentication.py rename to orm/tests/unit/fms/test_authentication.py index 52dbf2dc..20ab336f 100755 --- a/orm/services/flavor_manager/fms_rest/tests/test_authentication.py +++ b/orm/tests/unit/fms/test_authentication.py @@ -1,5 +1,6 @@ -from fms_rest.tests import FunctionalTest -from fms_rest.utils import authentication +from orm.services.flavor_manager.fms_rest.utils import authentication +from orm.tests.unit.fms import FunctionalTest + import mock from pecan import conf @@ -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/flavor_manager/fms_rest/tests/test_configuration.py b/orm/tests/unit/fms/test_configuration.py similarity index 80% rename from orm/services/flavor_manager/fms_rest/tests/test_configuration.py rename to orm/tests/unit/fms/test_configuration.py index f64d6c1e..046cec75 100755 --- a/orm/services/flavor_manager/fms_rest/tests/test_configuration.py +++ b/orm/tests/unit/fms/test_configuration.py @@ -1,12 +1,13 @@ """Get configuration module unittests.""" -from fms_rest.tests import FunctionalTest +from orm.tests.unit.fms import FunctionalTest + from mock import patch 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/flavor_manager/fms_rest/tests/logic/test_flavor_logic.py b/orm/tests/unit/fms/test_flavor_logic.py similarity index 97% rename from orm/services/flavor_manager/fms_rest/tests/logic/test_flavor_logic.py rename to orm/tests/unit/fms/test_flavor_logic.py index 6b813244..aad0f153 100755 --- a/orm/services/flavor_manager/fms_rest/tests/logic/test_flavor_logic.py +++ b/orm/tests/unit/fms/test_flavor_logic.py @@ -1,11 +1,13 @@ -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.logic.error_base import NotFoundError -import fms_rest.logic.flavor_logic as flavor_logic -from fms_rest.tests import FunctionalTest +from orm.common.orm_common.injector import injector +from orm.services.flavor_manager.fms_rest.data.sql_alchemy import db_models +from orm.services.flavor_manager.fms_rest.data.wsme import models +from orm.services.flavor_manager.fms_rest.data.wsme.models import * +from orm.services.flavor_manager.fms_rest.logic.error_base import NotFoundError +from orm.services.flavor_manager.fms_rest.logic import flavor_logic +from orm.tests.unit.fms import FunctionalTest + +from sqlalchemy.orm import exc from mock import MagicMock, patch -from orm_common.injector import injector class OES(): @@ -440,11 +442,11 @@ class TestFlavorLogic(FunctionalTest): injector.override_injected_dependency( ('data_manager', get_datamanager_mock)) - mock_strin.side_effect = flavor_logic.FlushError() - self.assertRaises(flavor_logic.FlushError, flavor_logic.add_regions, + mock_strin.side_effect = exc.FlushError() + self.assertRaises(exc.FlushError, flavor_logic.add_regions, 'uuid', RegionWrapper([Region(name='test_region')]), 'transaction') - mock_strin.side_effect = flavor_logic.FlushError( + mock_strin.side_effect = exc.FlushError( 'conflicts with persistent instance') self.assertRaises(flavor_logic.ErrorStatus, flavor_logic.add_regions, 'uuid', RegionWrapper([Region(name='test_region')]), @@ -549,15 +551,15 @@ class TestFlavorLogic(FunctionalTest): moq, 'transaction') - mock_strin.side_effect = flavor_logic.FlushError( + mock_strin.side_effect = exc.FlushError( 'conflicts with persistent instance') self.assertRaises(flavor_logic.ConflictError, flavor_logic.add_tenants, 'uuid', TenantWrapper(tenants), 'transaction') - mock_strin.side_effect = flavor_logic.FlushError('') - self.assertRaises(flavor_logic.FlushError, + mock_strin.side_effect = exc.FlushError('') + self.assertRaises(exc.FlushError, flavor_logic.add_tenants, 'uuid', TenantWrapper(tenants), 'transaction') diff --git a/orm/services/flavor_manager/fms_rest/tests/rest/test_flavors.py b/orm/tests/unit/fms/test_flavors.py similarity index 97% rename from orm/services/flavor_manager/fms_rest/tests/rest/test_flavors.py rename to orm/tests/unit/fms/test_flavors.py index 6d472146..3cb20d7f 100755 --- a/orm/services/flavor_manager/fms_rest/tests/rest/test_flavors.py +++ b/orm/tests/unit/fms/test_flavors.py @@ -2,12 +2,14 @@ import copy import requests 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.tests import FunctionalTest, test_utils +from orm.common.orm_common.injector import injector +from orm.services.flavor_manager.fms_rest.controllers.v1.orm.flavors import flavors +from orm.services.flavor_manager.fms_rest.data.wsme import models +from orm.services.flavor_manager.fms_rest.logic.error_base import ErrorStatus +from orm.tests.unit.fms import FunctionalTest +from orm.tests.unit.fms import 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_logs.py b/orm/tests/unit/fms/test_logs.py similarity index 95% rename from orm/services/flavor_manager/fms_rest/tests/rest/test_logs.py rename to orm/tests/unit/fms/test_logs.py index c20f9f0e..505783ed 100755 --- a/orm/services/flavor_manager/fms_rest/tests/rest/test_logs.py +++ b/orm/tests/unit/fms/test_logs.py @@ -1,5 +1,5 @@ """Logs module unittests.""" -from fms_rest.tests import FunctionalTest +from orm.tests.unit.fms import FunctionalTest class TestLogs(FunctionalTest): diff --git a/orm/services/flavor_manager/fms_rest/tests/test_models.py b/orm/tests/unit/fms/test_models.py similarity index 88% rename from orm/services/flavor_manager/fms_rest/tests/test_models.py rename to orm/tests/unit/fms/test_models.py index b56ec320..716f78bc 100755 --- a/orm/services/flavor_manager/fms_rest/tests/test_models.py +++ b/orm/tests/unit/fms/test_models.py @@ -1,5 +1,6 @@ -from fms_rest.data.wsme import models -from fms_rest.tests import FunctionalTest +from orm.services.flavor_manager.fms_rest.data.wsme import models +from orm.tests.unit.fms import FunctionalTest + import mock GROUP_REGIONS = [ diff --git a/orm/services/flavor_manager/fms_rest/tests/rest/test_os_extra_specs.py b/orm/tests/unit/fms/test_os_extra_specs.py similarity index 96% rename from orm/services/flavor_manager/fms_rest/tests/rest/test_os_extra_specs.py rename to orm/tests/unit/fms/test_os_extra_specs.py index 6aaa58fb..4d4ff77c 100755 --- a/orm/services/flavor_manager/fms_rest/tests/rest/test_os_extra_specs.py +++ b/orm/tests/unit/fms/test_os_extra_specs.py @@ -1,7 +1,8 @@ -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.services.flavor_manager.fms_rest.controllers.v1.orm.flavors import os_extra_specs as es +from orm.services.flavor_manager.fms_rest.data.wsme import models +from orm.services.flavor_manager.fms_rest.logic.error_base import NotFoundError +from orm.tests.unit.fms import FunctionalTest + from mock import MagicMock, patch diff --git a/orm/services/flavor_manager/fms_rest/tests/test_rds_proxy.py b/orm/tests/unit/fms/test_rds_proxy.py similarity index 79% rename from orm/services/flavor_manager/fms_rest/tests/test_rds_proxy.py rename to orm/tests/unit/fms/test_rds_proxy.py index 53895dfb..f5c4aa62 100755 --- a/orm/services/flavor_manager/fms_rest/tests/test_rds_proxy.py +++ b/orm/tests/unit/fms/test_rds_proxy.py @@ -1,6 +1,7 @@ -from fms_rest.data.sql_alchemy import db_models -from fms_rest import proxies -from fms_rest.tests import FunctionalTest +from orm.services.flavor_manager.fms_rest.data.sql_alchemy import db_models +from orm.services.flavor_manager.fms_rest import proxies +from orm.tests.unit.fms import FunctionalTest + import mock from testfixtures import log_capture @@ -18,7 +19,7 @@ class TestUtil(FunctionalTest): @mock.patch.object(proxies.rds_proxy, 'request') @mock.patch('requests.post') - @log_capture('fms_rest.proxies.rds_proxy') + @log_capture('orm.services.flavor_manager.fms_rest.proxies.rds_proxy') def test_send_good(self, mock_post, mock_request, l): resp = Response(200, 'my content') mock_post.return_value = resp @@ -27,7 +28,7 @@ class TestUtil(FunctionalTest): # self.assertRegexpMatches(l.records[-1].getMessage(), 'return from rds server status code') @mock.patch('requests.post') - @log_capture('fms_rest.proxies.rds_proxy') + @log_capture('orm.services.flavor_manager.fms_rest.proxies.rds_proxy') def test_bad_status(self, mock_post, l): resp = Response(400, 'my content') mock_post.return_value = resp @@ -35,7 +36,7 @@ class TestUtil(FunctionalTest): # self.assertRegexpMatches(l.records[-1].getMessage(), 'return from rds server status code') @mock.patch('requests.post') - @log_capture('fms_rest.proxies.rds_proxy') + @log_capture('orm.services.flavor_manager.fms_rest.proxies.rds_proxy') def test_no_content(self, mock_post, l): resp = Response(200, None) mock_post.return_value = resp diff --git a/orm/services/flavor_manager/fms_rest/tests/rest/test_regions.py b/orm/tests/unit/fms/test_regions.py similarity index 92% rename from orm/services/flavor_manager/fms_rest/tests/rest/test_regions.py rename to orm/tests/unit/fms/test_regions.py index b58266d9..70564fd4 100755 --- a/orm/services/flavor_manager/fms_rest/tests/rest/test_regions.py +++ b/orm/tests/unit/fms/test_regions.py @@ -1,11 +1,13 @@ import requests -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 FunctionalTest, test_utils +from orm.common.orm_common.injector import injector +from orm.services.flavor_manager.fms_rest.controllers.v1.orm.flavors import regions +from orm.services.flavor_manager.fms_rest.data.wsme import models +from orm.services.flavor_manager.fms_rest.logic.error_base import ErrorStatus +from orm.tests.unit.fms import FunctionalTest +from orm.tests.unit.fms import 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/tests/unit/fms/test_tags.py similarity index 97% rename from orm/services/flavor_manager/fms_rest/tests/rest/test_tags.py rename to orm/tests/unit/fms/test_tags.py index 1b960be3..dad07245 100644 --- a/orm/services/flavor_manager/fms_rest/tests/rest/test_tags.py +++ b/orm/tests/unit/fms/test_tags.py @@ -1,10 +1,11 @@ import requests -from fms_rest.data.wsme import models -from fms_rest.logic.error_base import ErrorStatus -from fms_rest.tests import FunctionalTest +from orm.common.orm_common.injector import injector +from orm.services.flavor_manager.fms_rest.data.wsme import models +from orm.services.flavor_manager.fms_rest.logic.error_base import ErrorStatus +from orm.tests.unit.fms 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/tests/unit/fms/test_tenants.py similarity index 94% rename from orm/services/flavor_manager/fms_rest/tests/rest/test_tenants.py rename to orm/tests/unit/fms/test_tenants.py index a5aebaa8..eb455d92 100755 --- a/orm/services/flavor_manager/fms_rest/tests/rest/test_tenants.py +++ b/orm/tests/unit/fms/test_tenants.py @@ -1,10 +1,11 @@ import requests -from fms_rest.data.wsme import models -from fms_rest.logic.error_base import ErrorStatus -from fms_rest.tests import FunctionalTest +from orm.common.orm_common.injector import injector +from orm.services.flavor_manager.fms_rest.data.wsme import models +from orm.services.flavor_manager.fms_rest.logic.error_base import ErrorStatus +from orm.tests.unit.fms 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_utils.py b/orm/tests/unit/fms/test_utils.py similarity index 100% rename from orm/services/flavor_manager/fms_rest/tests/test_utils.py rename to orm/tests/unit/fms/test_utils.py diff --git a/orm/services/flavor_manager/fms_rest/tests/data/test_wsme_models.py b/orm/tests/unit/fms/test_wsme_models.py similarity index 84% rename from orm/services/flavor_manager/fms_rest/tests/data/test_wsme_models.py rename to orm/tests/unit/fms/test_wsme_models.py index 067726a7..865021e1 100755 --- a/orm/services/flavor_manager/fms_rest/tests/data/test_wsme_models.py +++ b/orm/tests/unit/fms/test_wsme_models.py @@ -1,6 +1,6 @@ -from fms_rest.data.sql_alchemy import db_models -import fms_rest.data.wsme.models as wsme_models -from fms_rest.tests import FunctionalTest +from orm.services.flavor_manager.fms_rest.data.sql_alchemy import db_models +from orm.services.flavor_manager.fms_rest.data.wsme import models +from orm.tests.unit.fms import FunctionalTest class TestWsmeModels(FunctionalTest): @@ -29,7 +29,7 @@ class TestWsmeModels(FunctionalTest): sql_flavor.disk = 1 sql_flavor.name = 'name' - wsme_flavors = wsme_models.FlavorWrapper.from_db_model(sql_flavor) + wsme_flavors = models.FlavorWrapper.from_db_model(sql_flavor) self.assertEqual(len(wsme_flavors.flavor.regions), 2) self.assertEqual(len(wsme_flavors.flavor.tenants), 2) @@ -37,8 +37,8 @@ class TestWsmeModels(FunctionalTest): self.assertEqual(wsme_flavors.flavor.extra_specs['key2'], 'val2') def test_flavor_wrapper_to_db_model(self): - flavor_wrapper = wsme_models.FlavorWrapper() - flavor_wrapper.flavor = wsme_models.Flavor() + flavor_wrapper = models.FlavorWrapper() + flavor_wrapper.flavor = models.Flavor() flavor_wrapper.flavor.description = 'desc' flavor_wrapper.flavor.disk = '1' @@ -46,8 +46,8 @@ class TestWsmeModels(FunctionalTest): flavor_wrapper.flavor.extra_specs = {'key1': 'val1', 'key2': 'val2'} flavor_wrapper.flavor.tag = {'key1': 'val1', 'key2': 'val2'} flavor_wrapper.flavor.options = {'key1': 'val1', 'key2': 'val2'} - flavor_wrapper.flavor.regions = [wsme_models.Region('region1'), - wsme_models.Region('region2')] + flavor_wrapper.flavor.regions = [models.Region('region1'), + models.Region('region2')] flavor_wrapper.flavor.tenants = ['tenant1', 'tenant2'] flavor_wrapper.flavor.id = 'id' flavor_wrapper.flavor.ram = '1' @@ -72,7 +72,7 @@ class TestWsmeModels(FunctionalTest): sql_flavor.name = 'some name' sql_flavor.description = 'some_decription' - flavor_summary = wsme_models.FlavorSummary.from_db_model(sql_flavor) + flavor_summary = models.FlavorSummary.from_db_model(sql_flavor) self.assertEqual(flavor_summary.id, sql_flavor.id) self.assertEqual(flavor_summary.name, sql_flavor.name)