-
Notifications
You must be signed in to change notification settings - Fork 152
Expand file tree
/
Copy pathtest_main.py
More file actions
44 lines (31 loc) · 1.47 KB
/
test_main.py
File metadata and controls
44 lines (31 loc) · 1.47 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
# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
from unittest.mock import Mock, call, patch
from typer.testing import CliRunner
from data_designer.cli.main import app, main
from data_designer.config.utils.constants import DEFAULT_NUM_RECORDS
runner = CliRunner()
@patch("data_designer.cli.main.app")
@patch("data_designer.cli.main.ensure_cli_default_model_settings")
def test_main_bootstraps_before_running_app(mock_bootstrap: Mock, mock_app: Mock) -> None:
"""The CLI entrypoint bootstraps defaults before invoking Typer."""
call_order = Mock()
call_order.attach_mock(mock_bootstrap, "bootstrap")
call_order.attach_mock(mock_app, "app")
main()
assert call_order.mock_calls == [call.bootstrap(), call.app()]
@patch("data_designer.cli.commands.create.GenerationController")
def test_app_dispatches_lazy_create_command(mock_controller_cls: Mock) -> None:
"""The Typer app dispatches lazy-loaded commands through the resolved callback."""
mock_controller = Mock()
mock_controller_cls.return_value = mock_controller
result = runner.invoke(app, ["create", "config.yaml"])
assert result.exit_code == 0
mock_controller.run_create.assert_called_once_with(
config_source="config.yaml",
num_records=DEFAULT_NUM_RECORDS,
dataset_name="dataset",
artifact_path=None,
output_format=None,
)