summaryrefslogtreecommitdiffstats
path: root/testapi/testapi-client/testapiclient
diff options
context:
space:
mode:
authorSerenaFeng <feng.xiaowei@zte.com.cn>2018-03-07 11:00:15 +0800
committerSerenaFeng <feng.xiaowei@zte.com.cn>2018-03-07 12:50:28 +0800
commit9e8fc209687d84385addba81329ef478e19f8368 (patch)
tree4a98a2bd99264a4349f6daabe09bef92bee5fd5f /testapi/testapi-client/testapiclient
parent8d3328530fce2b9f97f26d4f1752addc45cf4411 (diff)
add too long line check in pep8
Change-Id: I13bd62699c14bb504751b2e1149de0812b771ba0 Signed-off-by: SerenaFeng <feng.xiaowei@zte.com.cn>
Diffstat (limited to 'testapi/testapi-client/testapiclient')
-rw-r--r--testapi/testapi-client/testapiclient/auth.py12
-rw-r--r--testapi/testapi-client/testapiclient/authHandler.py5
-rw-r--r--testapi/testapi-client/testapiclient/httpClient.py12
-rw-r--r--testapi/testapi-client/testapiclient/pods.py49
-rw-r--r--testapi/testapi-client/testapiclient/projects.py74
-rw-r--r--testapi/testapi-client/testapiclient/tests/__init__.py0
-rw-r--r--testapi/testapi-client/testapiclient/tests/unit/__init__.py0
-rw-r--r--testapi/testapi-client/testapiclient/tests/unit/test_placeholder.py6
8 files changed, 121 insertions, 37 deletions
diff --git a/testapi/testapi-client/testapiclient/auth.py b/testapi/testapi-client/testapiclient/auth.py
index 7799d60..6f51231 100644
--- a/testapi/testapi-client/testapiclient/auth.py
+++ b/testapi/testapi-client/testapiclient/auth.py
@@ -10,13 +10,19 @@ class Auth(Command):
def get_parser(self, prog_name):
parser = super(Auth, self).get_parser(prog_name)
- parser.add_argument('-u', type=str, required=True, help='Username for authentication')
- parser.add_argument('-p', type=str, required=True, help='Password for authentication')
+ parser.add_argument('-u',
+ type=str,
+ required=True,
+ help='Username for authentication')
+ parser.add_argument('-p',
+ type=str,
+ required=True,
+ help='Password for authentication')
return parser
def take_action(self, parsed_args):
response = AuthHandler.authenticate(parsed_args.u, parsed_args.p)
if "login" in response.text:
- print "Authentication has failed. Please check your username and password."
+ print "Authentication has failed."
else:
print "Authentication has been successful!"
diff --git a/testapi/testapi-client/testapiclient/authHandler.py b/testapi/testapi-client/testapiclient/authHandler.py
index a421cf8..baa1088 100644
--- a/testapi/testapi-client/testapiclient/authHandler.py
+++ b/testapi/testapi-client/testapiclient/authHandler.py
@@ -9,7 +9,10 @@ class AuthHandler:
@staticmethod
def authenticate(username, password):
session = requests.Session()
- hostname = Config.config.get("cas", "auth_url") + urllib.quote(Config.config.get("api", "url")) + Config.config.get("cas", "signin_return")
+ hostname = '{}{}{}'.format(
+ Config.config.get("cas", "auth_url"),
+ urllib.quote(Config.config.get("api", "url")),
+ Config.config.get("cas", "signin_return"))
data = {'name': username, 'pass': password, 'form_id': 'user_login'}
response = session.post(hostname, data)
User.session = session
diff --git a/testapi/testapi-client/testapiclient/httpClient.py b/testapi/testapi-client/testapiclient/httpClient.py
index bc45f36..69d94a4 100644
--- a/testapi/testapi-client/testapiclient/httpClient.py
+++ b/testapi/testapi-client/testapiclient/httpClient.py
@@ -29,16 +29,22 @@ class HTTPClient():
return r.text
def post(self, url, session, data):
- r = session.post(url, data=json.dumps(data), headers=HTTPClient.headers)
+ r = session.post(url,
+ data=json.dumps(data),
+ headers=HTTPClient.headers)
return r
def put(self, url, session, data):
- r = session.put(url, data=json.dumps(data), headers=HTTPClient.headers)
+ r = session.put(url,
+ data=json.dumps(data),
+ headers=HTTPClient.headers)
return r.text
def delete(self, url, session, *args):
if(args.__len__ > 0):
- r = session.delete(url, data=json.dumps(args[0]), headers=HTTPClient.headers)
+ r = session.delete(url,
+ data=json.dumps(args[0]),
+ headers=HTTPClient.headers)
else:
r = session.delete(url)
return r.text
diff --git a/testapi/testapi-client/testapiclient/pods.py b/testapi/testapi-client/testapiclient/pods.py
index f5e2fe9..6c8aaed 100644
--- a/testapi/testapi-client/testapiclient/pods.py
+++ b/testapi/testapi-client/testapiclient/pods.py
@@ -16,7 +16,9 @@ class PodGet(PodBase):
def get_parser(self, prog_name):
parser = super(PodGet, self).get_parser(prog_name)
- parser.add_argument('-name', default='', help='Search pods using name')
+ parser.add_argument('-name',
+ default='',
+ help='Search pods using name')
return parser
def take_action(self, parsed_args):
@@ -33,7 +35,10 @@ class PodGetOne(PodBase):
def get_parser(self, prog_name):
parser = super(PodGetOne, self).get_parser(prog_name)
- parser.add_argument('-name', default='', help='Find pod using name', required=True)
+ parser.add_argument('-name',
+ default='',
+ help='Find pod using name',
+ required=True)
return parser
def take_action(self, parsed_args):
@@ -47,9 +52,19 @@ class PodCreate(PodBase):
def get_parser(self, prog_name):
parser = super(PodCreate, self).get_parser(prog_name)
- parser.add_argument('-u', type=str, help='Username for authentication')
- parser.add_argument('-p', type=str, help='Password for authentication')
- parser.add_argument('pod', type=json.loads, help='Pod create request format :\n\'{ "role": "", "name": "", "details": "", "mode": ""}\',\n role should be either "community-ci" or "production-ci", and mode should be either "metal" or "virtual.')
+ parser.add_argument('-u',
+ type=str,
+ help='Username for authentication')
+ parser.add_argument('-p',
+ type=str,
+ help='Password for authentication')
+ parser.add_argument('pod',
+ type=json.loads,
+ help='Pod create request format :\n'
+ '\'{"role": "", "name": "", "details": "", '
+ '"mode": ""}\',\n role should be either '
+ '"community-ci" or "production-ci", and '
+ 'mode should be either "metal" or "virtual.')
return parser
def take_action(self, parsed_args):
@@ -57,9 +72,11 @@ class PodCreate(PodBase):
if(parsed_args.u and parsed_args.p):
response = AuthHandler.authenticate(parsed_args.u, parsed_args.p)
if "login" in response.text:
- print "Authentication has failed. Please check your username and password."
+ print "Authentication has failed."
return
- response = http_client.post(PodCreate.pods_url, User.session, parsed_args.pod)
+ response = http_client.post(PodCreate.pods_url,
+ User.session,
+ parsed_args.pod)
if response.status_code == 200:
print "Pod has been successfully created!"
else:
@@ -71,9 +88,16 @@ class PodDelete(PodBase):
def get_parser(self, prog_name):
parser = super(PodDelete, self).get_parser(prog_name)
- parser.add_argument('-u', type=str, help='Username for authentication')
- parser.add_argument('-p', type=str, help='Password for authentication')
- parser.add_argument('-name', type=str, required=True, help='Delete pods using name')
+ parser.add_argument('-u',
+ type=str,
+ help='Username for authentication')
+ parser.add_argument('-p',
+ type=str,
+ help='Password for authentication')
+ parser.add_argument('-name',
+ type=str,
+ required=True,
+ help='Delete pods using name')
return parser
def take_action(self, parsed_args):
@@ -81,7 +105,8 @@ class PodDelete(PodBase):
if(parsed_args.u and parsed_args.p):
response = AuthHandler.authenticate(parsed_args.u, parsed_args.p)
if "login" in response.text:
- print "Authentication has failed. Please check your username and password."
+ print "Authentication has failed."
return
- pods = http_client.delete(PodDelete.pods_url + "/" + parsed_args.name, User.session)
+ pods = http_client.delete(PodDelete.pods_url + "/" + parsed_args.name,
+ User.session)
print pods
diff --git a/testapi/testapi-client/testapiclient/projects.py b/testapi/testapi-client/testapiclient/projects.py
index 57def5d..eedfa3d 100644
--- a/testapi/testapi-client/testapiclient/projects.py
+++ b/testapi/testapi-client/testapiclient/projects.py
@@ -14,7 +14,9 @@ class ProjectGet(ProjectBase):
def get_parser(self, prog_name):
parser = super(ProjectGet, self).get_parser(prog_name)
- parser.add_argument('-name', default='', help='Search projects by name')
+ parser.add_argument('-name',
+ default='',
+ help='Search projects by name')
return parser
def take_action(self, parsed_args):
@@ -30,7 +32,10 @@ class ProjectGetOne(ProjectBase):
def get_parser(self, prog_name):
parser = super(ProjectGetOne, self).get_parser(prog_name)
- parser.add_argument('-name', default='', required=True, help='Search project by name')
+ parser.add_argument('-name',
+ default='',
+ required=True,
+ help='Search project by name')
return parser
def take_action(self, parsed_args):
@@ -44,9 +49,17 @@ class ProjectCreate(ProjectBase):
def get_parser(self, prog_name):
parser = super(ProjectCreate, self).get_parser(prog_name)
- parser.add_argument('-u', type=str, help='Username for authentication')
- parser.add_argument('-p', type=str, help='Password for authentication')
- parser.add_argument('project', type=json.loads, help='Project create request format :{ "name": (required)"", "description": (optional)""}')
+ parser.add_argument('-u',
+ type=str,
+ help='Username for authentication')
+ parser.add_argument('-p',
+ type=str,
+ help='Password for authentication')
+ parser.add_argument('project',
+ type=json.loads,
+ help='Project create request format :{'
+ ' "name": (required)"", '
+ '"description": (optional)""}')
return parser
def take_action(self, parsed_args):
@@ -54,9 +67,11 @@ class ProjectCreate(ProjectBase):
if(parsed_args.u and parsed_args.p):
response = AuthHandler.authenticate(parsed_args.u, parsed_args.p)
if "login" in response.text:
- print "Authentication has failed. Please check your username and password."
+ print "Authentication has failed."
return
- response = httpClient.post(ProjectCreate.projects_url, User.session, parsed_args.project)
+ response = httpClient.post(ProjectCreate.projects_url,
+ User.session,
+ parsed_args.project)
if response.status_code == 200:
print "Project has been successfully created!"
else:
@@ -67,9 +82,16 @@ class ProjectDelete(ProjectBase):
def get_parser(self, prog_name):
parser = super(ProjectDelete, self).get_parser(prog_name)
- parser.add_argument('-u', type=str, help='Username for authentication')
- parser.add_argument('-p', type=str, help='Password for authentication')
- parser.add_argument('-name', type=str, required=True, help='Delete project by name')
+ parser.add_argument('-u',
+ type=str,
+ help='Username for authentication')
+ parser.add_argument('-p',
+ type=str,
+ help='Password for authentication')
+ parser.add_argument('-name',
+ type=str,
+ required=True,
+ help='Delete project by name')
return parser
def take_action(self, parsed_args):
@@ -77,9 +99,11 @@ class ProjectDelete(ProjectBase):
if(parsed_args.u and parsed_args.p):
response = AuthHandler.authenticate(parsed_args.u, parsed_args.p)
if "login" in response.text:
- print "Authentication has failed. Please check your username and password."
+ print "Authentication has failed."
return
- projects = httpClient.delete(ProjectDelete.projects_url + "/" + parsed_args.name, User.session)
+ projects = httpClient.delete(
+ ProjectDelete.projects_url + "/" + parsed_args.name,
+ User.session)
print projects
@@ -87,10 +111,21 @@ class ProjectPut(ProjectBase):
def get_parser(self, prog_name):
parser = super(ProjectPut, self).get_parser(prog_name)
- parser.add_argument('-u', type=str, help='Username for authentication')
- parser.add_argument('-p', type=str, help='Password for authentication')
- parser.add_argument('-name', type=str, required=True, help='Update project by name')
- parser.add_argument('project', type=json.loads, help='Project Update request format :{ "name": (required)"", "description": (optional)""}')
+ parser.add_argument('-u',
+ type=str,
+ help='Username for authentication')
+ parser.add_argument('-p',
+ type=str,
+ help='Password for authentication')
+ parser.add_argument('-name',
+ type=str,
+ required=True,
+ help='Update project by name')
+ parser.add_argument('project',
+ type=json.loads,
+ help='Project Update request format :{'
+ '"name": (required)"", '
+ '"description": (optional)""}')
return parser
def take_action(self, parsed_args):
@@ -98,7 +133,10 @@ class ProjectPut(ProjectBase):
if(parsed_args.u and parsed_args.p):
response = AuthHandler.authenticate(parsed_args.u, parsed_args.p)
if "login" in response.text:
- print "Authentication has failed. Please check your username and password."
+ print "Authentication has failed."
return
- projects = httpClient.put(ProjectPut.projects_url + "/" + parsed_args.name, User.session, parsed_args.project)
+ projects = httpClient.put(
+ ProjectPut.projects_url + "/" + parsed_args.name,
+ User.session,
+ parsed_args.project)
print projects
diff --git a/testapi/testapi-client/testapiclient/tests/__init__.py b/testapi/testapi-client/testapiclient/tests/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/testapi/testapi-client/testapiclient/tests/__init__.py
diff --git a/testapi/testapi-client/testapiclient/tests/unit/__init__.py b/testapi/testapi-client/testapiclient/tests/unit/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/testapi/testapi-client/testapiclient/tests/unit/__init__.py
diff --git a/testapi/testapi-client/testapiclient/tests/unit/test_placeholder.py b/testapi/testapi-client/testapiclient/tests/unit/test_placeholder.py
new file mode 100644
index 0000000..2b7ad46
--- /dev/null
+++ b/testapi/testapi-client/testapiclient/tests/unit/test_placeholder.py
@@ -0,0 +1,6 @@
+import testtools
+
+
+class TestPlaceHolder(testtools.TestCase):
+ def test_placeholder(self):
+ self.assertEqual(1, 1)