dacf105200
Backend tests: - Unit tests for docker_build service (successful/failed builds, context, paths) - Unit tests for readiness_probe service (success, timeout, retries, edge cases) - Integration tests for config_folders API (CRUD + project overrides) - Integration tests for tool_types API with new fields - Integration tests for tool_configs API with new fields Frontend tests: - ToolWorkshopPage component tests (all 3 tabs, create/edit/delete) - API client tests for tool_types and config_folders Fixes: - Add field_validator import to tool_configs.py - Add JSON import to tool_config model - Update frontend test button names to match UI (Create Tool Type, Add Config, Create Folder) Quality gates: backend unit tests passing (23/23)
49 lines
1.8 KiB
Python
49 lines
1.8 KiB
Python
import uuid
|
|
from typing import TYPE_CHECKING
|
|
|
|
from sqlalchemy import ForeignKey, JSON, String, Text
|
|
from sqlalchemy import Uuid as UUID
|
|
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
|
|
|
from src.models.base import Base, TimestampMixin, UUIDPrimaryKeyMixin
|
|
|
|
if TYPE_CHECKING:
|
|
from src.models.project import Project
|
|
from src.models.tool_type import ToolType
|
|
from src.models.user import User
|
|
|
|
|
|
class ToolConfig(UUIDPrimaryKeyMixin, TimestampMixin, Base):
|
|
__tablename__ = "tool_configs"
|
|
|
|
user_id: Mapped[uuid.UUID] = mapped_column(
|
|
UUID(), ForeignKey("users.id"), nullable=False
|
|
)
|
|
tool_type_id: Mapped[uuid.UUID] = mapped_column(
|
|
UUID(), ForeignKey("tool_types.id"), nullable=False
|
|
)
|
|
project_id: Mapped[uuid.UUID | None] = mapped_column(
|
|
UUID(), ForeignKey("projects.id"), nullable=True
|
|
)
|
|
key: Mapped[str] = mapped_column(String(255), nullable=False)
|
|
value: Mapped[str] = mapped_column(Text, nullable=False)
|
|
config_type: Mapped[str] = mapped_column(
|
|
String(20), nullable=False, default="env"
|
|
) # "env" or "file"
|
|
file_path: Mapped[str | None] = mapped_column(
|
|
String(1024), nullable=True
|
|
) # Only for file type
|
|
port_override: Mapped[int | None] = mapped_column(nullable=True)
|
|
start_command: Mapped[str | None] = mapped_column(Text, nullable=True)
|
|
working_directory: Mapped[str | None] = mapped_column(Text, nullable=True)
|
|
environment_variables: Mapped[dict | None] = mapped_column(
|
|
JSON, default=dict, nullable=True
|
|
)
|
|
volumes: Mapped[list[dict] | None] = mapped_column(
|
|
JSON, default=list, nullable=True
|
|
)
|
|
|
|
user: Mapped["User"] = relationship()
|
|
tool_type: Mapped["ToolType"] = relationship()
|
|
project: Mapped["Project | None"] = relationship()
|