From cc95e12d2019187b90017bb6d0a41c05d7f7c0ba Mon Sep 17 00:00:00 2001 From: Greg Gauthier Date: Sat, 20 Jul 2024 12:40:25 +0100 Subject: [PATCH] add additional example tests --- .../test_datadelivery_acms_redaction_get.json | 1 + ..._datadelivery_client_applications_get.json | 42 +++++++++++++++++ tests/test_datadelivery.py | 45 +++++++++++++++++-- 3 files changed, 84 insertions(+), 4 deletions(-) create mode 100644 tests/expected_responses/test_datadelivery_acms_redaction_get.json create mode 100644 tests/expected_responses/test_datadelivery_client_applications_get.json diff --git a/tests/expected_responses/test_datadelivery_acms_redaction_get.json b/tests/expected_responses/test_datadelivery_acms_redaction_get.json new file mode 100644 index 0000000..0637a08 --- /dev/null +++ b/tests/expected_responses/test_datadelivery_acms_redaction_get.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/tests/expected_responses/test_datadelivery_client_applications_get.json b/tests/expected_responses/test_datadelivery_client_applications_get.json new file mode 100644 index 0000000..34cf59d --- /dev/null +++ b/tests/expected_responses/test_datadelivery_client_applications_get.json @@ -0,0 +1,42 @@ +[ + { + "ClientId" : "e72cdfde-957a-4f65-9f5e-c7b18e95d8dc", + "ClientSecret" : "f4ca195c-989c-48e6-a002-b1fb7b3c03fd", + "IsActive" : 1, + "Name" : "testcase", + "date_of_generation" : "2024-04-25 04:48:47", + "id" : 1, + "last_connection" : null, + "organization_id" : 16 + }, + { + "ClientId" : "b0dd74c2-9f39-45fc-a52e-b1130ffddbb5", + "ClientSecret" : "71b2ab0e-d3fa-40e2-a40e-2088ae716a46", + "IsActive" : 1, + "Name" : "Test", + "date_of_generation" : "2024-05-20 07:22:31", + "id" : 2, + "last_connection" : null, + "organization_id" : 1 + }, + { + "ClientId" : "be1a0686-fed2-4d79-a04c-c473c6c3e22e", + "ClientSecret" : "ddfdaee7-1fe5-4f62-964c-cb2b8e8397e1", + "IsActive" : 1, + "Name" : "Test3", + "date_of_generation" : "2024-05-20 10:58:35", + "id" : 3, + "last_connection" : null, + "organization_id" : 1 + }, + { + "ClientId" : "37f7afc6-91a1-4c2d-9696-0e8db6fc1bc6", + "ClientSecret" : "40106ff7-7feb-4869-b4c9-eeed5dee2f36", + "IsActive" : 1, + "Name" : "test4", + "date_of_generation" : "2024-05-20 11:14:16", + "id" : 4, + "last_connection" : null, + "organization_id" : 1 + } +] \ No newline at end of file diff --git a/tests/test_datadelivery.py b/tests/test_datadelivery.py index 818281b..4497168 100644 --- a/tests/test_datadelivery.py +++ b/tests/test_datadelivery.py @@ -11,7 +11,7 @@ CFG = get_cfg(ENV) @pytest.fixture -def api_call(): +def role_get_call(): token = get_legacy_token(ENV) api_call = { "token": token, @@ -23,8 +23,45 @@ def api_call(): return api_call -def test_datadelivery_role_get(request, api_call): - expected_response = get_expected_response(request.node.name) - actual_response = api_client(api_call) +@pytest.fixture +def acms_redaction_get_call(): + token = get_legacy_token(ENV) + api_call = { + "token": token, + "method": "GET", + "url": CFG["api_url"] + '/data-delivery/acmsredaction', + "headers": {'Content-Type': 'application/json'}, + "body": {"redaction_id": 1} + } + return api_call + +@pytest.fixture +def client_applications_get_call(): + token = get_legacy_token(ENV) + api_call = { + "token": token, + "method": "GET", + "url": CFG["api_url"] + '/data-delivery/client-applications', + "headers": {'Content-Type': 'application/json'}, + "body": {} + } + return api_call + + +def test_datadelivery_role_get(request, role_get_call): + expected_response = get_expected_response(request.node.name) + actual_response = api_client(role_get_call) + assert json.dumps(actual_response, indent=4) == json.dumps(expected_response, indent=4) + + +def test_datadelivery_acms_redaction_get(request, acms_redaction_get_call): + expected_response = get_expected_response(request.node.name) + actual_response = api_client(acms_redaction_get_call) + assert json.dumps(actual_response, indent=4) == json.dumps(expected_response, indent=4) + + +def test_datadelivery_client_applications_get(request, client_applications_get_call): + expected_response = get_expected_response(request.node.name) + actual_response = api_client(client_applications_get_call) assert json.dumps(actual_response, indent=4) == json.dumps(expected_response, indent=4)