Skip to content

Commit 134e785

Browse files
authored
Merge pull request #18 from getmarkus/cm-branch-16
refactor: API endpoints to includeing in tests
2 parents 284d7b5 + 60b3dd7 commit 134e785

File tree

4 files changed

+9
-9
lines changed

4 files changed

+9
-9
lines changed

app/core/usecases/analyze_issue.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ def analyze(self) -> Issue:
2525
issue = self.repo.get_by_id(self.issue_number)
2626
logger.info(f"issue: {issue}")
2727
if issue.issue_number == 0:
28+
logger.info(f"not found issue: {self.issue_number}")
2829
raise NotFoundException(
2930
message="Issue not found",
3031
detail=f"Issue with number {self.issue_number} does not exist",

app/tests/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def session_fixture():
1818

1919

2020
@pytest.fixture(name="client")
21-
def client_fixture(session: Session):
21+
def client_fixture():
2222

2323
with TestClient(app) as client:
2424
yield client

app/tests/test_issues.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ def test_analyze_issue_client(client: TestClient, session: Session):
3535
repository.add(test_issue)
3636
repository.commit()
3737

38-
response = client.post("/issues/1/analyze")
39-
# assert response.status_code == 200
40-
assert response.json() == {"version": 1, "issue_number": 1}
38+
response = client.post("/v1/issues/1/analyze")
39+
assert response.status_code == 200
40+
assert response.json() == {"issue_state": "OPEN", "version": 0, "issue_number": 1}
4141

4242

4343
def test_analyze_issue_not_found(client: TestClient, session: Session):
@@ -53,15 +53,14 @@ def test_analyze_issue_not_found(client: TestClient, session: Session):
5353
use_case.analyze()
5454
assert exc_info.value.message == "Issue not found"
5555

56-
response = client.post("/issues/1/analyze")
56+
response = client.post("/v1/issues/1/analyze")
5757
assert response.status_code == 404
58-
assert response.json() == {"version": 1, "issue_number": 1}
5958

6059

6160
def test_analyze_issue_invalid_number(client: TestClient, session: Session):
6261
"""Test analyzing an issue with an invalid issue number."""
6362

64-
response = client.post("/issues/abc/analyze")
63+
response = client.post("/v1/issues/abc/analyze")
6564
assert response.status_code == 422
6665
# Validate error response structure
6766
error_detail = response.json()["detail"]
@@ -72,6 +71,6 @@ def test_analyze_issue_invalid_number(client: TestClient, session: Session):
7271

7372
def test_analyze_issue_unauthorized(client: TestClient):
7473
# Test case 3: Unauthorized access
75-
response = client.post("/issues/456/analyze")
74+
response = client.post("/v1/issues/456/analyze")
7675
assert response.status_code == 401
77-
assert response.js_on() == {"detail": "Unauthorized"}
76+
assert response.json() == {"detail": "Unauthorized"}

rapidapi/api_tests.paw

946 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)