-
Notifications
You must be signed in to change notification settings - Fork 395
Expand file tree
/
Copy pathtest_cli.py
More file actions
130 lines (105 loc) · 5 KB
/
Copy pathtest_cli.py
File metadata and controls
130 lines (105 loc) · 5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
# Copyright (c) 2025, NVIDIA CORPORATION. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""CLI structure tests for super3 commands.
Uses ``typer.testing.CliRunner`` for in-process, fast CLI testing.
These tests verify that all super3 subcommands are importable and registered
correctly — catching import errors (e.g. missing subpackages) before they
reach users.
"""
from __future__ import annotations
import pytest
from typer.testing import CliRunner
from nemotron.cli.bin.nemotron import app
runner = CliRunner()
# Top-level super3 commands
SUPER3_TOP_COMMANDS = ["pretrain", "sft", "rl", "eval", "pipe", "data", "model"]
# super3 rl subcommands
SUPER3_RL_COMMANDS = ["rlvr", "swe1", "swe2", "rlhf"]
# super3 data prep subcommands
SUPER3_DATA_PREP_COMMANDS = ["pretrain", "sft", "rl"]
# super3 data import subcommands
SUPER3_DATA_IMPORT_COMMANDS = ["pretrain", "sft", "rl"]
class TestSuper3AppStructure:
def test_help_succeeds(self):
result = runner.invoke(app, ["super3", "--help"])
assert result.exit_code == 0, f"super3 --help failed: {result.output}"
@pytest.mark.parametrize("command", SUPER3_TOP_COMMANDS)
def test_top_command_listed(self, command):
result = runner.invoke(app, ["super3", "--help"])
assert result.exit_code == 0
assert command in result.output, (
f"'{command}' not found in super3 --help output"
)
@pytest.mark.parametrize("command", SUPER3_TOP_COMMANDS)
def test_top_command_help_succeeds(self, command):
result = runner.invoke(app, ["super3", command, "--help"])
assert result.exit_code == 0, (
f"super3 {command} --help failed: {result.output}\n{result.exception}"
)
class TestSuper3RlStructure:
@pytest.mark.parametrize("command", SUPER3_RL_COMMANDS)
def test_rl_subcommand_listed(self, command):
result = runner.invoke(app, ["super3", "rl", "--help"])
assert result.exit_code == 0
assert command in result.output, (
f"'{command}' not found in super3 rl --help output"
)
@pytest.mark.parametrize("command", SUPER3_RL_COMMANDS)
def test_rl_subcommand_help_succeeds(self, command):
result = runner.invoke(app, ["super3", "rl", command, "--help"])
assert result.exit_code == 0, (
f"super3 rl {command} --help failed: {result.output}\n{result.exception}"
)
class TestSuper3DataStructure:
def test_data_subcommands_listed(self):
result = runner.invoke(app, ["super3", "data", "--help"])
assert result.exit_code == 0
assert "prep" in result.output
assert "import" in result.output
def test_data_prep_help_succeeds(self):
result = runner.invoke(app, ["super3", "data", "prep", "--help"])
assert result.exit_code == 0, (
f"super3 data prep --help failed: {result.output}"
)
@pytest.mark.parametrize("command", SUPER3_DATA_PREP_COMMANDS)
def test_data_prep_subcommand_listed(self, command):
result = runner.invoke(app, ["super3", "data", "prep", "--help"])
assert result.exit_code == 0
assert command in result.output, (
f"'{command}' not found in super3 data prep --help output"
)
@pytest.mark.parametrize("command", SUPER3_DATA_PREP_COMMANDS)
def test_data_prep_subcommand_help_succeeds(self, command):
result = runner.invoke(app, ["super3", "data", "prep", command, "--help"])
assert result.exit_code == 0, (
f"super3 data prep {command} --help failed: {result.output}\n{result.exception}"
)
def test_data_import_help_succeeds(self):
result = runner.invoke(app, ["super3", "data", "import", "--help"])
assert result.exit_code == 0, (
f"super3 data import --help failed: {result.output}"
)
@pytest.mark.parametrize("command", SUPER3_DATA_IMPORT_COMMANDS)
def test_data_import_subcommand_listed(self, command):
result = runner.invoke(app, ["super3", "data", "import", "--help"])
assert result.exit_code == 0
assert command in result.output, (
f"'{command}' not found in super3 data import --help output"
)
@pytest.mark.parametrize("command", SUPER3_DATA_IMPORT_COMMANDS)
def test_data_import_subcommand_help_succeeds(self, command):
result = runner.invoke(app, ["super3", "data", "import", command, "--help"])
assert result.exit_code == 0, (
f"super3 data import {command} --help failed: {result.output}\n{result.exception}"
)