aboutsummaryrefslogtreecommitdiffstats
path: root/functest/opnfv_tests/vnf/router
diff options
context:
space:
mode:
authorCédric Ollivier <cedric.ollivier@orange.com>2021-11-10 15:42:57 +0100
committerCédric Ollivier <cedric.ollivier@orange.com>2021-11-15 09:27:07 +0100
commit4fdbdd34fb5fea55571a18b2438ececa953928ff (patch)
tree44f1d6ff38cedad25b058ba18844e1004b7385db /functest/opnfv_tests/vnf/router
parente25e576af33547657c278e2dae49b033bf6a1fa1 (diff)
Update linters and fix all new issues
It mostly add encoding in open calls and leverage f-strings. Change-Id: Ifead18fc724a452c1067dcf91dc577032edc9c59 Signed-off-by: Cédric Ollivier <cedric.ollivier@orange.com>
Diffstat (limited to 'functest/opnfv_tests/vnf/router')
-rw-r--r--functest/opnfv_tests/vnf/router/cloudify_vrouter.py2
-rw-r--r--functest/opnfv_tests/vnf/router/test_controller/function_test_exec.py4
-rw-r--r--functest/opnfv_tests/vnf/router/utilvnf.py24
-rw-r--r--functest/opnfv_tests/vnf/router/vnf_controller/ssh_client.py2
-rw-r--r--functest/opnfv_tests/vnf/router/vnf_controller/vm_controller.py4
-rw-r--r--functest/opnfv_tests/vnf/router/vnf_controller/vnf_controller.py10
6 files changed, 27 insertions, 19 deletions
diff --git a/functest/opnfv_tests/vnf/router/cloudify_vrouter.py b/functest/opnfv_tests/vnf/router/cloudify_vrouter.py
index 93779f4f8..32d675347 100644
--- a/functest/opnfv_tests/vnf/router/cloudify_vrouter.py
+++ b/functest/opnfv_tests/vnf/router/cloudify_vrouter.py
@@ -56,7 +56,7 @@ class CloudifyVrouter(cloudify.Cloudify):
# Retrieve the configuration
try:
self.config = getattr(
- config.CONF, 'vnf_{}_config'.format(self.case_name))
+ config.CONF, f'vnf_{self.case_name}_config')
except Exception as exc:
raise Exception("VNF config file not found") from exc
diff --git a/functest/opnfv_tests/vnf/router/test_controller/function_test_exec.py b/functest/opnfv_tests/vnf/router/test_controller/function_test_exec.py
index 7c532d9a3..9eb3c5d69 100644
--- a/functest/opnfv_tests/vnf/router/test_controller/function_test_exec.py
+++ b/functest/opnfv_tests/vnf/router/test_controller/function_test_exec.py
@@ -36,12 +36,12 @@ class FunctionTestExec():
os.path.join(
self.util.vnf_data_dir, self.util.command_template_dir,
self.util.test_cmd_map_yaml_file),
- 'r') as test_cmd_map_file:
+ 'r', encoding='utf-8') as test_cmd_map_file:
self.test_cmd_map_yaml = yaml.safe_load(test_cmd_map_file)
self.util.set_credentials(credentials["cloud"])
- with open(self.util.test_env_config_yaml) as file_fd:
+ with open(self.util.test_env_config_yaml, encoding='utf-8') as file_fd:
test_env_config_yaml = yaml.safe_load(file_fd)
file_fd.close()
diff --git a/functest/opnfv_tests/vnf/router/utilvnf.py b/functest/opnfv_tests/vnf/router/utilvnf.py
index 7339573d7..111f20c1a 100644
--- a/functest/opnfv_tests/vnf/router/utilvnf.py
+++ b/functest/opnfv_tests/vnf/router/utilvnf.py
@@ -64,7 +64,7 @@ class Utilvnf(): # pylint: disable=too-many-instance-attributes
if not os.path.exists(self.vnf_data_dir):
os.makedirs(self.vnf_data_dir)
- with open(self.test_env_config_yaml) as file_fd:
+ with open(self.test_env_config_yaml, encoding='utf-8') as file_fd:
test_env_config_yaml = yaml.safe_load(file_fd)
file_fd.close()
@@ -98,9 +98,7 @@ class Utilvnf(): # pylint: disable=too-many-instance-attributes
return mac_address
def get_blueprint_outputs(self, cfy_manager_ip, deployment_name):
- url = "http://%s/deployments/%s/outputs" % (
- cfy_manager_ip, deployment_name)
-
+ url = f"http://{cfy_manager_ip}/deployments/{deployment_name}/outputs"
response = requests.get(
url,
auth=requests.auth.HTTPBasicAuth('admin', 'admin'),
@@ -212,20 +210,28 @@ class Utilvnf(): # pylint: disable=too-many-instance-attributes
def write_result_data(self, result_data):
test_result = []
if not os.path.isfile(self.test_result_json_file):
- with open(self.test_result_json_file, "w") as file_fd:
+ with open(
+ self.test_result_json_file, "w",
+ encoding="utf-8") as file_fd:
pass
else:
- with open(self.test_result_json_file, "r") as file_fd:
+ with open(
+ self.test_result_json_file, "r",
+ encoding="utf-8") as file_fd:
test_result = json.load(file_fd)
test_result.append(result_data)
- with open(self.test_result_json_file, "w") as file_fd:
+ with open(
+ self.test_result_json_file, "w",
+ encoding="utf-8") as file_fd:
json.dump(test_result, file_fd)
def output_test_result_json(self):
if os.path.isfile(self.test_result_json_file):
- with open(self.test_result_json_file, "r") as file_fd:
+ with open(
+ self.test_result_json_file, "r",
+ encoding="utf-8") as file_fd:
test_result = json.load(file_fd)
output_json_data = json.dumps(test_result,
sort_keys=True,
@@ -236,6 +242,6 @@ class Utilvnf(): # pylint: disable=too-many-instance-attributes
@staticmethod
def get_test_scenario(file_path):
- with open(file_path, 'r') as test_scenario_file:
+ with open(file_path, "r", encoding="utf-8") as test_scenario_file:
test_scenario_yaml = yaml.safe_load(test_scenario_file)
return test_scenario_yaml["test_scenario_list"]
diff --git a/functest/opnfv_tests/vnf/router/vnf_controller/ssh_client.py b/functest/opnfv_tests/vnf/router/vnf_controller/ssh_client.py
index 0969eab3b..269f6526b 100644
--- a/functest/opnfv_tests/vnf/router/vnf_controller/ssh_client.py
+++ b/functest/opnfv_tests/vnf/router/vnf_controller/ssh_client.py
@@ -43,7 +43,7 @@ class SshClient(): # pylint: disable=too-many-instance-attributes
self.ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
self.util = Utilvnf()
- with open(self.util.test_env_config_yaml) as file_fd:
+ with open(self.util.test_env_config_yaml, encoding='utf-8') as file_fd:
test_env_config_yaml = yaml.safe_load(file_fd)
file_fd.close()
diff --git a/functest/opnfv_tests/vnf/router/vnf_controller/vm_controller.py b/functest/opnfv_tests/vnf/router/vnf_controller/vm_controller.py
index db276cfdb..2210b3909 100644
--- a/functest/opnfv_tests/vnf/router/vnf_controller/vm_controller.py
+++ b/functest/opnfv_tests/vnf/router/vnf_controller/vm_controller.py
@@ -36,7 +36,7 @@ class VmController():
self.util = Utilvnf()
self.util.set_credentials(credentials["cloud"])
- with open(self.util.test_env_config_yaml) as file_fd:
+ with open(self.util.test_env_config_yaml, encoding='utf-8') as file_fd:
test_env_config_yaml = yaml.safe_load(file_fd)
file_fd.close()
@@ -101,7 +101,7 @@ class VmController():
def command_create_and_execute(self, ssh, test_cmd_file_path,
cmd_input_param, prompt_file_path):
- with open(prompt_file_path, 'r') as prompt_file:
+ with open(prompt_file_path, 'r', encoding='utf-8') as prompt_file:
prompt = yaml.safe_load(prompt_file)
config_mode_prompt = prompt["config_mode"]
diff --git a/functest/opnfv_tests/vnf/router/vnf_controller/vnf_controller.py b/functest/opnfv_tests/vnf/router/vnf_controller/vnf_controller.py
index 4ab394760..46584456f 100644
--- a/functest/opnfv_tests/vnf/router/vnf_controller/vnf_controller.py
+++ b/functest/opnfv_tests/vnf/router/vnf_controller/vnf_controller.py
@@ -36,7 +36,7 @@ class VnfController():
self.util = Utilvnf()
self.vm_controller = VmController(util_info)
- with open(self.util.test_env_config_yaml) as file_fd:
+ with open(self.util.test_env_config_yaml, encoding='utf-8') as file_fd:
test_env_config_yaml = yaml.safe_load(file_fd)
file_fd.close()
@@ -49,7 +49,8 @@ class VnfController():
def config_vnf(self, source_vnf, destination_vnf, test_cmd_file_path,
parameter_file_path, prompt_file_path):
# pylint: disable=too-many-arguments
- with open(parameter_file_path, 'r') as parameter_file:
+ with open(
+ parameter_file_path, 'r', encoding='utf-8') as parameter_file:
cmd_input_param = yaml.safe_load(parameter_file)
cmd_input_param["macaddress"] = source_vnf["data_plane_network_mac"]
@@ -69,14 +70,15 @@ class VnfController():
res_dict_data_list = []
- with open(parameter_file_path, 'r') as parameter_file:
+ with open(
+ parameter_file_path, 'r', encoding='utf-8') as parameter_file:
cmd_input_param = yaml.safe_load(parameter_file)
cmd_input_param["source_ip"] = target_vnf["data_plane_network_ip"]
cmd_input_param["destination_ip"] = reference_vnf[
"data_plane_network_ip"]
- with open(prompt_file_path, 'r') as prompt_file:
+ with open(prompt_file_path, 'r', encoding='utf-8') as prompt_file:
prompt = yaml.safe_load(prompt_file)
terminal_mode_prompt = prompt["terminal_mode"]