summaryrefslogtreecommitdiffstats
path: root/result_collection_api/tornado_swagger_ui/example
diff options
context:
space:
mode:
authorSerenaFeng <feng.xiaowei@zte.com.cn>2016-05-26 14:30:24 +0800
committerSerenaFeng <feng.xiaowei@zte.com.cn>2016-05-26 15:22:48 +0800
commitc8be4b557e51316a3cd0cc54d962c86619e4cbaa (patch)
tree5bc535103f89edb99a01f7b5b0b7975d0e341e74 /result_collection_api/tornado_swagger_ui/example
parentb140bd0f8055af4f1624a2c9a6291f7923003122 (diff)
eliminate flake8 violation in testAPI except dashboard dir
JIRA: FUNCTEST-262 Change-Id: Ib77bb080111392b8e3248c5e6152f55c12b8c67c Signed-off-by: SerenaFeng <feng.xiaowei@zte.com.cn>
Diffstat (limited to 'result_collection_api/tornado_swagger_ui/example')
-rw-r--r--result_collection_api/tornado_swagger_ui/example/basic.py34
1 files changed, 19 insertions, 15 deletions
diff --git a/result_collection_api/tornado_swagger_ui/example/basic.py b/result_collection_api/tornado_swagger_ui/example/basic.py
index 1731bfd..93ff00b 100644
--- a/result_collection_api/tornado_swagger_ui/example/basic.py
+++ b/result_collection_api/tornado_swagger_ui/example/basic.py
@@ -22,15 +22,21 @@ class PropertySubclass:
class Item:
"""
@description:
- This is an example of a model class that has parameters in its constructor
- and the fields in the swagger spec are derived from the parameters to __init__.
+ This is an example of a model class that has parameters in its
+ constructor and the fields in the swagger spec are derived from
+ the parameters to __init__.
@notes:
- In this case we would have property1, name as required parameters and property3 as optional parameter.
+ In this case we would have property1, name as required parameters
+ and property3 as optional parameter.
@property property3: Item description
@ptype property3: L{PropertySubclass}
@ptype property4: C{list} of L{PropertySubclass}
"""
- def __init__(self, property1, property2=None, property3=None, property4=None):
+ def __init__(self,
+ property1,
+ property2=None,
+ property3=None,
+ property4=None):
self.property1 = property1
self.property2 = property2
self.property3 = property3
@@ -78,17 +84,17 @@ class GenericApiHandler(RequestHandler):
pass
def prepare(self):
- if not (self.request.method == "GET" or self.request.method == "DELETE"):
- if self.request.headers.get("Content-Type") is not None:
- if self.request.headers["Content-Type"].startswith(DEFAULT_REPRESENTATION):
+ if self.request.method != "GET" and self.request.method != "DELETE":
+ self.json_args = None
+ content_type = self.request.headers.get("Content-Type")
+ if content_type is not None:
+ if content_type.startswith(DEFAULT_REPRESENTATION):
try:
self.json_args = json.loads(self.request.body)
except (ValueError, KeyError, TypeError) as error:
raise HTTPError(HTTP_BAD_REQUEST,
"Bad Json format [{}]".
format(error))
- else:
- self.json_args = None
def finish_request(self, json_object):
self.write(json.dumps(json_object))
@@ -138,7 +144,8 @@ class ItemHandler(GenericApiHandler):
@notes:
get a item,
- This will be added to the Implementation Notes.It lets you put very long text in your api.
+ This will be added to the Implementation Notes.
+ It lets you put very long text in your api.
"""
self.finish_request(items[arg].format_http())
@@ -148,8 +155,6 @@ class ItemHandler(GenericApiHandler):
@description: delete a item
@notes:
delete a item in items
-
- This will be added to the Implementation Notes.It lets you put very long text in your api.
"""
del items[arg]
self.finish_request("success")
@@ -161,8 +166,7 @@ class ItemOptionParamHandler(GenericApiHandler):
"""
@return 200: case is created
"""
- print("ProjectHandler.post: %s -- %s -- %s" % (arg1, arg2, self.request.full_url()))
- fs = open("/home/swagger/tornado-rest-swagger/%s/%s" % (arg1, arg2), "wb")
+ fs = open("/home/%s/%s" % (arg1, arg2), "wb")
fs.write(self.request.body)
self.write("success")
@@ -193,7 +197,7 @@ class ItemQueryHandler(GenericApiHandler):
res.append(value.format_http())
elif value.property2 == property2:
res.append(value.format_http())
- elif items.has_key(property1):
+ elif property1 in items:
if items.get(property1).property2 == property2:
res.append(items.get(property1).format_http())