Skip to content

Commit

Permalink
Implement checkbox version tracking in TO (#160)
Browse files Browse the repository at this point in the history
* Implement checkbox version tracking in TO

* Fix mypy and pytest issues
  • Loading branch information
andrejvelichkovski committed Apr 26, 2024
1 parent 38e8498 commit baefb50
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
"""Add checkbox version column
Revision ID: 5d36de5a8a48
Revises: 624a270a03dc
Create Date: 2024-04-25 15:25:33.149465+00:00
"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = "5d36de5a8a48"
down_revision = "624a270a03dc"
branch_labels = None
depends_on = None


def upgrade() -> None:
op.add_column(
"test_execution",
sa.Column("checkbox_version", sa.String(length=200), nullable=True),
)


def downgrade() -> None:
op.drop_column("test_execution", "checkbox_version")
2 changes: 2 additions & 0 deletions backend/test_observer/controllers/reports/reports.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
TestExecution.status,
TestExecution.review_decision,
TestExecution.review_comment,
TestExecution.c3_link,
TestExecution.checkbox_version,
Environment.name,
Environment.architecture,
TestCase.template_id,
Expand Down
2 changes: 2 additions & 0 deletions backend/test_observer/controllers/test_executions/end_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ def end_test_execution(request: EndTestExecutionRequest, db: Session = Depends(g
if request.c3_link is not None:
test_execution.c3_link = request.c3_link

test_execution.checkbox_version = request.checkbox_version

db.commit()


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ class C3TestResult(BaseModel):
class EndTestExecutionRequest(BaseModel):
ci_link: Annotated[str, HttpUrl]
c3_link: Annotated[str, HttpUrl] | None = None
checkbox_version: str | None = None
test_results: list[C3TestResult]


Expand Down
4 changes: 4 additions & 0 deletions backend/test_observer/data_access/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,10 @@ class TestExecution(Base):
)
review_comment: Mapped[str] = mapped_column(default="")

checkbox_version: Mapped[str | None] = mapped_column(
String(200), nullable=True, default=None
)

@property
def is_approved(self) -> bool:
return (len(self.review_decision) > 0) and (
Expand Down
2 changes: 2 additions & 0 deletions backend/tests/controllers/reports/test_reports.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ def _expected_report_row(test_result: TestResult) -> list:
test_execution.status.name,
str(test_execution.review_decision),
test_execution.review_comment,
"" if not test_execution.c3_link else test_execution.c3_link,
"" if not test_execution.checkbox_version else test_execution.checkbox_version,
environment.name,
environment.architecture,
test_case.template_id,
Expand Down
2 changes: 2 additions & 0 deletions backend/tests/controllers/test_executions/test_end_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ def test_report_test_execution_data(test_client: TestClient, generator: DataGene
json={
"ci_link": test_execution.ci_link,
"c3_link": c3_link,
"checkbox_version": "3.3.0",
"test_results": [
{
"name": test_case.name,
Expand All @@ -62,6 +63,7 @@ def test_report_test_execution_data(test_client: TestClient, generator: DataGene
assert response.status_code == 200
assert test_execution.status == TestExecutionStatus.PASSED
assert test_execution.c3_link == c3_link
assert test_execution.checkbox_version == "3.3.0"
assert test_execution.test_results[0].test_case.name == test_case.name
assert test_execution.test_results[0].status == TestResultStatus.PASSED
assert test_execution.test_results[0].test_case.template_id == test_case.template_id
Expand Down
2 changes: 2 additions & 0 deletions backend/tests/data_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ def gen_test_execution(
status: TestExecutionStatus = TestExecutionStatus.NOT_STARTED,
review_decision: list[TestExecutionReviewDecision] | None = None,
review_comment: str = "",
checkbox_version: str | None = None,
) -> TestExecution:
if review_decision is None:
review_decision = []
Expand All @@ -137,6 +138,7 @@ def gen_test_execution(
status=status,
review_decision=review_decision,
review_comment=review_comment,
checkbox_version=checkbox_version,
)
self.db_session.add(test_execution)
self.db_session.commit()
Expand Down

0 comments on commit baefb50

Please sign in to comment.