Remove some pycharm warnings

* Mutable default arg
* Use of reserved names as parameters
* Missing requirements
* Unused parameters
* use static method
* Doc errors

Change-Id: Iaf7efa263398005ba1fa7261c894c85cb2fbcf47
This commit is contained in:
Eyal 2020-02-04 14:45:26 +02:00
parent cc3455b732
commit f0d3f2e092
12 changed files with 35 additions and 34 deletions

View File

@ -23,7 +23,6 @@ sys.path.insert(0, os.path.abspath('../..'))
extensions = [
'sphinx.ext.autodoc',
'openstackdocstheme',
#'sphinx.ext.intersphinx',
]
# autodoc generation is a bit aggressive and a nuisance when doing heavy
@ -78,4 +77,4 @@ latex_documents = [
]
# Example configuration for intersphinx: refer to the Python standard library.
#intersphinx_mapping = {'http://docs.python.org/': None}
# intersphinx_mapping = {'http://docs.python.org/': None}

View File

@ -11,3 +11,4 @@ At the command line::
$ git clone https://opendev.org/openstack/mistral-tempest-plugin
$ cd mistral-tempest-plugin/
$ pip install -e .

View File

@ -23,3 +23,4 @@ Alternatively, to run mistral tempest plugin tests using tox, go to tempest dire
And, to run a specific test::
$ tox -eall-plugin mistral_tempest_tests.tests.api.v2.test_mistral_basic_v2.WorkbookTestsV2.test_get_workbook

View File

@ -93,8 +93,8 @@ class MistralClientBase(rest_client.RestClient):
return self.delete('{obj}/{name}'.format(obj=obj, name=name))
def get_object(self, obj, id):
resp, body = self.get('{obj}/{id}'.format(obj=obj, id=id))
def get_object(self, obj, _id):
resp, body = self.get('{obj}/{id}'.format(obj=obj, id=_id))
return resp, jsonutils.loads(body)

View File

@ -37,7 +37,9 @@ class MistralClientV2(base.MistralClientBase):
return self.get(url_path, headers=headers)
def post_json(self, url_path, obj, extra_headers={}):
def post_json(self, url_path, obj, extra_headers=None):
if extra_headers is None:
extra_headers = {}
headers = {"Content-Type": "application/json"}
headers = dict(headers, **extra_headers)
return self.post(url_path,
@ -195,7 +197,9 @@ class MistralClientV2(base.MistralClientBase):
return [t for t in all_tasks if t['workflow_name'] == wf_name]
def create_action_execution(self, request_body, extra_headers={}):
def create_action_execution(self, request_body, extra_headers=None):
if extra_headers is None:
extra_headers = {}
resp, body = self.post_json('action_executions', request_body,
extra_headers)

View File

@ -244,9 +244,6 @@ class ActionExecutionTestsV2(base.TestCase):
'action_executions?include_output=true&task_execution_id=%s' %
task_id)
self.assertEqual(200, resp.status)
action_execution = body['action_executions'][0]
self.assertEqual(200, resp.status)
action_execution = body['action_executions'][0]
self.assertEqual(wf_namespace, action_execution['workflow_namespace'])

View File

@ -24,7 +24,8 @@ class ActionTestsV2(base.TestCase):
_service = 'workflowv2'
def get_field_value(self, body, act_name, field):
@staticmethod
def get_field_value(body, act_name, field):
return [body['actions'][i][field]
for i in range(len(body['actions']))
if body['actions'][i]['name'] == act_name][0]
@ -57,10 +58,10 @@ class ActionTestsV2(base.TestCase):
self.assertIn('next', body)
name_1 = body['actions'][0].get('name')
next = body.get('next')
next_ = body.get('next')
param_dict = utils.get_dict_from_string(
next.split('?')[1],
next_.split('?')[1],
delimiter='&'
)
@ -75,7 +76,7 @@ class ActionTestsV2(base.TestCase):
self.assertDictContainsSubset(expected_sub_dict, param_dict)
# Query again using 'next' hint
url_param = next.split('/')[-1]
url_param = next_.split('/')[-1]
resp, body = self.client.get_list_obj(url_param)
self.assertEqual(200, resp.status)

View File

@ -81,9 +81,9 @@ class ExecutionTestsV2(base.TestCase):
self.assertIn('next', body)
workflow_name_1 = body['executions'][0].get('workflow_name')
next = body.get('next')
next_ = body.get('next')
param_dict = utils.get_dict_from_string(
next.split('?')[1],
next_.split('?')[1],
delimiter='&'
)
@ -100,7 +100,7 @@ class ExecutionTestsV2(base.TestCase):
)
# Query again using 'next' link
url_param = next.split('/')[-1]
url_param = next_.split('/')[-1]
resp, body = self.client.get_list_obj(url_param)
self.assertEqual(200, resp.status)

View File

@ -129,10 +129,10 @@ class WorkflowTestsV2(base.TestCase):
self.assertIn('next', body)
name_1 = body['workflows'][0].get('name')
next = body.get('next')
next_ = body.get('next')
param_dict = utils.get_dict_from_string(
next.split('?')[1],
next_.split('?')[1],
delimiter='&'
)
@ -147,7 +147,7 @@ class WorkflowTestsV2(base.TestCase):
self.assertDictContainsSubset(expected_sub_dict, param_dict)
# Query again using 'next' hint
url_param = next.split('/')[-1]
url_param = next_.split('/')[-1]
resp, body = self.client.get_list_obj(url_param)
self.assertEqual(200, resp.status)
@ -256,13 +256,13 @@ class WorkflowTestsV2(base.TestCase):
namespace=namespace
)
name = body['workflows'][0]['name']
id = body['workflows'][0]['id']
wf_id = body['workflows'][0]['id']
self.assertEqual(201, resp.status)
self.assertEqual(name, body['workflows'][0]['name'])
resp, body = self.client.get_workflow(
id
wf_id
)
self.assertEqual(namespace, body['namespace'])
@ -279,12 +279,12 @@ class WorkflowTestsV2(base.TestCase):
namespace=namespace
)
name = body['workflows'][0]['name']
id = body['workflows'][0]['id']
wf_id = body['workflows'][0]['id']
self.assertEqual(201, resp.status)
self.assertEqual(name, body['workflows'][0]['name'])
resp, body = self.client.get_workflow(id)
resp, body = self.client.get_workflow(wf_id)
self.assertEqual(namespace, body['namespace'])
@ -294,7 +294,7 @@ class WorkflowTestsV2(base.TestCase):
'single_wf.yaml'
)
resp, body = self.client.get_workflow(id)
resp, body = self.client.get_workflow(wf_id)
self.assertEqual(200, resp.status)
@decorators.attr(type='sanity')
@ -373,8 +373,7 @@ class WorkflowTestsV2(base.TestCase):
tr_name = 'trigger'
resp, body = self.client.create_workflow('wf_v2.yaml')
name = body['workflows'][0]['name']
resp, body = self.client.create_cron_trigger(
tr_name, name, None, '5 * * * *')
self.client.create_cron_trigger(tr_name, name, None, '5 * * * *')
try:
self.assertRaises(
@ -414,12 +413,7 @@ class WorkflowTestsV2(base.TestCase):
tr_name = 'trigger'
_, body = self.client.create_workflow('wf_v2.yaml', scope='public')
name = body['workflows'][0]['name']
resp, body = self.alt_client.create_cron_trigger(
tr_name,
name,
None,
'5 * * * *'
)
self.alt_client.create_cron_trigger(tr_name, name, None, '5 * * * *')
try:
exception = self.assertRaises(

View File

@ -113,7 +113,9 @@ def _extract_target_headers_from_client(client):
}
def _execute_action(client, request, extra_headers={}):
def _execute_action(client, request, extra_headers=None):
if extra_headers is None:
extra_headers = {}
_, result = client.create_action_execution(
request,
extra_headers=extra_headers

View File

@ -94,7 +94,8 @@ class SSHActionsTestsV2(base.TestCaseAdvanced):
return ip
def _wait_until_server_up(self, server_ip, timeout=120, delay=2):
@staticmethod
def _wait_until_server_up(server_ip, timeout=120, delay=2):
seconds_remain = timeout
LOG.info("Waiting server SSH [IP=%s]...", server_ip)

View File

@ -12,4 +12,5 @@ paramiko>=2.0.0 # LGPLv2.1+
six>=1.10.0 # MIT
mock>=2.0.0 # BSD
tempest>=17.1.0 # Apache-2.0
testtools>=2.2.0 # MIT
python-keystoneclient>=3.8.0 # Apache-2.0