refactor: Unify leggen and leggend packages into single leggen package

- Merge leggend API components into leggen (api/, services/, background/)
- Replace leggend command with 'leggen server' subcommand
- Consolidate configuration systems into leggen.utils.config
- Update environment variables: LEGGEND_API_URL -> LEGGEN_API_URL
- Rename LeggendAPIClient -> LeggenAPIClient
- Update all documentation, Docker configs, and compose files
- Fix all import statements and test references
- Remove duplicate utility files and clean up package structure

All tests passing (101/101), linting clean, server functionality preserved.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Elisiário Couto
2025-09-14 18:02:55 +01:00
committed by Elisiário Couto
parent 0e645d9bae
commit 318ca517f7
50 changed files with 494 additions and 463 deletions

View File

@@ -4,7 +4,7 @@ import pytest
from unittest.mock import patch, AsyncMock, MagicMock
from datetime import datetime
from leggend.background.scheduler import BackgroundScheduler
from leggen.background.scheduler import BackgroundScheduler
@pytest.mark.unit
@@ -20,8 +20,8 @@ class TestBackgroundScheduler:
def scheduler(self):
"""Create scheduler instance for testing."""
with (
patch("leggend.background.scheduler.SyncService"),
patch("leggend.background.scheduler.config") as mock_config,
patch("leggen.background.scheduler.SyncService"),
patch("leggen.background.scheduler.config") as mock_config,
):
mock_config.scheduler_config = {
"sync": {"enabled": True, "hour": 3, "minute": 0}
@@ -37,7 +37,7 @@ class TestBackgroundScheduler:
def test_scheduler_start_default_config(self, scheduler, mock_config):
"""Test starting scheduler with default configuration."""
with patch("leggend.config.config") as mock_config_obj:
with patch("leggen.utils.config.config") as mock_config_obj:
mock_config_obj.scheduler_config = mock_config
# Mock the job that gets added
@@ -58,7 +58,7 @@ class TestBackgroundScheduler:
with (
patch.object(scheduler, "scheduler") as mock_scheduler,
patch("leggend.background.scheduler.config") as mock_config_obj,
patch("leggen.background.scheduler.config") as mock_config_obj,
):
mock_config_obj.scheduler_config = disabled_config
mock_scheduler.running = False
@@ -79,7 +79,7 @@ class TestBackgroundScheduler:
}
}
with patch("leggend.config.config") as mock_config_obj:
with patch("leggen.utils.config.config") as mock_config_obj:
mock_config_obj.scheduler_config = cron_config
scheduler.start()
@@ -97,7 +97,7 @@ class TestBackgroundScheduler:
with (
patch.object(scheduler, "scheduler") as mock_scheduler,
patch("leggend.background.scheduler.config") as mock_config_obj,
patch("leggen.background.scheduler.config") as mock_config_obj,
):
mock_config_obj.scheduler_config = invalid_cron_config
mock_scheduler.running = False
@@ -187,7 +187,7 @@ class TestBackgroundScheduler:
def test_scheduler_job_max_instances(self, scheduler, mock_config):
"""Test that sync jobs have max_instances=1."""
with patch("leggend.config.config") as mock_config_obj:
with patch("leggen.utils.config.config") as mock_config_obj:
mock_config_obj.scheduler_config = mock_config
scheduler.start()