You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ariatosca.apache.org by av...@apache.org on 2017/04/19 12:36:07 UTC
[4/4] incubator-ariatosca git commit: Partial fixes for cli tests
Partial fixes for cli tests
Project: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/commit/e17916e1
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/e17916e1
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/e17916e1
Branch: refs/heads/cli-tests
Commit: e17916e1938bb54522d1e5fb9d4d3256930486fd
Parents: 54b5a9f
Author: Avia Efrat <av...@gigaspaces.com>
Authored: Wed Apr 19 15:34:27 2017 +0300
Committer: Avia Efrat <av...@gigaspaces.com>
Committed: Wed Apr 19 15:35:57 2017 +0300
----------------------------------------------------------------------
aria/cli/commands/service_templates.py | 9 +++++----
aria/cli/commands/services.py | 2 +-
aria/storage/sql_mapi.py | 22 ++++++----------------
3 files changed, 12 insertions(+), 21 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/e17916e1/aria/cli/commands/service_templates.py
----------------------------------------------------------------------
diff --git a/aria/cli/commands/service_templates.py b/aria/cli/commands/service_templates.py
index 189ba51..97367c2 100644
--- a/aria/cli/commands/service_templates.py
+++ b/aria/cli/commands/service_templates.py
@@ -65,9 +65,10 @@ def show(service_template_name, model_storage, logger):
logger.info('{0}{1}'.format(service_template_dict['description'].encode('UTF-8') or '',
os.linesep))
- logger.info('Existing services:')
- for service in service_template.services:
- logger.info('\t{0}'.format(service.name))
+ if service_template.services:
+ logger.info('Existing services:')
+ for service in service_template.services:
+ logger.info('\t{0}'.format(service.name))
@service_templates.command(name='list',
@@ -83,7 +84,7 @@ def list(sort_by, descending, model_storage, logger):
logger.info('Listing all service templates...')
service_templates_list = model_storage.service_template.list(
- sort=utils.storage_sort_param(sort_by, descending)).items
+ sort=utils.storage_sort_param(sort_by, descending))
column_formatters = \
dict(description=table.trim_formatter_generator(DESCRIPTION_FIELD_LENGTH_LIMIT))
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/e17916e1/aria/cli/commands/services.py
----------------------------------------------------------------------
diff --git a/aria/cli/commands/services.py b/aria/cli/commands/services.py
index 1aa99f3..81bef7d 100644
--- a/aria/cli/commands/services.py
+++ b/aria/cli/commands/services.py
@@ -19,9 +19,9 @@ from StringIO import StringIO
from . import service_templates
from .. import helptexts
-from .. import table
from .. import utils
from ..core import aria
+from ..table import print_data
from ...core import Core
from ...modeling import exceptions as modeling_exceptions
from ...storage import exceptions as storage_exceptions
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/e17916e1/aria/storage/sql_mapi.py
----------------------------------------------------------------------
diff --git a/aria/storage/sql_mapi.py b/aria/storage/sql_mapi.py
index 144c925..730d007 100644
--- a/aria/storage/sql_mapi.py
+++ b/aria/storage/sql_mapi.py
@@ -92,10 +92,8 @@ class SQLAlchemyModelAPI(api.ModelAPI):
results, total, size, offset = self._paginate(query, pagination)
return ListResult(
- items=results,
- metadata=dict(total=total,
- size=size,
- offset=offset)
+ dict(total=total, size=size, offset=offset),
+ results
)
def iter(self,
@@ -406,19 +404,11 @@ def init_storage(base_dir, filename='db.sqlite'):
return dict(engine=engine, session=session)
-class ListResult(object):
+class ListResult(list):
"""
a ListResult contains results about the requested items.
"""
- def __init__(self, items, metadata):
- self.items = items
+ def __init__(self, metadata, *args, **qwargs):
+ super(ListResult, self).__init__(*args, **qwargs)
self.metadata = metadata
-
- def __len__(self):
- return len(self.items)
-
- def __iter__(self):
- return iter(self.items)
-
- def __getitem__(self, item):
- return self.items[item]
+ self.items = self