diff --git a/murano/api/v1/templates.py b/murano/api/v1/templates.py index f765010e..6f27b16c 100644 --- a/murano/api/v1/templates.py +++ b/murano/api/v1/templates.py @@ -22,7 +22,7 @@ from murano.common.i18n import _, _LE from murano.common import policy from murano.common import utils from murano.common import wsgi -from murano.db.models import EnvironmentTemplate +from murano.db import models from murano.db.services import core_services from murano.db.services import environment_templates as env_temps from murano.db.services import environments as envs @@ -59,8 +59,8 @@ class Controller(object): get_env_templates_by(filters) else: - filters = (EnvironmentTemplate.is_public, - EnvironmentTemplate.tenant_id == tenant_id) + filters = (models.EnvironmentTemplate.is_public, + models.EnvironmentTemplate.tenant_id == tenant_id) list_templates = env_temps.EnvTemplateServices.\ get_env_templates_or_by(filters) diff --git a/murano/db/session.py b/murano/db/session.py index 1ca6fc64..11b751a1 100644 --- a/murano/db/session.py +++ b/murano/db/session.py @@ -21,7 +21,7 @@ from oslo_db import options from oslo_db.sqlalchemy import session as db_session from oslo_utils import timeutils -from murano.db.models import Lock +from murano.db import models CONF = cfg.CONF @@ -68,11 +68,11 @@ def _get_or_create_lock(name, session, nested, retry=0): session.begin_nested() else: session.begin() - existing = session.query(Lock).get(name) + existing = session.query(models.Lock).get(name) if existing is None: try: # no lock found, creating a new one - lock = Lock(id=name, ts=timeutils.utcnow()) + lock = models.Lock(id=name, ts=timeutils.utcnow()) lock.save(session) return session.transaction # lock created and acquired diff --git a/murano/tests/unit/dsl/test_logger.py b/murano/tests/unit/dsl/test_logger.py index 8fb34ac3..8ff8f8ba 100644 --- a/murano/tests/unit/dsl/test_logger.py +++ b/murano/tests/unit/dsl/test_logger.py @@ -13,9 +13,7 @@ # License for the specific language governing permissions and limitations # under the License. -from mock import ANY -from mock import MagicMock -from mock.mock import call +import mock from murano.dsl import helpers from murano.engine.system import logger @@ -26,12 +24,12 @@ from murano.tests.unit.dsl.foundation import test_case class TestLogger(test_case.DslTestCase): FORMAT_CALLS = [ - call(ANY, 'str', (), {}), - call(ANY, u'тест', (), {}), - call(ANY, 'str', (1,), {}), - call(ANY, 'str {0}', ('message',), {}), - call(ANY, 'str {message}', (), {'message': 'message'}), - call(ANY, 'str {message}{0}', (), {})] + mock.call(mock.ANY, 'str', (), {}), + mock.call(mock.ANY, u'тест', (), {}), + mock.call(mock.ANY, 'str', (1,), {}), + mock.call(mock.ANY, 'str {0}', ('message',), {}), + mock.call(mock.ANY, 'str {message}', (), {'message': 'message'}), + mock.call(mock.ANY, 'str {message}{0}', (), {})] LOG_CALLS = FORMAT_CALLS @@ -51,14 +49,14 @@ class TestLogger(test_case.DslTestCase): logger_instance = self._runner.testCreate() logger_ext = logger_instance.extension - underlying_logger_mock = MagicMock() + underlying_logger_mock = mock.MagicMock() logger_ext._underlying_logger = underlying_logger_mock logger_ext._underlying_logger.return_value = None - format_mock = MagicMock(return_value='format_mock') + format_mock = mock.MagicMock(return_value='format_mock') # do not verify number of conversions to string - format_mock.__str__ = MagicMock(return_value='format_mock') - format_mock.__unicode__ = MagicMock(return_value='format_mock') + format_mock.__str__ = mock.MagicMock(return_value='format_mock') + format_mock.__unicode__ = mock.MagicMock(return_value='format_mock') logger_ext._format_without_exceptions = format_mock @@ -67,7 +65,7 @@ class TestLogger(test_case.DslTestCase): def test_trace(self): logger_instance, format_mock, underlying_logger_mock \ = self._create_logger_mock() - log_method = MagicMock() + log_method = mock.MagicMock() underlying_logger_mock.trace = log_method self._runner.testTrace(logger_instance) @@ -78,7 +76,7 @@ class TestLogger(test_case.DslTestCase): def test_debug(self): logger_instance, format_mock, underlying_logger_mock \ = self._create_logger_mock() - log_method = MagicMock() + log_method = mock.MagicMock() underlying_logger_mock.debug = log_method self._runner.testDebug(logger_instance) @@ -89,7 +87,7 @@ class TestLogger(test_case.DslTestCase): def test_info(self): logger_instance, format_mock, underlying_logger_mock \ = self._create_logger_mock() - log_method = MagicMock() + log_method = mock.MagicMock() underlying_logger_mock.info = log_method self._runner.testInfo(logger_instance) @@ -100,7 +98,7 @@ class TestLogger(test_case.DslTestCase): def test_warning(self): logger_instance, format_mock, underlying_logger_mock \ = self._create_logger_mock() - log_method = MagicMock() + log_method = mock.MagicMock() underlying_logger_mock.warning = log_method self._runner.testWarning(logger_instance) @@ -111,7 +109,7 @@ class TestLogger(test_case.DslTestCase): def test_error(self): logger_instance, format_mock, underlying_logger_mock \ = self._create_logger_mock() - log_method = MagicMock() + log_method = mock.MagicMock() underlying_logger_mock.error = log_method self._runner.testError(logger_instance) @@ -122,7 +120,7 @@ class TestLogger(test_case.DslTestCase): def test_critical(self): logger_instance, format_mock, underlying_logger_mock \ = self._create_logger_mock() - log_method = MagicMock() + log_method = mock.MagicMock() underlying_logger_mock.critical = log_method self._runner.testCritical(logger_instance) @@ -133,7 +131,7 @@ class TestLogger(test_case.DslTestCase): def test_exception(self): logger_instance, format_mock, underlying_logger_mock = \ self._create_logger_mock() - log_method = MagicMock() + log_method = mock.MagicMock() underlying_logger_mock.error = log_method self._runner.testException(logger_instance)