• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Clinical-Genomics / arnold / 7126237250

07 Dec 2023 09:28AM UTC coverage: 0.0%. Remained the same
7126237250

push

github

web-flow
add(case api endpoints) (#51) (patch)

## Added
Endpoinst to create and get cases to the arnold API

0 of 27 new or added lines in 4 files covered. (0.0%)

1 existing line in 1 file now uncovered.

0 of 898 relevant lines covered (0.0%)

0.0 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/arnold/api/api_v1/endpoints/case.py
NEW
1
from fastapi import APIRouter, Body, Depends, status
×
NEW
2
from fastapi.responses import JSONResponse
×
3

NEW
4
from arnold.crud import create, read
×
NEW
5
from arnold.adapter.plugin import ArnoldAdapter
×
NEW
6
from arnold.settings import get_arnold_adapter
×
NEW
7
from arnold.models.database.case import Case
×
8

NEW
9
router = APIRouter()
×
10

11

NEW
12
@router.post(
×
13
    "/case/",
14
    response_description="Create a new case document",
15
    status_code=status.HTTP_201_CREATED,
16
    response_model=Case,
17
)
NEW
18
def create_case(
×
19
    case: Case = Body(...),
20
    adapter: ArnoldAdapter = Depends(get_arnold_adapter),
21
) -> JSONResponse:
22
    """Create a case document in the database."""
NEW
23
    if read.case.get_case(case_id=case.id, adapter=adapter):
×
NEW
24
        return JSONResponse(
×
25
            status_code=status.HTTP_409_CONFLICT,
26
            content="Case already in database.",
27
        )
NEW
28
    try:
×
NEW
29
        create.create_case(case=case, adapter=adapter)
×
NEW
30
    except Exception as error:
×
NEW
31
        return JSONResponse(
×
32
            status_code=status.HTTP_405_METHOD_NOT_ALLOWED, content=f"Error: {error}"
33
        )
NEW
34
    return JSONResponse(
×
35
        status_code=status.HTTP_201_CREATED, content=f"Case with {case.id} was created."
36
    )
37

38

NEW
39
@router.get(
×
40
    "/case/{case_id}",
41
    response_description="Get a case document.",
42
    status_code=status.HTTP_200_OK,
43
    response_model=Case,
44
)
NEW
45
def get_case(
×
46
    case_id: str, adapter: ArnoldAdapter = Depends(get_arnold_adapter)
47
) -> Case | JSONResponse:
48
    """Retrieve a case document from the database."""
NEW
49
    try:
×
NEW
50
        case: Case = read.case.get_case(case_id=case_id, adapter=adapter)
×
NEW
51
        return case
×
NEW
52
    except Exception as error:
×
NEW
53
        return JSONResponse(
×
54
            status_code=status.HTTP_500_INTERNAL_SERVER_ERROR,
55
            content=f"Could not find entry with {case_id} in database. {error}",
56
        )
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc