Skip to content

Commit

Permalink
Add is_confirmed to environment issue
Browse files Browse the repository at this point in the history
  • Loading branch information
omar-selo committed Sep 16, 2024
1 parent dfa2c23 commit 9b19cf2
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ def upgrade() -> None:
sa.Column("environment_name", sa.String(), nullable=False),
sa.Column("url", sa.String(), nullable=False),
sa.Column("description", sa.String(), nullable=False),
sa.Column("is_confirmed", sa.Boolean(), nullable=False),
sa.Column("id", sa.Integer(), autoincrement=True, nullable=False),
sa.Column("created_at", sa.DateTime(), nullable=False),
sa.Column("updated_at", sa.DateTime(), nullable=False),
Expand Down
2 changes: 2 additions & 0 deletions backend/test_observer/controllers/environments/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ class ReportedIssueRequest(BaseModel):
environment_name: str
description: str
url: HttpUrl
is_confirmed: bool

@field_validator("url")
@classmethod
Expand All @@ -25,5 +26,6 @@ class ReportedIssueResponse(BaseModel):
environment_name: str
description: str
url: HttpUrl
is_confirmed: bool
created_at: datetime
updated_at: datetime
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ def create_reported_issue(request: ReportedIssueRequest, db: Session = Depends(g
environment_name=request.environment_name,
url=request.url,
description=request.description,
is_confirmed=request.is_confirmed,
)
db.add(issue)
db.commit()
Expand Down
1 change: 1 addition & 0 deletions backend/test_observer/data_access/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,7 @@ class EnvironmentIssue(Base):
environment_name: Mapped[str]
url: Mapped[str]
description: Mapped[str]
is_confirmed: Mapped[bool]

def __repr__(self) -> str:
return data_model_repr(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"environment_name": "template 1",
"url": "https://github.com/",
"description": "some description",
"is_confirmed": True,
}


Expand All @@ -17,7 +18,10 @@ def test_empty_get(test_client: TestClient):
assert response.json() == []


@pytest.mark.parametrize("field", ["url", "description", "environment_name"])
@pytest.mark.parametrize(
"field",
["url", "description", "environment_name", "is_confirmed"],
)
def test_post_requires_field(test_client: TestClient, field: str):
data = {k: v for k, v in valid_post_data.items() if k != field}
response = test_client.post(endpoint, json=data)
Expand Down Expand Up @@ -77,6 +81,19 @@ def test_update_description(test_client: TestClient):
_assert_reported_issue(response.json()[0], issue)


def test_mark_unconfirmed(test_client: TestClient):
response = test_client.post(endpoint, json=valid_post_data)
issue = response.json()
issue["is_confirmed"] = False
response = test_client.put(f"{endpoint}/{issue['id']}", json=issue)

assert response.status_code == 200
_assert_reported_issue(response.json(), issue)

response = test_client.get(endpoint)
_assert_reported_issue(response.json()[0], issue)


def test_delete_issue(test_client: TestClient):
response = test_client.post(endpoint, json=valid_post_data)
issue_id = response.json()["id"]
Expand Down

0 comments on commit 9b19cf2

Please sign in to comment.