Skip to content

Commit

Permalink
Merge branch 'main' into fetch-testexecution-status-from-c3
Browse files Browse the repository at this point in the history
  • Loading branch information
andrejvelichkovski committed Nov 28, 2023
2 parents fa2e104 + 8a08727 commit c2eb357
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 2 deletions.
15 changes: 14 additions & 1 deletion backend/test_observer/controllers/artefacts/artefacts.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
get_reports_ids,
get_statuses_ids,
)
from .models import ArtefactBuildDTO, ArtefactDTO
from .models import ArtefactBuildDTO, ArtefactDTO, ArtefactPatch

router = APIRouter()

Expand Down Expand Up @@ -65,6 +65,19 @@ def get_artefact(artefact_id: int, db: Session = Depends(get_db)):
return artefact


@router.patch("/{artefact_id}")
def patch_artefact(
artefact_id: int, request: ArtefactPatch, db: Session = Depends(get_db)
):
artefact = db.get(Artefact, artefact_id)

if artefact is None:
raise HTTPException(status_code=404, detail="Artefact not found")

artefact.status = request.status
db.commit()


@router.get("/{artefact_id}/builds", response_model=list[ArtefactBuildDTO])
def get_artefact_builds(
artefact_id: int,
Expand Down
6 changes: 5 additions & 1 deletion backend/test_observer/controllers/artefacts/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
from pydantic import AliasPath, BaseModel, ConfigDict, Field

from test_observer.external_apis.c3.models import TestResult

from test_observer.data_access.models_enums import ArtefactStatus

class TestExecutionStatus(str, Enum):
IN_PROGRESS = "IN_PROGRESS"
Expand Down Expand Up @@ -70,3 +70,7 @@ class ArtefactBuildDTO(BaseModel):
architecture: str
revision: int | None
test_executions: list[TestExecutionDTO]


class ArtefactPatch(BaseModel):
status: ArtefactStatus
15 changes: 15 additions & 0 deletions backend/tests/controllers/artefacts/test_artefacts.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
SubmissionStatus,
)
from test_observer.main import app
from test_observer.data_access.models_enums import ArtefactStatus
from tests.helpers import create_artefact


Expand Down Expand Up @@ -211,3 +212,17 @@ def test_correct_test_execution_status(
],
}
]


def test_artefact_signoff(db_session: Session, test_client: TestClient):
artefact = create_artefact(db_session, "candidate")

response = test_client.patch(
f"/v1/artefacts/{artefact.id}",
json={"status": ArtefactStatus.APPROVED},
)

db_session.refresh(artefact)

assert response.status_code == 200
assert artefact.status == ArtefactStatus.APPROVED

0 comments on commit c2eb357

Please sign in to comment.