feat: initialize project structure and configuration
- Create backend directory structure (app/models, app/schemas, app/services, app/api, app/tasks, tests) - Create frontend directory structure (src/router, src/views, src/components, src/api, src/stores) - Create data directories (ssh_keys, repos) - Add requirements.txt with FastAPI, SQLAlchemy, Pydantic, and testing dependencies - Add frontend package.json with Vue 3, Vue Router, Pinia, and Element Plus - Add .env.example with configuration template - Add .gitignore for Python, data directories, and frontend - Add pytest conftest.py with test fixtures for database and environment Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
0
backend/app/__init__.py
Normal file
0
backend/app/__init__.py
Normal file
0
backend/app/api/__init__.py
Normal file
0
backend/app/api/__init__.py
Normal file
0
backend/app/models/__init__.py
Normal file
0
backend/app/models/__init__.py
Normal file
0
backend/app/schemas/__init__.py
Normal file
0
backend/app/schemas/__init__.py
Normal file
0
backend/app/services/__init__.py
Normal file
0
backend/app/services/__init__.py
Normal file
0
backend/app/tasks/__init__.py
Normal file
0
backend/app/tasks/__init__.py
Normal file
14
backend/requirements.txt
Normal file
14
backend/requirements.txt
Normal file
@@ -0,0 +1,14 @@
|
||||
fastapi==0.109.0
|
||||
uvicorn[standard]==0.27.0
|
||||
sqlalchemy==2.0.25
|
||||
pydantic==2.5.3
|
||||
pydantic-settings==2.1.0
|
||||
python-multipart==0.0.6
|
||||
apscheduler==3.10.4
|
||||
paramiko==3.4.0
|
||||
gitpython==3.1.40
|
||||
cryptography==41.0.7
|
||||
requests==2.31.0
|
||||
pytest==7.4.4
|
||||
pytest-asyncio==0.23.3
|
||||
httpx==0.26.0
|
||||
0
backend/tests/__init__.py
Normal file
0
backend/tests/__init__.py
Normal file
55
backend/tests/conftest.py
Normal file
55
backend/tests/conftest.py
Normal file
@@ -0,0 +1,55 @@
|
||||
import os
|
||||
import sys
|
||||
import tempfile
|
||||
import pytest
|
||||
from pathlib import Path
|
||||
|
||||
# Add backend to path
|
||||
sys.path.insert(0, str(Path(__file__).parent.parent))
|
||||
|
||||
from sqlalchemy import create_engine
|
||||
from sqlalchemy.orm import sessionmaker
|
||||
from app.models import Base
|
||||
|
||||
|
||||
@pytest.fixture(scope="function")
|
||||
def db_path(tmp_path):
|
||||
"""临时数据库路径."""
|
||||
return tmp_path / "test.db"
|
||||
|
||||
|
||||
@pytest.fixture(scope="function")
|
||||
def db_engine(db_path):
|
||||
"""临时数据库引擎."""
|
||||
engine = create_engine(f"sqlite:///{db_path}", connect_args={"check_same_thread": False})
|
||||
Base.metadata.create_all(engine)
|
||||
yield engine
|
||||
engine.dispose()
|
||||
|
||||
|
||||
@pytest.fixture(scope="function")
|
||||
def db_session(db_engine):
|
||||
"""临时数据库会话."""
|
||||
SessionLocal = sessionmaker(bind=db_engine, autocommit=False, autoflush=False)
|
||||
session = SessionLocal()
|
||||
yield session
|
||||
session.close()
|
||||
|
||||
|
||||
@pytest.fixture(scope="function")
|
||||
def test_encrypt_key():
|
||||
"""测试加密密钥."""
|
||||
import base64
|
||||
return base64.b64encode(b'test-key-32-bytes-long-1234567890').decode()
|
||||
|
||||
|
||||
@pytest.fixture(scope="function")
|
||||
def test_env_vars(db_path, test_encrypt_key, monkeypatch):
|
||||
"""设置测试环境变量."""
|
||||
monkeypatch.setenv("GM_ENCRYPT_KEY", test_encrypt_key)
|
||||
monkeypatch.setenv("GM_API_TOKEN", "test-token")
|
||||
monkeypatch.setenv("GM_DATA_DIR", str(db_path.parent))
|
||||
return {
|
||||
"GM_ENCRYPT_KEY": test_encrypt_key,
|
||||
"GM_API_TOKEN": "test-token",
|
||||
}
|
||||
Reference in New Issue
Block a user