run pre-commit on test_vmware.py and cloud_test_base.py

This commit is contained in:
Megan Wilhite 2020-12-17 09:12:04 -05:00 committed by Daniel Wozniak
parent 1777d58935
commit 605761d0ed
2 changed files with 11 additions and 20 deletions

View file

@ -1,14 +1,6 @@
# -*- coding: utf-8 -*-
""" """
:codeauthor: Megan Wilhite <mwilhite@saltstack.com> :codeauthor: Megan Wilhite <mwilhite@saltstack.com>
""" """
# Import Python Libs
from __future__ import absolute_import, print_function, unicode_literals
# Import Salt Libs
from salt.ext import six
# Create the cloud instance name to be used throughout the tests # Create the cloud instance name to be used throughout the tests
from tests.integration.cloud.helpers.cloud_test_base import TIMEOUT, CloudTest from tests.integration.cloud.helpers.cloud_test_base import TIMEOUT, CloudTest
@ -31,9 +23,9 @@ class VMWareTest(CloudTest):
] ]
ret_val = self.run_cloud( ret_val = self.run_cloud(
"-p vmware-test {0}".format(self.instance_name), timeout=TIMEOUT "-p vmware-test {}".format(self.instance_name), timeout=TIMEOUT
) )
disk_datastore_str = " [{0}] {1}/Hard disk 2-flat.vmdk".format( disk_datastore_str = " [{}] {}/Hard disk 2-flat.vmdk".format(
disk_datastore, self.instance_name disk_datastore, self.instance_name
) )
@ -42,7 +34,7 @@ class VMWareTest(CloudTest):
self.assertIn( self.assertIn(
disk_datastore_str, disk_datastore_str,
ret_val, ret_val,
msg="Hard Disk 2 did not use the Datastore {0} ".format(disk_datastore), msg="Hard Disk 2 did not use the Datastore {} ".format(disk_datastore),
) )
self.assertDestroyInstance() self.assertDestroyInstance()
@ -53,14 +45,14 @@ class VMWareTest(CloudTest):
""" """
# create the instance # create the instance
ret_val = self.run_cloud( ret_val = self.run_cloud(
"-p vmware-test {0} --no-deploy".format(self.instance_name), timeout=TIMEOUT "-p vmware-test {} --no-deploy".format(self.instance_name), timeout=TIMEOUT
) )
# check if instance returned with salt installed # check if instance returned with salt installed
self.assertInstanceExists(ret_val) self.assertInstanceExists(ret_val)
create_snapshot = self.run_cloud( create_snapshot = self.run_cloud(
"-a create_snapshot {0} \ "-a create_snapshot {} \
snapshot_name='Test Cloud' \ snapshot_name='Test Cloud' \
memdump=True -y".format( memdump=True -y".format(
self.instance_name self.instance_name
@ -69,7 +61,7 @@ class VMWareTest(CloudTest):
) )
s_ret_str = "Snapshot created successfully" s_ret_str = "Snapshot created successfully"
self.assertIn(s_ret_str, six.text_type(create_snapshot)) self.assertIn(s_ret_str, str(create_snapshot))
self.assertDestroyInstance() self.assertDestroyInstance()
@ -79,8 +71,9 @@ class VMWareTest(CloudTest):
verify_ssl: False verify_ssl: False
""" """
profile_name = "vmware_verify_ssl" profile_name = "vmware_verify_ssl"
self.add_profile_config("vmware-test", {"verify_ssl": False,}, self.add_profile_config(
"vmware.conf", profile_name) "vmware-test", {"verify_ssl": False}, "vmware.conf", profile_name
)
# create the instance # create the instance
ret_val = self.run_cloud( ret_val = self.run_cloud(
"-p {} {}".format(profile_name, self.instance_name), timeout=TIMEOUT "-p {} {}".format(profile_name, self.instance_name), timeout=TIMEOUT

View file

@ -8,10 +8,10 @@ import os
import shutil import shutil
from time import sleep from time import sleep
import salt.utils.verify
from salt.config import cloud_config, cloud_providers_config from salt.config import cloud_config, cloud_providers_config
from salt.ext.six.moves import range from salt.ext.six.moves import range
from salt.utils.yaml import safe_load from salt.utils.yaml import safe_load
import salt.utils.verify
from tests.support.case import ShellCase from tests.support.case import ShellCase
from tests.support.helpers import expensiveTest, random_string from tests.support.helpers import expensiveTest, random_string
from tests.support.paths import FILES from tests.support.paths import FILES
@ -200,9 +200,7 @@ class CloudTest(ShellCase):
""" """
copy the current profile and add a new profile in the same file copy the current profile and add a new profile in the same file
""" """
conf_path = os.path.join( conf_path = os.path.join(RUNTIME_VARS.TMP_CONF_DIR, "cloud.profiles.d", conf)
RUNTIME_VARS.TMP_CONF_DIR, "cloud.profiles.d", conf
)
with salt.utils.files.fopen(conf_path, "r") as fp: with salt.utils.files.fopen(conf_path, "r") as fp:
conf = safe_load(fp) conf = safe_load(fp)
conf[new_profile] = conf[name].copy() conf[new_profile] = conf[name].copy()