|
| 1 | +############################################################################### |
| 2 | +# |
| 3 | +# MIT License |
| 4 | +# |
| 5 | +# Copyright (c) 2025 Advanced Micro Devices, Inc. |
| 6 | +# |
| 7 | +# Permission is hereby granted, free of charge, to any person obtaining a copy |
| 8 | +# of this software and associated documentation files (the "Software"), to deal |
| 9 | +# in the Software without restriction, including without limitation the rights |
| 10 | +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 11 | +# copies of the Software, and to permit persons to whom the Software is |
| 12 | +# furnished to do so, subject to the following conditions: |
| 13 | +# |
| 14 | +# The above copyright notice and this permission notice shall be included in all |
| 15 | +# copies or substantial portions of the Software. |
| 16 | +# |
| 17 | +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 18 | +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 19 | +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 20 | +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 21 | +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 22 | +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 23 | +# SOFTWARE. |
| 24 | +# |
| 25 | +############################################################################### |
| 26 | +"""Functional tests for node-scraper CLI help commands.""" |
| 27 | + |
| 28 | +import subprocess |
| 29 | +import sys |
| 30 | + |
| 31 | + |
| 32 | +def test_help_command(): |
| 33 | + """Test that node-scraper -h displays help information.""" |
| 34 | + result = subprocess.run( |
| 35 | + [sys.executable, "-m", "nodescraper.cli.cli", "-h"], |
| 36 | + capture_output=True, |
| 37 | + text=True, |
| 38 | + ) |
| 39 | + |
| 40 | + assert result.returncode == 0 |
| 41 | + assert "usage:" in result.stdout.lower() |
| 42 | + assert "node scraper" in result.stdout.lower() |
| 43 | + assert "-h" in result.stdout or "--help" in result.stdout |
| 44 | + |
| 45 | + |
| 46 | +def test_help_command_long_form(): |
| 47 | + """Test that node-scraper --help displays help information.""" |
| 48 | + result = subprocess.run( |
| 49 | + [sys.executable, "-m", "nodescraper.cli.cli", "--help"], |
| 50 | + capture_output=True, |
| 51 | + text=True, |
| 52 | + ) |
| 53 | + |
| 54 | + assert result.returncode == 0 |
| 55 | + assert "usage:" in result.stdout.lower() |
| 56 | + assert "node scraper" in result.stdout.lower() |
| 57 | + |
| 58 | + |
| 59 | +def test_no_arguments(): |
| 60 | + """Test that node-scraper with no arguments runs the default config.""" |
| 61 | + result = subprocess.run( |
| 62 | + [sys.executable, "-m", "nodescraper.cli.cli"], |
| 63 | + capture_output=True, |
| 64 | + text=True, |
| 65 | + timeout=30, |
| 66 | + ) |
| 67 | + |
| 68 | + assert len(result.stdout) > 0 or len(result.stderr) > 0 |
| 69 | + output = (result.stdout + result.stderr).lower() |
| 70 | + assert "plugin" in output or "nodescraper" in output |
| 71 | + |
| 72 | + |
| 73 | +def test_help_shows_subcommands(): |
| 74 | + """Test that help output includes available subcommands.""" |
| 75 | + result = subprocess.run( |
| 76 | + [sys.executable, "-m", "nodescraper.cli.cli", "-h"], |
| 77 | + capture_output=True, |
| 78 | + text=True, |
| 79 | + ) |
| 80 | + |
| 81 | + assert result.returncode == 0 |
| 82 | + output = result.stdout.lower() |
| 83 | + assert "run-plugins" in output or "commands:" in output or "positional arguments:" in output |
0 commit comments