mirror of
https://github.com/moesnow/March7thAssistant.git
synced 2026-08-03 08:47:01 +08:00
- 配置 pytest 测试框架和开发依赖 (pytest, pytest-cov, pytest-qt) - 添加 utils/ 模块测试: color, date, image_utils, console, command, singleton, logger, registry - 添加 module/ 模块测试: workflow, config, notification, localization, ocr, screen, update - 添加 app/ GUI 组件测试: trie, signal_bus, config, style_sheet, icon - 添加 app/ 纯函数测试: warp_export, account_manager, schedule_dialog, check_update, log_interface, pushsettingcard, switchsettingcard - 添加通知子模块测试: webhook, telegram, smtp, lark, kook, pac, notifiers - 添加注册表模块测试: star_rail_setting, game_auto_hdr, gameaccount (winreg mock) - 共 584 个测试用例通过,覆盖率 17%
40 lines
1.6 KiB
Python
40 lines
1.6 KiB
Python
import os
|
|
from utils.console import is_gui_started, is_docker_started, should_skip_pause
|
|
|
|
|
|
class TestConsole:
|
|
def test_is_gui_started_true(self, monkeypatch):
|
|
monkeypatch.setenv("MARCH7TH_GUI_STARTED", "true")
|
|
assert is_gui_started() is True
|
|
|
|
def test_is_gui_started_false(self, monkeypatch):
|
|
monkeypatch.delenv("MARCH7TH_GUI_STARTED", raising=False)
|
|
assert is_gui_started() is False
|
|
|
|
def test_is_gui_started_case_insensitive(self, monkeypatch):
|
|
monkeypatch.setenv("MARCH7TH_GUI_STARTED", "TRUE")
|
|
assert is_gui_started() is True
|
|
|
|
def test_is_docker_started_true(self, monkeypatch):
|
|
monkeypatch.setenv("MARCH7TH_DOCKER_STARTED", "true")
|
|
assert is_docker_started() is True
|
|
|
|
def test_is_docker_started_false(self, monkeypatch):
|
|
monkeypatch.delenv("MARCH7TH_DOCKER_STARTED", raising=False)
|
|
assert is_docker_started() is False
|
|
|
|
def test_should_skip_pause_gui(self, monkeypatch):
|
|
monkeypatch.setenv("MARCH7TH_GUI_STARTED", "true")
|
|
monkeypatch.delenv("MARCH7TH_DOCKER_STARTED", raising=False)
|
|
assert should_skip_pause() is True
|
|
|
|
def test_should_skip_pause_docker(self, monkeypatch):
|
|
monkeypatch.delenv("MARCH7TH_GUI_STARTED", raising=False)
|
|
monkeypatch.setenv("MARCH7TH_DOCKER_STARTED", "true")
|
|
assert should_skip_pause() is True
|
|
|
|
def test_should_skip_pause_neither(self, monkeypatch):
|
|
monkeypatch.delenv("MARCH7TH_GUI_STARTED", raising=False)
|
|
monkeypatch.delenv("MARCH7TH_DOCKER_STARTED", raising=False)
|
|
assert should_skip_pause() is False
|