31ed10aa18
* Refactored tests hierarcy (moved get_resource to the base class) * Fixed logic in abstract engine (transaction scoope was wrong) * Added stub methods for context manipulations (not everywhere yet) * Refactored actions * Created ECHO action to be able to emulate required output * Added simple data flow test (two dependent tasks) TODO: * More tests * Refactor actions according to the latest discussions Change-Id: I5ba5e330110889014eeca53501ddae54dc9a1236
62 lines
1.7 KiB
Python
62 lines
1.7 KiB
Python
# -*- coding: utf-8 -*-
|
|
#
|
|
# Copyright 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
|
|
import pkg_resources as pkg
|
|
import os
|
|
import tempfile
|
|
|
|
from mistral import version
|
|
from mistral.db.sqlalchemy import api as db_api
|
|
from mistral.openstack.common.db.sqlalchemy import session
|
|
|
|
|
|
RESOURCES_PATH = 'tests/resources/'
|
|
|
|
|
|
def get_resource(resource_name):
|
|
return open(pkg.resource_filename(
|
|
version.version_info.package,
|
|
RESOURCES_PATH + resource_name)).read()
|
|
|
|
|
|
class BaseTest(unittest2.TestCase):
|
|
def setUp(self):
|
|
super(BaseTest, self).setUp()
|
|
|
|
# TODO: add whatever is needed for all Mistral tests in here
|
|
|
|
def tearDown(self):
|
|
super(BaseTest, self).tearDown()
|
|
|
|
# TODO: add whatever is needed for all Mistral tests in here
|
|
|
|
|
|
class DbTestCase(BaseTest):
|
|
|
|
def setUp(self):
|
|
self.db_fd, self.db_path = tempfile.mkstemp()
|
|
session.set_defaults('sqlite:///' + self.db_path, self.db_path)
|
|
db_api.setup_db()
|
|
|
|
def tearDown(self):
|
|
db_api.drop_db()
|
|
os.close(self.db_fd)
|
|
os.unlink(self.db_path)
|
|
|
|
def is_db_session_open(self):
|
|
return db_api._get_thread_local_session() is not None
|