From 54b3eab68648e19b6a44996aee08182d8edd6655 Mon Sep 17 00:00:00 2001 From: Luis Valle Date: Mon, 26 Aug 2024 14:40:32 -0600 Subject: [PATCH] Removing mock http library --- .../plugins/modules/test_zendesk_ticket.py | 43 +------------------ 1 file changed, 1 insertion(+), 42 deletions(-) diff --git a/tests/unit/plugins/modules/test_zendesk_ticket.py b/tests/unit/plugins/modules/test_zendesk_ticket.py index 853b148ebf..827c308f2b 100644 --- a/tests/unit/plugins/modules/test_zendesk_ticket.py +++ b/tests/unit/plugins/modules/test_zendesk_ticket.py @@ -8,30 +8,7 @@ from __future__ import (absolute_import, division, print_function) __metaclass__ = type from ansible_collections.community.general.plugins.modules import zendesk_ticket -from ansible_collections.community.general.tests.unit.plugins.modules.utils import ModuleTestCase, set_module_args, AnsibleExitJson, AnsibleFailJson -from httmock import HTTMock, response, urlmatch - - -@urlmatch(netloc=r'(.)*zendesk\.com(.)*') -def zendesk_api_mock(url, request): - ticket_data = { - "id": 35436, - "subject": "Test Ticket", - "status": "new", - "priority": "high", - "description": "This is a test ticket body", - "created_at": "2023-05-22T10:00:00Z", - "updated_at": "2023-05-22T10:00:00Z", - "requester_id": 20978392, - "submitter_id": 76872, - "assignee_id": 235323, - "organization_id": 509974, - "group_id": 98738, - "tags": ["test", "mock"], - "url": "https://example.zendesk.com/api/v2/tickets/35436.json" - } - headers = {'content-type': 'application/json'} - return response(201, ticket_data, headers, None, 5, request) +from ansible_collections.community.general.tests.unit.plugins.modules.utils import ModuleTestCase, set_module_args, AnsibleFailJson class TestZendeskTicket(ModuleTestCase): @@ -90,21 +67,3 @@ class TestZendeskTicket(ModuleTestCase): result = exc_info.exception.args[0] self.assertTrue(result['failed']) self.assertEqual(result['msg'], 'Ticket ID 35436 does not exist.') - - def test_create_ticket_with_mock(self): - set_module_args({ - 'url': 'https://your_company.zendesk.com', - 'username': 'user', - 'token': 'test_token', - 'status': 'new', - 'subject': 'Test Ticket', - 'body': 'This is a test ticket body', - 'priority': 'high' - }) - - with HTTMock(zendesk_api_mock): - with self.assertRaises(AnsibleExitJson) as result: - self.module.main() - - self.assertTrue(result.exception.args[0]['changed']) - self.assertEqual(result.exception.args[0]['ticket']['id'], 35436)