Skip to content

Commit

Permalink
Fix mypy issues
Browse files Browse the repository at this point in the history
  • Loading branch information
omar-selo committed Dec 1, 2023
1 parent bf0f0da commit e5b62db
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 9 deletions.
2 changes: 1 addition & 1 deletion backend/scripts/seed_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@
def seed_data(client: TestClient | requests.Session):
for request in REQUESTS:
client.put(
START_TEST_EXECUTION_URL, data=request.model_dump_json()
START_TEST_EXECUTION_URL, json=request.model_dump(mode="json")
).raise_for_status()


Expand Down
4 changes: 3 additions & 1 deletion backend/test_observer/controllers/test_executions/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
# Omar Selo <[email protected]>


from typing import Annotated

from pydantic import BaseModel, HttpUrl, field_serializer, model_validator

from test_observer.data_access.models_enums import FamilyName, TestExecutionStatus
Expand All @@ -35,7 +37,7 @@ class StartTestExecutionRequest(BaseModel):
arch: str
execution_stage: str
environment: str
ci_link: HttpUrl
ci_link: Annotated[str, HttpUrl]

@field_serializer("family")
def serialize_dt(self, family: FamilyName):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,18 @@ def patch_test_execution(
request: TestExecutionsPatchRequest,
db: Session = Depends(get_db),
):
test_execution = db.query(TestExecution).filter(TestExecution.id == id).one()
test_execution.c3_link = request.c3_link
test_execution.ci_link = request.ci_link
test_execution.status = request.status
test_execution = db.get(TestExecution, id)

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

if request.c3_link is not None:
test_execution.c3_link = str(request.c3_link)

if request.ci_link is not None:
test_execution.ci_link = str(request.ci_link)

if request.status is not None:
test_execution.status = request.status

db.commit()
4 changes: 2 additions & 2 deletions backend/test_observer/data_access/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,8 @@ class TestExecution(Base):

__tablename__ = "test_execution"

ci_link: Mapped[str] = mapped_column(String(200), nullable=True)
c3_link: Mapped[str] = mapped_column(String(200), nullable=True)
ci_link: Mapped[str | None] = mapped_column(String(200), nullable=True)
c3_link: Mapped[str | None] = mapped_column(String(200), nullable=True)
# Relationships
artefact_build_id: Mapped[int] = mapped_column(
ForeignKey("artefact_build.id", ondelete="CASCADE")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ def test_uses_existing_models(db_session: Session, test_client: TestClient):

test_execution_id = test_client.put(
"/v1/test-executions/start-test",
data=request.model_dump_json(),
json=request.model_dump(mode="json"),
).json()["id"]

test_execution = (
Expand Down

0 comments on commit e5b62db

Please sign in to comment.