Skip to content

Commit

Permalink
CRAYSAT-1959: add functional tests for sat init in csm testing
Browse files Browse the repository at this point in the history
  • Loading branch information
ethanholen-hpe committed Jan 8, 2025
1 parent 5d1c47f commit 3956f74
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 0 deletions.
Empty file.
58 changes: 58 additions & 0 deletions src/csm_testing/tests/sat_functional/init/test_init.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#
# MIT License
#
# (C) Copyright 2024 Hewlett Packard Enterprise Development LP
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),
# to deal in the Software without restriction, including without limitation
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
# and/or sell copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
# OTHER DEALINGS IN THE SOFTWARE.
#
"""
Simple tests for the functionality of the `sat init` command.
"""
import shlex
import subprocess
import re
import unittest

HELP_OUTPUT="""usage: sat init [-h] [-f] [-o OUTPUT]
Initialize a SAT configuration file with default parameters in the location specified on the command line, specified by $SAT_CONFIG_FILE or in
the default location.
optional arguments:
-h, --help show this help message and exit
-f, --force Overwrite an existing config file at the specified location.
-o OUTPUT, --output OUTPUT
The path to which to write the configuration file. If not set, the value of $SAT_CONFIG_FILE will be used, or
$HOME/.config/sat/sat.toml if $SAT_CONFIG_FILE is not set.
"""

class TestStatus(unittest.TestCase):
"""Test the `sat init` command."""

def test_help_command(self):
"""Test that `sat init` returns the proper header."""
command = 'sat init -h'

# Use stdout and stderr instead of capture_output=True for Python 3.6 compatibility
proc = subprocess.run(shlex.split(command), stdout=subprocess.PIPE, stderr=subprocess.PIPE,
check=True)
command_output = proc.stdout.decode().strip()

self.assertEqual(HELP_OUTPUT, command_output)

0 comments on commit 3956f74

Please sign in to comment.