aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--moonclient/Changelog5
-rw-r--r--moonclient/moonclient/__init__.py1
-rw-r--r--moonclient/moonclient/shell.py53
-rw-r--r--moonclient/moonclient/tests.py2
-rw-r--r--moonclient/setup.py6
5 files changed, 24 insertions, 43 deletions
diff --git a/moonclient/Changelog b/moonclient/Changelog
index 0ba076cc..f641f3ad 100644
--- a/moonclient/Changelog
+++ b/moonclient/Changelog
@@ -7,6 +7,11 @@
CHANGES
=======
+0.3.0
+-----
+
+* Return code matches now the number of error occurred during tests
+
0.2.0
-----
diff --git a/moonclient/moonclient/__init__.py b/moonclient/moonclient/__init__.py
index e69de29b..493f7415 100644
--- a/moonclient/moonclient/__init__.py
+++ b/moonclient/moonclient/__init__.py
@@ -0,0 +1 @@
+__version__ = "0.3.0"
diff --git a/moonclient/moonclient/shell.py b/moonclient/moonclient/shell.py
index f3d87ba3..d1d02518 100644
--- a/moonclient/moonclient/shell.py
+++ b/moonclient/moonclient/shell.py
@@ -11,42 +11,7 @@ import os
from cliff.app import App
from cliff.commandmanager import CommandManager
-from cliff.formatters.base import ListFormatter, SingleFormatter
-
-
-class _JSONFormatter(ListFormatter, SingleFormatter):
-
- def add_argument_group(self, parser):
- group = parser.add_argument_group(title='json formatter')
- group.add_argument(
- '--noindent',
- action='store_true',
- dest='noindent',
- help='whether to disable indenting the JSON'
- )
- group.add_argument(
- '--projectname',
- help='Set the project name'
- )
-
- def emit_list(self, column_names, data, stdout, parsed_args):
- items = []
- import time
- for item in data:
- element = dict(zip(column_names, item))
- element["project_name"] = parsed_args.projectname
- element["name"] = element.pop("test_name")
- element["url"] = ""
- element["_id"] = ""
- element["creation_date"] = time.strftime("%Y-%m-%d %H:%M:%S")
- items.append(element)
- indent = None if parsed_args.noindent else 2
- json.dump({"testcases": items}, stdout, indent=indent)
-
- def emit_one(self, column_names, data, stdout, parsed_args):
- one = dict(zip(column_names, data))
- indent = None if parsed_args.noindent else 2
- json.dump(one, stdout, indent=indent)
+import moonclient
def get_env_creds(admin_token=False):
@@ -76,6 +41,7 @@ class MoonClient(App):
secureprotocol = False
user_saving_file = ".moonclient"
url_prefix = "/moon"
+ _nb_error = 0
post = {
"auth": {
"identity": {
@@ -106,7 +72,7 @@ class MoonClient(App):
def __init__(self):
super(MoonClient, self).__init__(
description='Moon Python Client',
- version='0.2.0',
+ version=moonclient.__version__,
command_manager=CommandManager('moon.client'),
)
creds = get_env_creds()
@@ -165,6 +131,14 @@ class MoonClient(App):
self._intraextension = value
open(os.path.join(os.getenv('HOME'), self.user_saving_file), "w").write(value)
+ @property
+ def nb_error(self):
+ return self._nb_error
+
+ def incr_error(self):
+ self._nb_error += 1
+ print("INCREMENTING ERRORS {}".format(self._nb_error))
+
def get_tenant_uuid(self, tenant_name):
return self.get_url("/v3/projects?name={}".format(tenant_name), authtoken=True, port=5000)["projects"][0]["id"]
@@ -266,8 +240,6 @@ class MoonClient(App):
data = self.get_url("/v3/auth/tokens", post_data=self.post)
if "token" not in data:
raise Exception("Authentication problem ({})".format(data))
- from cliff.formatters.json_format import JSONFormatter
- JSONFormatter = _JSONFormatter
def prepare_to_run_command(self, cmd):
self.log.debug('prepare_to_run_command %s', cmd.__class__.__name__)
@@ -281,7 +253,8 @@ class MoonClient(App):
def main(argv=sys.argv[1:]):
myapp = MoonClient()
- return myapp.run(argv)
+ myapp.run(argv)
+ return myapp.nb_error
if __name__ == '__main__':
diff --git a/moonclient/moonclient/tests.py b/moonclient/moonclient/tests.py
index f312eed2..de93dc6f 100644
--- a/moonclient/moonclient/tests.py
+++ b/moonclient/moonclient/tests.py
@@ -203,6 +203,7 @@ class TestsLaunch(Lister):
overall_result = overall_result and True
else:
compare = "\033[1m\033[31mFalse\033[m"
+ self.app.incr_error()
overall_result = overall_result and False
else:
overall_result = overall_result and compare
@@ -213,6 +214,7 @@ class TestsLaunch(Lister):
compare = "\033[mTrue\033[m"
else:
compare = "\033[1m\033[31mFalse\033[m"
+ self.app.incr_error()
data_tmp.append(compare)
data_tmp.append(test["description"])
data.append(data_tmp)
diff --git a/moonclient/setup.py b/moonclient/setup.py
index 71ea704b..0b93c4d3 100644
--- a/moonclient/setup.py
+++ b/moonclient/setup.py
@@ -5,13 +5,13 @@
# This software is distributed under the terms and conditions of the 'Apache-2.0'
# license which can be found in the file 'LICENSE' in this package distribution
# or at 'http://www.apache.org/licenses/LICENSE-2.0'.
+from setuptools import setup, find_packages
+from moonclient import __version__
PROJECT = 'python-moonclient'
# Change docs/sphinx/conf.py too!
-VERSION = '0.1'
-
-from setuptools import setup, find_packages
+VERSION = __version__
try:
long_description = open('README.rst', 'rt').read()