Skip to content
Snippets Groups Projects
Commit 6f539955 authored by Ashwin Kumar Karnad's avatar Ashwin Kumar Karnad
Browse files

Merge branch 'new-test---help' into 'main'

Add new test (for `--help` option)

See merge request !31
parents defc7f66 49af5ccc
No related branches found
No related tags found
1 merge request!31Add new test (for `--help` option)
......@@ -150,7 +150,16 @@ def compose_quota_report(user: str, home=True, bytes=False, scratchdir=None) ->
return out
def main():
def main(argv=None):
"""Main function for mpsd-quota command.
Parameters
----------
argv : List[str] or None
Can provide list of arguments (reflecting sys.argv) for testing purposes
The default value (None) will result in `sys.argv` being used.
"""
parser = argparse.ArgumentParser(
prog="mpsd-quota",
description="Shows current usage of /home and /scratch",
......@@ -185,7 +194,10 @@ def main():
action="store_true",
)
args = parser.parse_args()
# if argv==None, then parse_args will use sys.argv (normal scenario) if we
# are testing `main(argv)` we can parse custom arguments into `argv` (for
# testing)
args = parser.parse_args(argv)
if args.verbose:
print("Increased verbosity (DEBUG messages)")
......
......@@ -130,3 +130,14 @@ def test_compose_quota_report(mocker):
assert "1.2e-08%" in output_lines[2]
# in total, we expect three lines
assert len(output_lines) == 3
def test_mpsd_quota_command_help(capsys):
try:
quota.main(["mpsd-quota", "--help"])
except SystemExit:
pass
output = capsys.readouterr().out
print(f"{output=}")
assert "Shows current usage of /home and /scratch" in output
assert "Output of mpsd-quota is in" in output
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment