Extract odoo helpdesk ticket creation
All checks were successful
Tests / test (push) Successful in 28s
All checks were successful
Tests / test (push) Successful in 28s
This commit is contained in:
parent
61f1065bc6
commit
e4c64c4a17
5 changed files with 70 additions and 46 deletions
|
|
@ -614,7 +614,8 @@ def test_delete_creates_ticket_with_admin_links(
|
|||
test_service_offering,
|
||||
instance_id,
|
||||
):
|
||||
mock_api_client = mocker.patch("servala.api.views.CLIENT")
|
||||
# Mock the create_helpdesk_ticket function
|
||||
mock_create_ticket = mocker.patch("servala.api.views.create_helpdesk_ticket")
|
||||
|
||||
response = osb_client.delete(
|
||||
f"/api/osb/v2/service_instances/{instance_id}"
|
||||
|
|
@ -623,13 +624,15 @@ def test_delete_creates_ticket_with_admin_links(
|
|||
|
||||
assert response.status_code == 200
|
||||
|
||||
ticket_call = mock_api_client.execute.call_args_list[-1]
|
||||
ticket_data = ticket_call[0][2][0]
|
||||
# Verify the ticket was created with admin URL
|
||||
mock_create_ticket.assert_called_once()
|
||||
call_kwargs = mock_create_ticket.call_args[1]
|
||||
|
||||
assert "admin/core/serviceoffering" in ticket_data["description"]
|
||||
assert f"/{test_service_offering.pk}/" in ticket_data["description"]
|
||||
# Check that the description contains an admin URL
|
||||
assert "admin/core/serviceoffering" in call_kwargs["description"]
|
||||
assert f"/{test_service_offering.pk}/" in call_kwargs["description"]
|
||||
assert (
|
||||
ticket_data["name"]
|
||||
call_kwargs["title"]
|
||||
== f"Exoscale OSB Offboard - {test_service.name} - {instance_id}"
|
||||
)
|
||||
|
||||
|
|
@ -644,7 +647,9 @@ def test_patch_creates_ticket_with_user_admin_links(
|
|||
instance_id,
|
||||
org_owner,
|
||||
):
|
||||
mock_api_client = mocker.patch("servala.api.views.CLIENT")
|
||||
# Mock the create_helpdesk_ticket function
|
||||
mock_create_ticket = mocker.patch("servala.api.views.create_helpdesk_ticket")
|
||||
|
||||
payload = {
|
||||
"service_id": test_service.osb_service_id,
|
||||
"plan_id": test_service_offering.osb_plan_id,
|
||||
|
|
@ -666,13 +671,17 @@ def test_patch_creates_ticket_with_user_admin_links(
|
|||
)
|
||||
|
||||
assert response.status_code == 200
|
||||
ticket_call = mock_api_client.execute.call_args_list[-1]
|
||||
ticket_data = ticket_call[0][2][0]
|
||||
assert "admin/core/serviceoffering" in ticket_data["description"]
|
||||
assert "admin/core/user" in ticket_data["description"]
|
||||
assert f"/{org_owner.pk}/" in ticket_data["description"]
|
||||
|
||||
# Verify the ticket was created with admin URLs
|
||||
mock_create_ticket.assert_called_once()
|
||||
call_kwargs = mock_create_ticket.call_args[1]
|
||||
|
||||
# Check that the description contains admin URLs
|
||||
assert "admin/core/serviceoffering" in call_kwargs["description"]
|
||||
assert "admin/core/user" in call_kwargs["description"]
|
||||
assert f"/{org_owner.pk}/" in call_kwargs["description"]
|
||||
assert (
|
||||
ticket_data["name"]
|
||||
call_kwargs["title"]
|
||||
== f"Exoscale OSB Suspend - {test_service.name} - {instance_id}"
|
||||
)
|
||||
|
||||
|
|
@ -686,7 +695,9 @@ def test_ticket_includes_organization_and_instance_when_found(
|
|||
test_service_offering,
|
||||
organization,
|
||||
):
|
||||
mock_api_client = mocker.patch("servala.api.views.CLIENT")
|
||||
# Mock the create_helpdesk_ticket function
|
||||
mock_create_ticket = mocker.patch("servala.api.views.create_helpdesk_ticket")
|
||||
|
||||
service_definition = ServiceDefinition.objects.create(
|
||||
name="Test Definition",
|
||||
service=test_service,
|
||||
|
|
@ -719,11 +730,17 @@ def test_ticket_includes_organization_and_instance_when_found(
|
|||
)
|
||||
|
||||
assert response.status_code == 200
|
||||
ticket_call = mock_api_client.execute.call_args_list[-1]
|
||||
ticket_data = ticket_call[0][2][0]
|
||||
assert f"Organization: {organization.name}" in ticket_data["description"]
|
||||
assert "admin/core/organization" in ticket_data["description"]
|
||||
assert f"/{organization.pk}/" in ticket_data["description"]
|
||||
assert f"Instance: {service_instance.name}" in ticket_data["description"]
|
||||
assert "admin/core/serviceinstance" in ticket_data["description"]
|
||||
assert f"/{service_instance.pk}/" in ticket_data["description"]
|
||||
|
||||
# Verify the ticket was created with all admin URLs
|
||||
mock_create_ticket.assert_called_once()
|
||||
call_kwargs = mock_create_ticket.call_args[1]
|
||||
|
||||
# Check organization is included
|
||||
assert f"Organization: {organization.name}" in call_kwargs["description"]
|
||||
assert "admin/core/organization" in call_kwargs["description"]
|
||||
assert f"/{organization.pk}/" in call_kwargs["description"]
|
||||
|
||||
# Check instance is included
|
||||
assert f"Instance: {service_instance.name}" in call_kwargs["description"]
|
||||
assert "admin/core/serviceinstance" in call_kwargs["description"]
|
||||
assert f"/{service_instance.pk}/" in call_kwargs["description"]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue