"""bin 模块单元测试。 覆盖: - manage_logs: format_size, get_log_base_names 纯函数 - run_cli: parse_args 函数 """ from __future__ import annotations import argparse import pytest class TestFormatSize: """format_size 纯函数测试。""" def test_small_size(self): from bin.manage_logs import format_size result = format_size(0.5) assert "MB" in result or "KB" in result or "0" in result def test_medium_size(self): from bin.manage_logs import format_size result = format_size(100.0) assert isinstance(result, str) def test_large_size(self): from bin.manage_logs import format_size result = format_size(1500.0) assert isinstance(result, str) assert "GB" in result or "1" in result def test_zero_size(self): from bin.manage_logs import format_size result = format_size(0.0) assert isinstance(result, str) class TestGetLogBaseNames: """get_log_base_names 函数测试。""" def test_function_exists(self): from bin.manage_logs import get_log_base_names assert callable(get_log_base_names) def test_nonexistent_dir_returns_empty(self): from bin.manage_logs import get_log_base_names result = get_log_base_names('/nonexistent/path') assert result == [] class TestManageLogsModule: """manage_logs 模块测试。""" def test_show_stats_exists(self): from bin.manage_logs import show_stats assert callable(show_stats) def test_manual_cleanup_exists(self): from bin.manage_logs import manual_cleanup assert callable(manual_cleanup) def test_manual_compress_exists(self): from bin.manage_logs import manual_compress assert callable(manual_compress) def test_show_monitor_status_exists(self): from bin.manage_logs import show_monitor_status assert callable(show_monitor_status) def test_main_exists(self): from bin.manage_logs import main assert callable(main) class TestRunCliParseArgs: """run_cli.parse_args 函数测试。""" def test_function_exists(self): from bin.run_cli import parse_args assert callable(parse_args) def test_empty_args(self): from bin.run_cli import parse_args result = parse_args([]) assert isinstance(result, argparse.Namespace) def test_device_id_arg(self): from bin.run_cli import parse_args result = parse_args(['--device-id', 'test_device']) assert result.device_id == 'test_device' def test_y_pianyi_arg(self): from bin.run_cli import parse_args result = parse_args(['--y-pianyi', '100']) assert result.y_pianyi == 100 class TestRunCliModule: """run_cli 模块测试。""" def test_ensure_adb_in_path_exists(self): from bin.run_cli import ensure_adb_in_path assert callable(ensure_adb_in_path) def test_main_exists(self): from bin.run_cli import main assert callable(main) class TestBinModules: """bin 子模块存在性测试。""" def test_run_cli_importable(self): from bin import run_cli assert run_cli is not None def test_manage_logs_importable(self): from bin import manage_logs assert manage_logs is not None