Skip to content

Add comprehensive unit test suite for configuration-related modules - #6

Merged
LevelDownRefine merged 8 commits into
mainfrom
copilot/create-tests-folder
Jul 7, 2026
Merged

LevelDownRefine merged 8 commits into
mainfrom
copilot/create-tests-folder

Conversation

Copilot AI commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

This PR establishes a structured automated test environment for the repository and implements a comprehensive unit test suite targeting critical configuration and path-manipulation functions across utils.py, copy_bettergi_config.py, launcher.py, and generate_onedragon_config.py.

Key Changes

  • Test Environment Establishment

    • Created tests/ directory with standard initialization to support automated test discovery.
  • Path Utility Tests (tests/test_utils.py)

    • Validates absolute path resolution (get_root_dir()), directory caching, and recursive subdirectory generation (join_dir_path_with_mk()) using safe, isolated tempfile.TemporaryDirectory contexts.
  • Configuration Distribution Tests (tests/test_copy_bettergi_config.py)

    • Tests reading YAML-based config.yml settings to resolve the target destination path for specific scripts (e.g., '原神').
    • Verifies file-copying logic with mock source and target directory state matching.
  • Launcher & Timeout Automation Tests (tests/test_launcher.py)

    • Asserts weekday index arithmetic and weekday-specific weekly_timeouts overrides for script configurations.
    • Validates assertions for malformed timeout lists and checks subprocess execution paths within run_launcher().
  • Workflow Tests with Dynamic Mocking (tests/test_generate_onedragon_config.py)

    • Implemented headless testing-compliant workflow checks by isolating PySide6 and qfluentwidgets GUI modules at the module lifecycle bounds:
original_modules = {}

def setUpModule():
    global generate_onedragon_config
    # Mock GUI dependencies to prevent ModuleNotFoundError in headless/CI test runners
    for mod in ['PySide6', 'PySide6.QtWidgets', 'PySide6.QtGui', 'qfluentwidgets']:
        original_modules[mod] = sys.modules.get(mod)
        sys.modules[mod] = MagicMock()
    
    import generate_onedragon_config as goc
    generate_onedragon_config = goc

def tearDownModule():
    # Restore modules post-test to avoid process-level side-effects
    for mod, orig in original_modules.items():
        if orig is None:
            sys.modules.pop(mod, None)
        else:
            sys.modules[mod] = orig

Copilot AI requested a review from LevelDownRefine July 7, 2026 07:56
@LevelDownRefine
LevelDownRefine marked this pull request as ready for review July 7, 2026 07:57
@LevelDownRefine
LevelDownRefine merged commit d4e9367 into main Jul 7, 2026
1 check passed
@LevelDownRefine
LevelDownRefine deleted the copilot/create-tests-folder branch July 7, 2026 08:07
LevelDownRefine added a commit that referenced this pull request Aug 10, 2026
1. 删除未使用的 INPUT_MAX_W
2. 修正 QGridLayout 注释 stretch=1 → 固定宽
3. 删除 widgets.py 卡片阴影变更日志注释
4. _DUNGEON_BTN_QSS 硬编码字体 → theme.FONT_FAMILY
5. setFixedHeight(30) 提取为 INPUT_FIXED_H 常量
6. LABEL_WIDTH 注释不一致修正
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants