aboutsummaryrefslogtreecommitdiffstats
path: root/tests/collect_tests
diff options
context:
space:
mode:
authorArif Ali <arif.ali@canonical.com>2024-01-15 18:51:04 -0800
committerJake Hunsaker <jacob.r.hunsaker@gmail.com>2024-04-12 11:50:48 -0400
commit93bcf51257ec4ce2b97c942e51e56546ce8cd0cd (patch)
treedb1e835f5de49918553281726d86f4660731313e /tests/collect_tests
parent4069af4bca5d20662389200f0d426d2d31f054e8 (diff)
downloadsos-93bcf51257ec4ce2b97c942e51e56546ce8cd0cd.tar.gz
[testing] Add most testing via tox.ini
Consolidate testing, so that things can be run from CLI, CI and various other means in a consistent way by using tox. * Updated all the flake8 tests in the tests folder. * Added pylint as a neutral test so that we can work on this in stages and have some collaboration on what we test and don't * The tox tests for unit, stageone, stagetwo testing makes is easier for users to know how to run tests, and not have to do things manually * Using tox for CI doesn't make sense, as that will create virtual envs and will disregard system/snap based python modules so may not work Signed-off-by: Arif Ali <arif.ali@canonical.com>
Diffstat (limited to 'tests/collect_tests')
-rw-r--r--tests/collect_tests/help_output_tests.py39
1 files changed, 29 insertions, 10 deletions
diff --git a/tests/collect_tests/help_output_tests.py b/tests/collect_tests/help_output_tests.py
index 584ad498..4a253f56 100644
--- a/tests/collect_tests/help_output_tests.py
+++ b/tests/collect_tests/help_output_tests.py
@@ -35,13 +35,20 @@ class CollectHelpOutputTest(StageOneOutputTest):
sos_cmd = 'collect --help'
- @skipIf(PEXPECT_PRESENT, "python3-pexpect is installed, placeholder will not be used")
+ @skipIf(
+ PEXPECT_PRESENT,
+ "python3-pexpect is installed, placeholder will not be used"
+ )
def test_placeholder_warning_shown(self):
- self.assertOutputContains("WARNING: `collect` is not available with this installation!")
+ self.assertOutputContains(
+ "WARNING: `collect` is not available with this installation!"
+ )
@skipIf(PEXPECT_PRESENT is False, "python3-pexpect not installed locally")
def test_help_sections_present(self):
- self.assertOutputNotContains("WARNING: `collect` is not available with this installation!")
+ self.assertOutputNotContains(
+ "WARNING: `collect` is not available with this installation!"
+ )
self.assertOutputContains("Global Options:")
self.assertOutputContains("Report Passthru Options:")
self.assertOutputContains("Collector Options:")
@@ -65,7 +72,9 @@ class CollectOptionsHelpTest(StageOneOutputTest):
@skipIf(PEXPECT_PRESENT is False, "python3-pexpect not installed locally")
def test_cluster_profiles_shown(self):
- _out = re.search(r"Use the short name with --cluster-type or cluster options \(-c\)(.*?)The following cluster options are available:",
+ _out = re.search("Use the short name with --cluster-type or cluster "
+ r"options \(-c\)(.*?)The following cluster options "
+ "are available:",
self.cmd_output.stdout, re.S).group(1).splitlines()
_profs = {}
for ln in _out:
@@ -75,8 +84,9 @@ class CollectOptionsHelpTest(StageOneOutputTest):
_profs[ln[0]] = ln[1]
clusters = []
- # get a list of names of profile pyfiles
- for pyfile in glob.glob(os.path.join(SOS_REPO_ROOT, 'sos/collector/clusters/*.py')):
+ # get a list of names of profile pyfiles
+ for pyfile in glob.glob(os.path.join(SOS_REPO_ROOT,
+ 'sos/collector/clusters/*.py')):
pyf = os.path.basename(pyfile)
if pyf.startswith('__'):
continue
@@ -88,17 +98,26 @@ class CollectOptionsHelpTest(StageOneOutputTest):
# this has the secondary effect of enforcing a stylistic requirement
# where at least one profile must match the pyfile name
for clus in clusters:
- assert clus in _profs, "Cluster '%s' not displayed in --list-options" % clus
+ assert \
+ clus in _profs, \
+ f"Cluster '{clus}' not displayed in --list-options"
@skipIf(PEXPECT_PRESENT is False, "python3-pexpect not installed locally")
def test_cluster_options_shown(self):
- _opts = re.search(" Cluster Option Name Type Default Description(.*?)Options take the form of cluster.name=value",
+ _opts = re.search(" Cluster Option Name "
+ "Type Default Description(.*?)Options "
+ "take the form of cluster.name=value",
self.cmd_output.stdout, re.S).group(1).splitlines()
_opts = [o for o in _opts if o]
assert _opts, "No option output detected"
- @skipIf(PEXPECT_PRESENT, "python3-pexpect is installed, placeholder will be unused")
+ @skipIf(
+ PEXPECT_PRESENT,
+ "python3-pexpect is installed, placeholder will be unused"
+ )
def test_placeholder_component_used(self):
- self.assertOutputContains("(unavailable) Collect an sos report from multiple nodes")
+ self.assertOutputContains(
+ "(unavailable) Collect an sos report from multiple nodes"
+ )