Add configuration rules, refactor settings management, and enhance import functionality

- Introduced a new configuration file `.cursorrules` to define coding standards, error handling, testing requirements, and project-specific guidelines.
- Refactored `config.py` to implement a `Settings` dataclass for better management of environment variables, improving testability and maintainability.
- Updated the import duty schedule handler to utilize session management with `session_scope`, ensuring proper database session handling.
- Enhanced the import service to streamline the duty schedule import process, improving code organization and readability.
- Added new service layer functions to encapsulate business logic related to group duty pinning and duty schedule imports.
- Updated README documentation to reflect the new configuration structure and improved import functionality.
This commit is contained in:
2026-02-18 12:35:11 +03:00
parent 8697b9e30b
commit 5331fac334
25 changed files with 1032 additions and 397 deletions

View File

@@ -1,7 +1,7 @@
"""Tests for FastAPI app /api/duties."""
import time
from unittest.mock import patch
from unittest.mock import ANY, patch
import pytest
from fastapi.testclient import TestClient
@@ -50,7 +50,7 @@ def test_duties_200_when_skip_auth(mock_fetch, client):
)
assert r.status_code == 200
assert r.json() == []
mock_fetch.assert_called_once_with("2025-01-01", "2025-01-31")
mock_fetch.assert_called_once_with(ANY, "2025-01-01", "2025-01-31")
@patch("api.app.validate_init_data_with_reason")
@@ -105,7 +105,7 @@ def test_duties_200_with_allowed_user(mock_can_access, mock_validate, client):
assert r.status_code == 200
assert len(r.json()) == 1
assert r.json()[0]["full_name"] == "Иван Иванов"
mock_fetch.assert_called_once_with("2025-01-01", "2025-01-31")
mock_fetch.assert_called_once_with(ANY, "2025-01-01", "2025-01-31")
def test_duties_e2e_auth_real_validation(client, monkeypatch):
@@ -130,7 +130,7 @@ def test_duties_e2e_auth_real_validation(client, monkeypatch):
)
assert r.status_code == 200
assert r.json() == []
mock_fetch.assert_called_once_with("2025-01-01", "2025-01-31")
mock_fetch.assert_called_once_with(ANY, "2025-01-01", "2025-01-31")
@patch("api.app.config.MINI_APP_SKIP_AUTH", True)