voip announcement

This commit is contained in:
javad committed 2026-09-28 19:37:19 +03:30
1 parent 38b1cf06df
commit c7993aae44
18 files changed
+679 -151

No files matched your search

+32
View File
@@ -132,3 +132,35 @@ def test_voip_error_is_minimal(client, voip_data):
content_type="application/json",
)
assert response.status_code == 403
@pytest.mark.django_db
@pytest.mark.parametrize("provider_error", [requests.Timeout("timed out"), requests.HTTPError("503 unavailable")])
def test_voip_provider_failure_does_not_raise_into_staff_page(client, voip_data, provider_error):
agent, customer, _ = voip_data
client.force_login(agent)
with patch("apps.integrations.voip.requests.post", side_effect=provider_error) as post:
response = client.post(
reverse("staff_tickets:contact_call", args=[customer.public_id]),
data=json.dumps({"method": "mobile"}),
content_type="application/json",
)
assert response.status_code == 502
assert response.json() == {"success": False, "message": "برقراری تماس ناموفق بود."}
assert post.call_args.kwargs["timeout"] > 0
@pytest.mark.django_db
def test_voip_invalid_provider_response_is_reported_as_failure(client, voip_data):
agent, customer, _ = voip_data
client.force_login(agent)
provider_response = Mock(content=b"[]")
provider_response.json.return_value = []
with patch("apps.integrations.voip.requests.post", return_value=provider_response):
response = client.post(
reverse("staff_tickets:contact_call", args=[customer.public_id]),
data=json.dumps({"method": "mobile"}),
content_type="application/json",
)
assert response.status_code == 502
assert response.json() == {"success": False, "message": "برقراری تماس ناموفق بود."}