Skip to content

Commit

Permalink
lost of api tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mariusandra committed Dec 21, 2024
1 parent 4272fea commit b8e1d9a
Show file tree
Hide file tree
Showing 18 changed files with 291 additions and 576 deletions.
5 changes: 3 additions & 2 deletions backend/app/api/frames.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,8 @@ async def api_frame_deploy_event(id: int):
async def api_frame_update_endpoint(
id: int,
data: FrameUpdateRequest,
db: Session = Depends(get_db)
db: Session = Depends(get_db),
redis: Redis = Depends(get_redis)
):
frame = db.get(Frame, id)
if not frame:
Expand All @@ -334,7 +335,7 @@ async def api_frame_update_endpoint(
for field, value in update_data.items():
setattr(frame, field, value)

await update_frame(db, frame)
await update_frame(db, redis, frame)

if data.next_action == 'restart':
from app.tasks import restart_frame
Expand Down
11 changes: 4 additions & 7 deletions backend/app/api/repositories.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from app.utils.network import is_safe_host
from app.schemas.repositories import (
RepositoryCreateRequest,
RepositoryUpdateRequest,
RepositoryResponse,
RepositoriesListResponse
)
Expand All @@ -19,10 +20,6 @@
FRAMEOS_SAMPLES_URL = "https://repo.frameos.net/samples/repository.json"
FRAMEOS_GALLERY_URL = "https://repo.frameos.net/gallery/repository.json"

class RepositoryUpdateRequest(RepositoryCreateRequest):
# Both fields optional for partial update
url: str | None = None
name: str | None = None

@private_api.post("/repositories", response_model=RepositoryResponse, status_code=201)
async def create_repository(data: RepositoryCreateRequest, db: Session = Depends(get_db)):
Expand Down Expand Up @@ -79,7 +76,7 @@ async def get_repositories(db: Session = Depends(get_db)):
raise HTTPException(status_code=500, detail="Database error")

@private_api.get("/repositories/{repository_id}", response_model=RepositoryResponse)
async def get_repository(repository_id: int, db: Session = Depends(get_db)):
async def get_repository(repository_id: str, db: Session = Depends(get_db)):
try:
repository = db.get(Repository, repository_id)
if not repository:
Expand All @@ -91,7 +88,7 @@ async def get_repository(repository_id: int, db: Session = Depends(get_db)):
raise HTTPException(status_code=500, detail="Database error")

@private_api.patch("/repositories/{repository_id}", response_model=RepositoryResponse)
async def update_repository(repository_id: int, data: RepositoryUpdateRequest, db: Session = Depends(get_db)):
async def update_repository(repository_id: str, data: RepositoryUpdateRequest, db: Session = Depends(get_db)):
try:
repository = db.get(Repository, repository_id)
if not repository:
Expand All @@ -110,7 +107,7 @@ async def update_repository(repository_id: int, data: RepositoryUpdateRequest, d
raise HTTPException(status_code=500, detail="Database error")

@private_api.delete("/repositories/{repository_id}")
async def delete_repository(repository_id: int, db: Session = Depends(get_db)):
async def delete_repository(repository_id: str, db: Session = Depends(get_db)):
try:
repository = db.get(Repository, repository_id)
if not repository:
Expand Down
2 changes: 1 addition & 1 deletion backend/app/api/templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ async def get_template_image(template_id: str, token: str, request: Request, db:


@private_api.get("/templates/{template_id}/export")
async def export_template(template_id: int, db: Session = Depends(get_db)):
async def export_template(template_id: str, db: Session = Depends(get_db)):
template = db.get(Template, template_id)
return respond_with_template(template)

Expand Down
Loading

0 comments on commit b8e1d9a

Please sign in to comment.