feat: add reusable solution library
This commit is contained in:
41
backend/apps/solutions/tests/test_solution_api.py
Normal file
41
backend/apps/solutions/tests/test_solution_api.py
Normal file
@@ -0,0 +1,41 @@
|
||||
from apps.tickets.models import Ticket
|
||||
|
||||
|
||||
def test_create_and_list_solution(client, db):
|
||||
response = client.post(
|
||||
"/api/solutions",
|
||||
data={
|
||||
"title": "Restart callback worker",
|
||||
"problem_signature": "HTTP 500 from callback",
|
||||
"root_cause": "Worker connection pool stale",
|
||||
"solution": "Restart callback worker and verify queue depth.",
|
||||
"status": "published",
|
||||
},
|
||||
content_type="application/json",
|
||||
)
|
||||
|
||||
assert response.status_code == 200
|
||||
solution_id = response.json()["id"]
|
||||
|
||||
response = client.get("/api/solutions")
|
||||
assert response.status_code == 200
|
||||
assert response.json()[0]["id"] == solution_id
|
||||
|
||||
|
||||
def test_link_solution_to_ticket_increments_usage(client, db):
|
||||
ticket = Ticket.objects.create(ticket_no="TK202606300020", title="A", description="A")
|
||||
solution = client.post(
|
||||
"/api/solutions",
|
||||
data={"title": "S", "problem_signature": "P", "root_cause": "R", "solution": "Do S"},
|
||||
content_type="application/json",
|
||||
).json()
|
||||
|
||||
response = client.post(
|
||||
f"/api/solutions/{solution['id']}/link-ticket",
|
||||
data={"ticket_id": ticket.id, "link_type": "adopted"},
|
||||
content_type="application/json",
|
||||
)
|
||||
|
||||
assert response.status_code == 200
|
||||
assert response.json()["link_type"] == "adopted"
|
||||
assert response.json()["solution_usage_count"] == 1
|
||||
Reference in New Issue
Block a user