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:34:57 UTC

incubator-ariatosca git commit: Partial fixes for cli tests

Repository: incubator-ariatosca
Updated Branches:
  refs/heads/cli-tests ed07f9f27 -> 0a829ae9e


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/0a829ae9
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/0a829ae9
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/0a829ae9

Branch: refs/heads/cli-tests
Commit: 0a829ae9e41cca2ff2ddc7cc1541570834732fd8
Parents: ed07f9f
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:34:27 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/0a829ae9/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/0a829ae9/aria/cli/commands/services.py
----------------------------------------------------------------------
diff --git a/aria/cli/commands/services.py b/aria/cli/commands/services.py
index e1569a6..858fb88 100644
--- a/aria/cli/commands/services.py
+++ b/aria/cli/commands/services.py
@@ -18,8 +18,8 @@ import os
 from StringIO import StringIO
 
 from . import service_templates
-from .. import helptexts
 from .. import utils
+from .. import helptexts
 from ..core import aria
 from ..table import print_data
 from ...core import Core

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/0a829ae9/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