Skip to content

Commit

Permalink
Take ci_link from start of test execution
Browse files Browse the repository at this point in the history
  • Loading branch information
omar-selo committed Dec 1, 2023
1 parent 0f04c7e commit 5ecd073
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 3 deletions.
11 changes: 10 additions & 1 deletion backend/scripts/seed_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
arch="armhf",
execution_stage="beta",
environment="rpi2",
ci_link="http://localhost",
),
StartTestExecutionRequest(
family=FamilyName.SNAP,
Expand All @@ -29,6 +30,7 @@
arch="armhf",
execution_stage="beta",
environment="rpi2",
ci_link="http://localhost",
),
StartTestExecutionRequest(
family=FamilyName.SNAP,
Expand All @@ -40,6 +42,7 @@
arch="armhf",
execution_stage="beta",
environment="rpi2",
ci_link="http://localhost",
),
StartTestExecutionRequest(
family=FamilyName.SNAP,
Expand All @@ -51,6 +54,7 @@
arch="amd64",
execution_stage="edge",
environment="dawson-i",
ci_link="http://localhost",
),
StartTestExecutionRequest(
family=FamilyName.SNAP,
Expand All @@ -62,6 +66,7 @@
arch="arm64",
execution_stage="candidate",
environment="cm3",
ci_link="http://localhost",
),
StartTestExecutionRequest(
family=FamilyName.SNAP,
Expand All @@ -73,6 +78,7 @@
arch="arm64",
execution_stage="stable",
environment="cm3",
ci_link="http://localhost",
),
StartTestExecutionRequest(
family=FamilyName.SNAP,
Expand All @@ -84,6 +90,7 @@
arch="arm64",
execution_stage="stable",
environment="dragonboard",
ci_link="http://localhost",
),
StartTestExecutionRequest(
family=FamilyName.DEB,
Expand All @@ -94,6 +101,7 @@
arch="arm64",
execution_stage="proposed",
environment="rpi400",
ci_link="http://localhost",
),
StartTestExecutionRequest(
family=FamilyName.DEB,
Expand All @@ -104,14 +112,15 @@
arch="arm64",
execution_stage="updates",
environment="rpi400",
ci_link="http://localhost",
),
]


def seed_data(client: TestClient | requests.Session):
for request in REQUESTS:
client.put(
START_TEST_EXECUTION_URL, json=request.model_dump()
START_TEST_EXECUTION_URL, data=request.model_dump_json()
).raise_for_status()


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


from pydantic import BaseModel, field_serializer, model_validator
from pydantic import BaseModel, HttpUrl, field_serializer, model_validator

from test_observer.data_access.models_enums import FamilyName, TestExecutionStatus

Expand All @@ -35,6 +35,7 @@ class StartTestExecutionRequest(BaseModel):
arch: str
execution_stage: str
environment: str
ci_link: HttpUrl

@field_serializer("family")
def serialize_dt(self, family: FamilyName):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ def start_test_execution(
},
creation_kwargs={
"status": TestExecutionStatus.IN_PROGRESS,
"ci_link": request.ci_link,
},
)
return {"id": test_execution.id}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ def test_creates_all_data_models(db_session: Session, test_client: TestClient):
"arch": "arm64",
"execution_stage": "beta",
"environment": "cm3",
"ci_link": "http://localhost",
},
)

Expand Down Expand Up @@ -109,6 +110,7 @@ def test_invalid_artefact_format(test_client: TestClient):
"arch": "arm64",
"execution_stage": "beta",
"environment": "cm3",
"ci_link": "http://localhost",
},
)
assert response.status_code == 422
Expand All @@ -125,6 +127,7 @@ def test_uses_existing_models(db_session: Session, test_client: TestClient):
arch="arm64",
execution_stage="beta",
environment="cm3",
ci_link="http://localhost/",
)
stage = (
db_session.query(Stage).filter(Stage.name == request.execution_stage).first()
Expand All @@ -151,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",
json=request.model_dump(),
data=request.model_dump_json(),
).json()["id"]

test_execution = (
Expand All @@ -163,6 +166,7 @@ def test_uses_existing_models(db_session: Session, test_client: TestClient):
assert test_execution.artefact_build_id == artefact_build.id
assert test_execution.environment_id == environment.id
assert test_execution.status == TestExecutionStatus.IN_PROGRESS
assert test_execution.ci_link == "http://localhost/"


def test_updates_test_execution(db_session: Session, test_client: TestClient):
Expand Down

0 comments on commit 5ecd073

Please sign in to comment.