Move ims tests to top level folder
Moves unit tests under the ims directory to the root test directory Change-Id: Idc8e356ce74970bacf16c3046b72e57fe9cbe5eb
This commit is contained in:
parent
d61621cf84
commit
92590ca743
@ -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(
|
||||
|
@ -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
|
||||
|
||||
|
@ -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__)
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
||||
|
@ -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),
|
||||
|
@ -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__)
|
||||
|
||||
|
@ -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__)
|
||||
|
||||
|
@ -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
|
||||
|
@ -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,
|
||||
|
@ -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__)
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
from ims.logger import get_logger
|
||||
from orm.services.image_manager.ims.logger import get_logger
|
||||
|
||||
LOG = get_logger(__name__)
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
@ -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()
|
||||
|
@ -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__)
|
||||
|
@ -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"
|
||||
}
|
@ -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
|
@ -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
|
@ -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
|
@ -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
|
||||
|
@ -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
|
@ -1,4 +1,4 @@
|
||||
from ims.tests import FunctionalTest
|
||||
from orm.tests.unit.ims import FunctionalTest
|
||||
|
||||
|
||||
class TestLogsController(FunctionalTest):
|
@ -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')
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
@ -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 = [
|
Loading…
x
Reference in New Issue
Block a user