Remove obsolete code

Change-Id: I678e7a1711cee3c13c34019548beec4ab6cbd1ca
This commit is contained in:
Serg Melikyan 2013-07-15 11:31:49 +04:00
parent 944f7c57b4
commit eb1cc1630a
12 changed files with 31 additions and 789 deletions

View File

@ -1,64 +0,0 @@
# Copyright (c) 2013 Mirantis, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from muranoapi import utils
from muranoapi.db.services.systemservices import SystemServices
from muranoapi.openstack.common import wsgi
from muranoapi.openstack.common import log as logging
from webob.exc import HTTPNotFound
log = logging.getLogger(__name__)
class Controller(object):
def index(self, request, environment_id):
log.debug(_('ActiveDirectory:Index '
'<EnvId: {0}>'.format(environment_id)))
session_id = None
if hasattr(request, 'context') and request.context.session:
session_id = request.context.session
get = SystemServices.get_services
services = get(environment_id, 'activeDirectories', session_id)
return {'activeDirectories': services}
@utils.verify_session
def create(self, request, environment_id, body):
log.debug(_('ActiveDirectory:Create <EnvId: {0}, '
'Body: {1}>'.format(environment_id, body)))
session_id = request.context.session
create = SystemServices.create_active_directory
return create(body.copy(), session_id, environment_id)
@utils.verify_session
def delete(self, request, environment_id, active_directory_id):
log.debug(_('ActiveDirectory:Delete <EnvId: {0}, '
'Id: {1}>'.format(environment_id, active_directory_id)))
session_id = request.context.session
delete = SystemServices.delete_service
try:
delete(active_directory_id, 'activeDirectories', session_id,
environment_id)
except ValueError:
raise HTTPNotFound()
def create_resource():
return wsgi.Resource(Controller())

View File

@ -1,62 +0,0 @@
# Copyright (c) 2013 Mirantis, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from muranoapi import utils
from muranoapi.db.services.systemservices import SystemServices
from muranoapi.openstack.common import wsgi
from muranoapi.openstack.common import log as logging
from webob.exc import HTTPNotFound
log = logging.getLogger(__name__)
class Controller(object):
def index(self, request, environment_id):
log.debug(_('AspNetAppFarms:List <EnvId: {0}>'.format(environment_id)))
session_id = None
if hasattr(request, 'context') and request.context.session:
session_id = request.context.session
get = SystemServices.get_services
services = get(environment_id, 'aspNetAppFarms', session_id)
return {'aspNetAppFarms': services}
@utils.verify_session
def create(self, request, environment_id, body):
log.debug(_('AspNetAppFarms:Create <EnvId: {0}, Body: {1}>'.
format(environment_id, body)))
session_id = request.context.session
create = SystemServices.create_asp_application_farm
return create(body.copy(), session_id, environment_id)
@utils.verify_session
def delete(self, request, environment_id, app_farm_id):
log.debug(_('AspNetAppFarms:Delete <EnvId: {0}, Id: {1}>'.
format(environment_id, app_farm_id)))
session_id = request.context.session
delete = SystemServices.delete_service
try:
delete(app_farm_id, 'aspNetAppFarms', session_id, environment_id)
except ValueError:
raise HTTPNotFound()
def create_resource():
return wsgi.Resource(Controller())

View File

@ -1,62 +0,0 @@
# Copyright (c) 2013 Mirantis, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from muranoapi import utils
from muranoapi.db.services.systemservices import SystemServices
from muranoapi.openstack.common import wsgi
from muranoapi.openstack.common import log as logging
from webob.exc import HTTPNotFound
log = logging.getLogger(__name__)
class Controller(object):
def index(self, request, environment_id):
log.debug(_('AspNetApps:List <EnvId: {0}>'.format(environment_id)))
session_id = None
if hasattr(request, 'context') and request.context.session:
session_id = request.context.session
get = SystemServices.get_services
services = get(environment_id, 'aspNetApps', session_id)
return {'aspNetApps': services}
@utils.verify_session
def create(self, request, environment_id, body):
log.debug(_('AspNetApps:Create <EnvId: {0}, Body: {1}>'.
format(environment_id, body)))
session_id = request.context.session
create = SystemServices.create_asp_application
return create(body.copy(), session_id, environment_id)
@utils.verify_session
def delete(self, request, environment_id, app_id):
log.debug(_('AspNetApps:Delete <EnvId: {0}, Id: {1}>'.
format(environment_id, app_id)))
session_id = request.context.session
delete = SystemServices.delete_service
try:
delete(app_id, 'aspNetApps', session_id, environment_id)
except ValueError:
raise HTTPNotFound()
def create_resource():
return wsgi.Resource(Controller())

View File

@ -17,8 +17,8 @@ from webob import exc
from muranoapi.common import config
from muranoapi.db.session import get_session
from muranoapi.db.models import Environment
from muranoapi.db.services.core_services import CoreServices
from muranoapi.db.services.environments import EnvironmentServices
from muranoapi.db.services.systemservices import SystemServices
from muranoapi.openstack.common import wsgi
from muranoapi.openstack.common import log as logging
@ -65,21 +65,8 @@ class Controller(object):
session_id = request.context.session
#add services to env
get = SystemServices.get_services
ad = get(environment_id, 'activeDirectories', session_id)
webServers = get(environment_id, 'webServers', session_id)
aspNetApps = get(environment_id, 'aspNetApps', session_id)
webServerFarms = get(environment_id, 'webServerFarms', session_id)
aspNetAppFarms = get(environment_id, 'aspNetAppFarms', session_id)
env['services'] = {
'activeDirectories': ad,
'webServers': webServers,
'aspNetApps': aspNetApps,
'webServerFarms': webServerFarms,
'aspNetAppFarms': aspNetAppFarms
}
get_data = CoreServices.get_data
env['services'] = get_data(environment_id, '/services', session_id)
return env

View File

@ -16,11 +16,6 @@ import routes
from muranoapi.openstack.common import wsgi
from muranoapi.api.v1 import environments, services
from muranoapi.api.v1 import sessions
from muranoapi.api.v1 import active_directories
from muranoapi.api.v1 import webservers
from muranoapi.api.v1 import aspNetApps
from muranoapi.api.v1 import webserverFarms
from muranoapi.api.v1 import aspNetAppFarms
class API(wsgi.Router):
@ -112,79 +107,4 @@ class API(wsgi.Router):
action='deploy',
conditions={'method': ['POST']})
activeDirectories_resource = active_directories.create_resource()
mapper.connect('/environments/{environment_id}/activeDirectories',
controller=activeDirectories_resource,
action='index',
conditions={'method': ['GET']})
mapper.connect('/environments/{environment_id}/activeDirectories',
controller=activeDirectories_resource,
action='create',
conditions={'method': ['POST']})
mapper.connect('/environments/{environment_id}/activeDirectories/'
'{active_directory_id}',
controller=activeDirectories_resource,
action='delete',
conditions={'method': ['DELETE']})
webServers_resource = webservers.create_resource()
mapper.connect('/environments/{environment_id}/webServers',
controller=webServers_resource,
action='index',
conditions={'method': ['GET']})
mapper.connect('/environments/{environment_id}/webServers',
controller=webServers_resource,
action='create',
conditions={'method': ['POST']})
mapper.connect('/environments/{environment_id}/webServers/'
'{web_server_id}',
controller=webServers_resource,
action='delete',
conditions={'method': ['DELETE']})
aspNetApps_resource = aspNetApps.create_resource()
mapper.connect('/environments/{environment_id}/aspNetApps',
controller=aspNetApps_resource,
action='index',
conditions={'method': ['GET']})
mapper.connect('/environments/{environment_id}/aspNetApps',
controller=aspNetApps_resource,
action='create',
conditions={'method': ['POST']})
mapper.connect('/environments/{environment_id}/aspNetApps/'
'{app_id}',
controller=aspNetApps_resource,
action='delete',
conditions={'method': ['DELETE']})
webServerFarms_resource = webserverFarms.create_resource()
mapper.connect('/environments/{environment_id}/webServerFarms',
controller=webServerFarms_resource,
action='index',
conditions={'method': ['GET']})
mapper.connect('/environments/{environment_id}/webServerFarms',
controller=webServerFarms_resource,
action='create',
conditions={'method': ['POST']})
mapper.connect('/environments/{environment_id}/webServerFarms/'
'{web_server_farm_id}',
controller=webServerFarms_resource,
action='delete',
conditions={'method': ['DELETE']})
aspNetAppFarms_resource = aspNetAppFarms.create_resource()
mapper.connect('/environments/{environment_id}/aspNetAppFarms',
controller=aspNetAppFarms_resource,
action='index',
conditions={'method': ['GET']})
mapper.connect('/environments/{environment_id}/aspNetAppFarms',
controller=aspNetAppFarms_resource,
action='create',
conditions={'method': ['POST']})
mapper.connect('/environments/{environment_id}/aspNetAppFarms/'
'{app_farm_id}',
controller=aspNetAppFarms_resource,
action='delete',
conditions={'method': ['DELETE']})
super(API, self).__init__(mapper)

View File

@ -1,63 +0,0 @@
# Copyright (c) 2013 Mirantis, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from muranoapi import utils
from muranoapi.db.services.systemservices import SystemServices
from muranoapi.openstack.common import wsgi
from muranoapi.openstack.common import log as logging
from webob.exc import HTTPNotFound
log = logging.getLogger(__name__)
class Controller(object):
def index(self, request, environment_id):
log.debug(_('WebServerFarm:List <EnvId: {0}>'.format(environment_id)))
session_id = None
if hasattr(request, 'context') and request.context.session:
session_id = request.context.session
get = SystemServices.get_services
services = get(environment_id, 'webServerFarms', session_id)
return {'webServerFarms': services}
@utils.verify_session
def create(self, request, environment_id, body):
log.debug(_('WebServerFarm:Create <EnvId: {0}, '
'Body: {1}>'.format(environment_id, body)))
session_id = request.context.session
create = SystemServices.create_web_server_farm
return create(body.copy(), session_id, environment_id)
@utils.verify_session
def delete(self, request, environment_id, web_server_farm_id):
log.debug(_('WebServerFarm:Delete <EnvId: {0}, '
'Id: {1}>'.format(environment_id, web_server_farm_id)))
session_id = request.context.session
delete = SystemServices.delete_service
try:
delete(web_server_farm_id, 'webServerFarms', session_id,
environment_id)
except ValueError:
raise HTTPNotFound()
def create_resource():
return wsgi.Resource(Controller())

View File

@ -1,62 +0,0 @@
# Copyright (c) 2013 Mirantis, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from muranoapi import utils
from muranoapi.db.services.systemservices import SystemServices
from muranoapi.openstack.common import wsgi
from muranoapi.openstack.common import log as logging
from webob.exc import HTTPNotFound
log = logging.getLogger(__name__)
class Controller(object):
def index(self, request, environment_id):
log.debug(_('WebServer:List <EnvId: {0}>'.format(environment_id)))
session_id = None
if hasattr(request, 'context') and request.context.session:
session_id = request.context.session
get = SystemServices.get_services
services = get(environment_id, 'webServers', session_id)
return {'webServers': services}
@utils.verify_session
def create(self, request, environment_id, body):
log.debug(_('WebServer:Create <EnvId: {0}, '
'Body: {1}>'.format(environment_id, body)))
session_id = request.context.session
create = SystemServices.create_web_server
return create(body.copy(), session_id, environment_id)
@utils.verify_session
def delete(self, request, environment_id, web_server_id):
log.debug(_('WebServer:Delete <EnvId: {0}, '
'Id: {1}>'.format(environment_id, web_server_id)))
session_id = request.context.session
delete = SystemServices.delete_service
try:
delete(web_server_id, 'webServers', session_id, environment_id)
except ValueError:
raise HTTPNotFound()
def create_resource():
return wsgi.Resource(Controller())

View File

@ -18,6 +18,27 @@ from muranoapi.openstack.common import timeutils
class CoreServices(object):
@staticmethod
def get_service_status(environment_id, service_id):
"""
Service can have one of three distinguished statuses:
- Deploying: if environment has status deploying and there is at least
one orchestration engine report for this service;
- Pending: if environment has status `deploying` and there is no
report from orchestration engine about this service;
- Ready: If environment has status ready.
:param environment_id: Service environment, we always know to which
environment service belongs to
:param service_id: Id of service for which we checking status.
:return: Service status
"""
# Now we assume that service has same status as environment.
# TODO: implement as designed and described above
return EnvironmentServices.get_status(environment_id)
@staticmethod
def get_data(environment_id, path, session_id=None):
get_description = EnvironmentServices.get_environment_description
@ -28,7 +49,13 @@ class CoreServices(object):
return []
result = TraverseHelper.get(path, env_description)
return result if result else []
if path == '/services':
get_status = CoreServices.get_service_status
for srv in result:
srv['status'] = get_status(environment_id, srv['id'])
return result
@staticmethod
def post_data(environment_id, session_id, data, path):

View File

@ -1,305 +0,0 @@
# Copyright (c) 2013 Mirantis, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
import eventlet
from muranoapi.common import config
from muranoapi.db.services.environments import EnvironmentServices
from muranoapi.openstack.common import timeutils
from muranoapi.common import uuidutils
amqp = eventlet.patcher.import_patched('amqplib.client_0_8')
rabbitmq = config.CONF.rabbitmq
class SystemServices(object):
@staticmethod
def get_service_status(environment_id, service_id):
"""
Service can have one of three distinguished statuses:
- Deploying: if environment has status deploying and there is at least
one orchestration engine report for this service;
- Pending: if environment has status `deploying` and there is no
report from orchestration engine about this service;
- Ready: If environment has status ready.
:param environment_id: Service environment, we always know to which
environment service belongs to
:param service_id: Id of service for which we checking status.
:return: Service status
"""
# Now we assume that service has same status as environment.
# TODO: implement as designed and described above
return EnvironmentServices.get_status(environment_id)
@staticmethod
def get_services(environment_id, service_type, session_id=None):
"""
Get services of specified service_type from specified environment.
If session_id is specified session state is checked, and if session is
not deployed function returns service from the modified environment.
:param environment_id: Environment Id
:param service_type: Service service_type, e.g. activeDirectories
:param session_id: Session Id
:return: Service Object List
"""
env_description = EnvironmentServices.get_environment_description(
environment_id, session_id)
if not 'services' in env_description:
return []
if service_type in env_description['services']:
services = env_description['services'][service_type]
for service in services:
service['status'] = SystemServices.get_service_status(
environment_id, None)
return services
else:
return []
@staticmethod
def get_service(environment_id, service_id, session_id=None):
"""
Get services from specified environment. If session_id is specified
session state is checked, and if session is not deployed function
returns service from the modified environment.
:param environment_id: Environment Id
:param service_id: Service Id
:param session_id: Session Id
:return: Service Object
:raise: ValueError if no services described in environment or if
service not found
"""
env_description = EnvironmentServices.get_environment_description(
environment_id, session_id)
if not 'services' in env_description:
raise ValueError('This environment does not have services')
services = []
if 'activeDirectories' in env_description['services']:
services = env_description['services']['activeDirectories']
if 'webServers' in env_description['services']:
services += env_description['services']['webServers']
if 'aspNetApps' in env_description['services']:
services += env_description['services']['aspNetApps']
if 'webServerFarms' in env_description['services']:
services += env_description['services']['webServerFarms']
if 'aspNetAppFarms' in env_description['services']:
services += env_description['services']['aspNetAppFarms']
services = filter(lambda s: s.id == service_id, services)
if len(services) > 0:
return services[0]
raise ValueError('Service with specified id does not exist')
@staticmethod
def create_active_directory(ad_params, session_id, environment_id):
"""
Creates active directory service and saves it in specified session
:param ad_params: Active Directory Params as Dict
:param session_id: Session
"""
env_description = EnvironmentServices.get_environment_description(
environment_id, session_id)
active_directory = ad_params
active_directory['id'] = uuidutils.generate_uuid()
active_directory['created'] = str(timeutils.utcnow())
active_directory['updated'] = str(timeutils.utcnow())
unit_count = 0
for unit in active_directory['units']:
unit_count += 1
unit['id'] = uuidutils.generate_uuid()
unit['name'] = 'dc{0}'.format(unit_count)
if not 'services' in env_description:
env_description['services'] = {}
if not 'activeDirectories' in env_description['services']:
env_description['services']['activeDirectories'] = []
env_description['services']['activeDirectories'].append(
active_directory)
EnvironmentServices.save_environment_description(session_id,
env_description)
return active_directory
@staticmethod
def create_web_server(ws_params, session_id, environment_id):
"""
Creates web server service and saves it in specified session
:param ws_params: Web Server Params as Dict
:param session_id: Session
"""
env_description = EnvironmentServices.get_environment_description(
environment_id, session_id)
web_server = ws_params
web_server['id'] = uuidutils.generate_uuid()
web_server['created'] = str(timeutils.utcnow())
web_server['updated'] = str(timeutils.utcnow())
unit_count = 0
for unit in web_server['units']:
unit_count += 1
unit['id'] = uuidutils.generate_uuid()
unit['name'] = web_server['name'] + '_instance_' + str(unit_count)
if not 'services' in env_description:
env_description['services'] = {}
if not 'webServers' in env_description['services']:
env_description['services']['webServers'] = []
env_description['services']['webServers'].append(web_server)
EnvironmentServices.save_environment_description(session_id,
env_description)
return web_server
@staticmethod
def create_asp_application(params, session_id, environment_id):
"""
Creates ASP.NET Application service and saves it in specified session
:param params: Params as Dict
:param session_id: Session
"""
env_description = EnvironmentServices.get_environment_description(
environment_id, session_id)
aspApp = params
aspApp['id'] = uuidutils.generate_uuid()
aspApp['created'] = str(timeutils.utcnow())
aspApp['updated'] = str(timeutils.utcnow())
unit_count = 0
for unit in aspApp['units']:
unit_count += 1
unit['id'] = uuidutils.generate_uuid()
unit['name'] = aspApp['name'] + '_instance_' + str(unit_count)
if not 'services' in env_description:
env_description['services'] = {}
if not 'aspNetApps' in env_description['services']:
env_description['services']['aspNetApps'] = []
env_description['services']['aspNetApps'].append(aspApp)
EnvironmentServices.save_environment_description(session_id,
env_description)
return aspApp
@staticmethod
def create_web_server_farm(ws_params, session_id, environment_id):
"""
Creates web server farm service and saves it in specified session
:param ws_params: Web Server Farm Params as Dict
:param session_id: Session
"""
env_description = EnvironmentServices.get_environment_description(
environment_id, session_id)
web_server_farm = ws_params
web_server_farm['id'] = uuidutils.generate_uuid()
web_server_farm['created'] = str(timeutils.utcnow())
web_server_farm['updated'] = str(timeutils.utcnow())
unit_count = 0
for unit in web_server_farm['units']:
unit_count += 1
unit['id'] = uuidutils.generate_uuid()
unit['name'] = web_server_farm['name'] + '_instance_' + \
str(unit_count)
if not 'services' in env_description:
env_description['services'] = {}
if not 'webServerFarms' in env_description['services']:
env_description['services']['webServerFarms'] = []
env_description['services']['webServerFarms'].append(web_server_farm)
EnvironmentServices.save_environment_description(session_id,
env_description)
return web_server_farm
@staticmethod
def create_asp_application_farm(params, session_id, environment_id):
"""
Creates ASP.NET Application Farm service and saves it in
specified session
:param params: Params as Dict
:param session_id: Session
"""
env_description = EnvironmentServices.get_environment_description(
environment_id, session_id)
aspApp_farm = params
aspApp_farm['id'] = uuidutils.generate_uuid()
aspApp_farm['created'] = str(timeutils.utcnow())
aspApp_farm['updated'] = str(timeutils.utcnow())
unit_count = 0
for unit in aspApp_farm['units']:
unit_count += 1
unit['id'] = uuidutils.generate_uuid()
unit['name'] = aspApp_farm['name'] + '_instance_' + str(unit_count)
if not 'services' in env_description:
env_description['services'] = {}
if not 'aspNetAppFarms' in env_description['services']:
env_description['services']['aspNetAppFarms'] = []
env_description['services']['aspNetAppFarms'].append(aspApp_farm)
EnvironmentServices.save_environment_description(session_id,
env_description)
return aspApp_farm
@staticmethod
def delete_service(service_id, service_type, session_id, environment_id):
env_description = EnvironmentServices.get_environment_description(
environment_id, session_id)
if not 'services' in env_description:
raise NameError('This environment does not have services')
services = []
if service_type in env_description['services']:
services = env_description['services'][service_type]
if service_id not in [srv['id'] for srv in services]:
raise ValueError('Specified service does not exist')
services = [srv for srv in services if srv['id'] != service_id]
env_description['services'][service_type] = services
EnvironmentServices.save_environment_description(session_id,
env_description)

View File

@ -1,13 +0,0 @@
# Copyright (c) 2013 Mirantis, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.

View File

@ -1,20 +0,0 @@
# Copyright (c) 2013 Mirantis, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
import unittest
class Test(unittest.TestCase):
def test(self):
assert True

View File

@ -1,41 +0,0 @@
# Copyright (c) 2013 Mirantis, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
import unittest2
from mock import MagicMock
import muranoapi.api.v1.router as router
def my_mock(link, controller, action, conditions, path=''):
return [link, controller, action, conditions, path]
def func_mock():
return True
class SanityUnitTests(unittest2.TestCase):
def test_api(self):
router.webservers = MagicMock(create_resource=func_mock)
router.aspNetApps = MagicMock(create_resource=func_mock)
router.sessions = MagicMock(create_resource=func_mock)
router.active_directories = MagicMock(create_resource=func_mock)
router.environments = MagicMock(create_resource=func_mock)
mapper = MagicMock(connect=my_mock)
object = router.API(mapper)
assert object._router is not None