Files
firefrost-services/services/modpack-version-checker/tests/test_config.py
Claude (The Golden Chronicler #50) 04e9b407d5 feat: Migrate Arbiter and Modpack Version Checker to monorepo
WHAT WAS DONE:
- Migrated Arbiter (discord-oauth-arbiter) code to services/arbiter/
- Migrated Modpack Version Checker code to services/modpack-version-checker/
- Created .env.example for Arbiter with all required environment variables
- Moved systemd service file to services/arbiter/deploy/
- Organized directory structure per Gemini monorepo recommendations

WHY:
- Consolidate all service code in one repository
- Prepare for Gemini code review (Panel v1.12 compatibility check)
- Enable service-prefixed Git tagging (arbiter-v2.1.0, modpack-v1.0.0)
- Support npm workspaces for shared dependencies

SERVICES MIGRATED:
1. Arbiter (Discord OAuth bot) - Originally written by Gemini + Claude
   - Full source code from ops-manual docs/implementation/
   - Created comprehensive .env.example
   - Ready for Panel v1.12 compatibility verification

2. Modpack Version Checker (Python CLI tool)
   - Full source code from ops-manual docs/tasks/
   - Written for Panel v1.11, needs Gemini review for v1.12
   - Never had code review before

STILL TODO:
- Whitelist Manager - Pull from Billing VPS (38.68.14.188)
  - Currently deployed and running
  - Needs Panel v1.12 API compatibility fix (Task #86)
  - Requires SSH access to pull code

NEXT STEPS:
- Gemini code review for Panel v1.12 API compatibility
- Create package.json for each service
- Test npm workspaces integration
- Deploy after verification

FILES:
- services/arbiter/ (25 new files, full application)
- services/modpack-version-checker/ (21 new files, full application)

Signed-off-by: The Golden Chronicler <claude@firefrostgaming.com>
2026-03-31 21:52:42 +00:00

73 lines
2.1 KiB
Python

"""Tests for config.py."""
import json
from pathlib import Path
from unittest.mock import patch
import pytest
from modpack_checker.config import Config
def test_default_values():
cfg = Config()
assert cfg.curseforge_api_key == ""
assert cfg.discord_webhook_url is None
assert cfg.check_interval_hours == 6
assert cfg.notification_on_update is True
def test_is_configured_without_key():
assert Config().is_configured() is False
def test_is_configured_with_key():
assert Config(curseforge_api_key="abc123").is_configured() is True
def test_save_and_load_round_trip(tmp_path):
config_dir = tmp_path / ".config" / "modpack-checker"
config_file = config_dir / "config.json"
with patch("modpack_checker.config.CONFIG_DIR", config_dir), \
patch("modpack_checker.config.CONFIG_FILE", config_file):
original = Config(
curseforge_api_key="test-key-xyz",
check_interval_hours=12,
notification_on_update=False,
)
original.save()
loaded = Config.load()
assert loaded.curseforge_api_key == "test-key-xyz"
assert loaded.check_interval_hours == 12
assert loaded.notification_on_update is False
def test_load_returns_defaults_when_file_missing(tmp_path):
config_file = tmp_path / "nonexistent.json"
with patch("modpack_checker.config.CONFIG_FILE", config_file):
cfg = Config.load()
assert cfg.curseforge_api_key == ""
def test_load_returns_defaults_on_corrupted_file(tmp_path):
config_dir = tmp_path / ".config" / "modpack-checker"
config_dir.mkdir(parents=True)
config_file = config_dir / "config.json"
config_file.write_text("{ this is not valid json }")
with patch("modpack_checker.config.CONFIG_DIR", config_dir), \
patch("modpack_checker.config.CONFIG_FILE", config_file):
cfg = Config.load()
assert cfg.curseforge_api_key == ""
def test_interval_bounds():
with pytest.raises(Exception):
Config(check_interval_hours=0)
with pytest.raises(Exception):
Config(check_interval_hours=169)