modify codacy errors in target

Signed-off-by: danfengliu <danfengl@vmware.com>
This commit is contained in:
danfengliu 2018-11-07 16:06:44 +08:00
parent a6151175e3
commit 9265754936
2 changed files with 18 additions and 9 deletions

View File

@ -60,4 +60,8 @@ class Repository(base.Base):
_, status_code, _ = client.repositories_repo_name_tags_tag_labels_post_with_http_info(repo_name, tag, label)
base._assert_status_code(expect_status_code, status_code)
def get_repo_signatures(self, repo_name, expect_status_code = 200, **kwargs):
client = self._get_client(**kwargs)
data, status_code, _ = client.repositories_repo_name_signatures_get_with_http_info(repo_name)
base._assert_status_code(expect_status_code, status_code)

View File

@ -1,29 +1,34 @@
# -*- coding: utf-8 -*-
import sys
import time
import random
import base
import swagger_client
class Target(base.Base):
def create_target(self,
endpoint_target = r"https://{}.{}.{}.{}".format(random.randint(1, 254), random.randint(1, 254), random.randint(1, 254), random.randint(1, 254)),
endpoint_target = None,
username_target = "target_user", password_target = "Aa123456", name_target=base._random_name("target"),
type=0, insecure_target=True, expect_status_code = 201,
target_type=0, insecure_target=True, expect_status_code = 201,
**kwargs):
if endpoint_target is None:
endpoint_target = r"https://{}.{}.{}.{}".format(int(round(time.time() * 1000)) % 100,
int(round(time.time() * 1000)) % 200,
int(round(time.time() * 1000)) % 100,
int(round(time.time() * 1000)) % 254)
client = self._get_client(**kwargs)
policy = swagger_client.RepTarget(name=name_target, endpoint=endpoint_target,
username=username_target, password=password_target, type=type,
username=username_target, password=password_target, type=target_type,
insecure=insecure_target)
_, status_code, header = client.targets_post_with_http_info(policy)
base._assert_status_code(expect_status_code, status_code)
return base._get_id_from_header(header), name_target
def get_target(self, expect_status_code = 200, params = {}, **kwargs):
def get_target(self, expect_status_code = 200, params = None, **kwargs):
client = self._get_client(**kwargs)
data = []
if params is None:
params = {}
data, status_code, _ = client.targets_get_with_http_info(**params)
base._assert_status_code(expect_status_code, status_code)
return data