mirror of
https://github.com/PaddlePaddle/FastDeploy.git
synced 2025-12-24 13:28:13 +08:00
56 lines
1.9 KiB
Python
56 lines
1.9 KiB
Python
# Copyright (c) 2025 PaddlePaddle Authors. 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.
|
|
|
|
import unittest
|
|
from argparse import Namespace, _SubParsersAction
|
|
from unittest.mock import MagicMock, patch
|
|
|
|
from fastdeploy.entrypoints.cli.collect_env import CollectEnvSubcommand, cmd_init
|
|
|
|
|
|
class TestCollectEnvSubcommand(unittest.TestCase):
|
|
def setUp(self):
|
|
self.subcommand = CollectEnvSubcommand()
|
|
|
|
def test_name_property(self):
|
|
self.assertEqual(self.subcommand.name, "collect-env")
|
|
|
|
@patch("fastdeploy.entrypoints.cli.collect_env.collect_env_main")
|
|
def test_cmd(self, mock_collect_env_main):
|
|
args = Namespace()
|
|
self.subcommand.cmd(args)
|
|
mock_collect_env_main.assert_called_once()
|
|
|
|
def test_subparser_init(self):
|
|
mock_subparsers = MagicMock(spec=_SubParsersAction)
|
|
parser = self.subcommand.subparser_init(mock_subparsers)
|
|
print(parser)
|
|
mock_subparsers.add_parser.assert_called_once_with(
|
|
"collect-env",
|
|
help="Start collecting environment information.",
|
|
description="Start collecting environment information.",
|
|
usage="fastdeploy collect-env",
|
|
)
|
|
|
|
|
|
class TestCmdInit(unittest.TestCase):
|
|
def test_cmd_init(self):
|
|
subcommands = cmd_init()
|
|
self.assertEqual(len(subcommands), 1)
|
|
self.assertIsInstance(subcommands[0], CollectEnvSubcommand)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|