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
This commit is contained in:
Nicholas Jones 2017-08-22 13:10:08 -05:00
parent 5de8154ed7
commit c86c404c31
55 changed files with 223 additions and 202 deletions

View File

@ -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

View File

@ -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__)

View File

@ -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__)

View File

@ -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

View File

@ -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__)

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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__)

View File

@ -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__)

View File

@ -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__)

View File

@ -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__)

View File

@ -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__)

View File

@ -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__)

View File

@ -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):

View File

@ -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),

View File

@ -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),

View File

@ -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

View File

@ -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__)

View File

@ -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__)

View File

@ -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

View File

@ -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__)

View File

@ -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()

View File

@ -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__)

View File

@ -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__)

View File

@ -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)

View File

@ -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,

View File

@ -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):

View File

@ -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"
}

View File

@ -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')

View File

@ -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'

View File

@ -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')

View File

@ -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

View File

@ -1,5 +1,5 @@
"""Logs module unittests."""
from fms_rest.tests import FunctionalTest
from orm.tests.unit.fms import FunctionalTest
class TestLogs(FunctionalTest):

View File

@ -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 = [

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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)