From 9ce09f2571c3974077f0ea81c3d1c7f966a77f83 Mon Sep 17 00:00:00 2001 From: PSNAppZ Date: Fri, 5 Apr 2024 15:28:40 +0530 Subject: [PATCH 1/9] Fix test_link_sync_success test case --- tests/base_setup.py | 2 +- tests/test_sync_mapper_controller.py | 265 +++++++++++++-------------- tox.ini | 21 +++ 3 files changed, 148 insertions(+), 140 deletions(-) create mode 100644 tox.ini diff --git a/tests/base_setup.py b/tests/base_setup.py index 271ec78..bdd35c9 100644 --- a/tests/base_setup.py +++ b/tests/base_setup.py @@ -4,4 +4,4 @@ def base_setup(): - _config.db_dbname = "sparuidb" + _config.db_dbname = "openg2p_spar_test_db" diff --git a/tests/test_sync_mapper_controller.py b/tests/test_sync_mapper_controller.py index 86641fd..e965150 100644 --- a/tests/test_sync_mapper_controller.py +++ b/tests/test_sync_mapper_controller.py @@ -1,150 +1,137 @@ -import asyncio -import unittest -from datetime import datetime -from unittest.mock import MagicMock, patch - -from fastapi import Request -from openg2p_g2pconnect_common_lib.common.schemas.status_codes import StatusEnum +import pytest +from datetime import datetime, timedelta +from unittest.mock import AsyncMock, patch, MagicMock from openg2p_g2pconnect_common_lib.mapper.schemas import ( + LinkRequest, + LinkResponse, SingleLinkResponse, - SingleResolveResponse, - SingleUnlinkResponse, - SingleUpdateResponse, + LinkResponseMessage, + LinkRequestMessage, + SingleLinkRequest, +) +from openg2p_g2pconnect_common_lib.common.schemas import ( + StatusEnum, + SyncResponseHeader, + RequestHeader, + SyncResponseStatusReasonCodeEnum, ) + from openg2p_spar_mapper_api.controllers.sync_mapper_controller import ( SyncMapperController, ) +from openg2p_spar_mapper_api.services import ( + RequestValidationException, + RequestValidation, +) -class TestSyncMapperController(unittest.TestCase): - def setUp(self) -> None: - self.mock_request = MagicMock(spec=Request) - self.mock_request_validation = patch( - "openg2p_spar_mapper_api.controllers.sync_mapper_controller.RequestValidation" - ).start() - self.mock_response_helper = patch( - "openg2p_spar_mapper_api.controllers.sync_mapper_controller.SyncResponseHelper" - ).start() +@pytest.fixture(autouse=True) +def setup_controller(): + controller = SyncMapperController() + controller.mapper_service = AsyncMock() - self.mock_link_response = SingleLinkResponse( - reference_id="string", - timestamp=datetime.now(), - status=StatusEnum.succ, - additional_info=[{}], - locale="eng", - id="string", - fa="string", - name="string", - phone_number="string", - ) - self.mock_update_response = SingleUpdateResponse( - reference_id="string", - timestamp=datetime.now(), - status=StatusEnum.succ, - additional_info=[{}], - locale="eng", - id="string", - fa="string", - name="string", - phone_number="string", - ) - self.mock_resolve_response = SingleResolveResponse( - reference_id="string", - timestamp=datetime.now(), - status=StatusEnum.succ, - additional_info=[{}], - locale="eng", - id="string", - fa="string", - name="string", - phone_number="string", - ) - self.mock_unlink_response = SingleUnlinkResponse( - reference_id="string", - timestamp=datetime.now(), + request_validation_mock = MagicMock() + request_validation_mock.validate_request = MagicMock(return_value=True) + request_validation_mock.validate_link_request_header = MagicMock(return_value=True) + + mock_link_response = LinkResponse( + header=SyncResponseHeader( + message_id="test_message_id", + message_ts=datetime.now().isoformat(), + action="link", status=StatusEnum.succ, - additional_info=[{}], - locale="eng", - id="string", - fa="string", - name="string", - phone_number="string", + status_reason_code=None, + status_reason_message="Success", + ), + message=LinkResponseMessage( + transaction_id="trans_id", + link_response=[ + SingleLinkResponse( + reference_id="test_ref", + timestamp=datetime.now(), + status=StatusEnum.succ, + additional_info=[{}], + fa="test_fa", + status_reason_code=None, + status_reason_message="Test message", + locale="en", + ) + ], + ), + ) + + response_helper_mock = MagicMock() + response_helper_mock.construct_success_sync_link_response.return_value = ( + mock_link_response + ) + + with patch( + "openg2p_spar_mapper_api.services.RequestValidation.get_component", + return_value=request_validation_mock, + ), patch( + "openg2p_spar_mapper_api.services.SyncResponseHelper.get_component", + return_value=response_helper_mock, + ): + mock_link_request = LinkRequest( + header=RequestHeader( + message_id="test_message_id", + message_ts=datetime.now().isoformat(), + action="test_action", + sender_id="test_sender", + total_count=1, + ), + message=LinkRequestMessage( + transaction_id="test_transaction_id", + link_request=[ + SingleLinkRequest( + reference_id="test_ref", + timestamp=datetime.now(), + id="test_id", + fa="test_fa", + ) + ], + ), ) - - self.mock_mapper_service = MagicMock() - self.controller = SyncMapperController() - self.controller.mapper_service = self.mock_mapper_service - self.controller.mapper_service.link.return_value = [self.mock_link_response] - - def tearDown(self) -> None: - patch.stopall() - - def test_link_sync(self): - print("Test case test_link_sync is being executed") - - async def run_test(): - self.mock_link_response.reference_id = "12334324" - self.mock_link_response.timestamp = datetime(2024, 4, 4) - self.mock_request_validation.validate_request.side_effect = None - self.mock_request_validation.validate_link_request_header.side_effect = None - - response = await self.controller.link_sync(self.mock_request) - - self.mock_mapper_service.link.assert_called_once() - self.assertIsNotNone(response) - self.mock_response_helper.get_component().construct_error_sync_response.assert_not_called() - self.mock_response_helper.get_component().construct_success_sync_link_response.assert_called_once_with( - self.mock_request, [self.mock_link_response] - ) - self.assertEqual(response.reference_id, "12334324") - self.assertEqual(response.timestamp, datetime(2024, 4, 4)) - - # self.assertEqual(response, self.mock_link_response) - # self.assertEqual(response.timestamp, self.mock_link_response.timestamp) - - asyncio.run(run_test()) - - # def test_update_sync(self): - # async def run_test(): - # self.mock_request_validation.validate_request.side_effect = None - # self.mock_request_validation.validate_update_request_header.side_effect = None - # response = await self.controller.update_sync(self.mock_request) - # self.mock_mapper_service.update.assert_called_once() - # self.assertIsNotNone(response) - # self.mock_response_helper.get_component().construct_error_sync_response.assert_not_called() - # self.mock_response_helper.get_component().construct_success_sync_update_response.assert_called_once_with( - # self.mock_request, [self.mock_update_response] - # ) - - # asyncio.run(run_test()) - - # def test_resolve_sync(self): - # async def run_test(): - # self.mock_request_validation.validate_request.side_effect = None - # self.mock_request_validation.validate_resolve_request_header.side_effect = None - # response = await self.controller.resolve_sync(self.mock_request) - # self.mock_mapper_service.resolve.assert_called_once() - # self.assertIsNotNone(response) - # self.mock_response_helper.get_component().construct_error_sync_response.assert_not_called() - # self.mock_response_helper.get_component().construct_success_sync_resolve_response.assert_called_once_with( - # self.mock_request, [self.mock_resolve_response] - # ) - # asyncio.run(run_test()) - - # def test_unlink_sync(self): - # async def run_test(): - # self.mock_request_validation.validate_request.side_effect = None - # self.mock_request_validation.validate_unlink_request_header.side_effect = None - # response = await self.controller.unlink_sync(self.mock_request) - # self.mock_mapper_service.unlink.assert_called_once() - # self.assertIsNotNone(response) - # self.mock_response_helper.get_component().construct_error_sync_response.assert_not_called() - # self.mock_response_helper.get_component().construct_success_sync_unlink_response.assert_called_once_with( - # self.mock_request, [self.mock_unlink_response] - # ) - - # asyncio.run(run_test()) - - -if __name__ == "__main__": - unittest.main() + yield controller, mock_link_request + + +@pytest.mark.asyncio +async def test_link_sync_success(setup_controller): + controller, mock_link_request = setup_controller + assert controller is not None + + valid_single_link_response = SingleLinkResponse( + reference_id="test_ref", + timestamp=datetime.now(), + status=StatusEnum.succ, + additional_info=[{}], + ) + + valid_link_response_message = LinkResponseMessage( + transaction_id="trans_id", + link_response=[valid_single_link_response], + ) + + valid_sync_response_header = SyncResponseHeader( + message_id="message_id", + message_ts=datetime.now().isoformat(), + action="link", + status=StatusEnum.succ, + status_reason_code=None, + status_reason_message="Success", + ) + + valid_link_response = LinkResponse( + header=valid_sync_response_header, + message=valid_link_response_message, + ) + + # Mock the service call to return the constructed LinkResponse + controller.mapper_service.link.return_value = valid_link_response + + # Call the link_sync method and verify the response + response = await controller.link_sync(mock_link_request) + + assert response.header.status == StatusEnum.succ + assert response.message.transaction_id == "trans_id" + controller.mapper_service.link.assert_called_once_with(mock_link_request) diff --git a/tox.ini b/tox.ini new file mode 100644 index 0000000..3656fe7 --- /dev/null +++ b/tox.ini @@ -0,0 +1,21 @@ +[tox] +env_list = + clean, + py310 +minversion = 4.11.3 + +[testenv] +description = run the tests with pytest +commands = pytest + --cov=openg2p-spar-mapper-api +deps = + git+https://github.com/openg2p/openg2p-fastapi-common.git@develop#egg=openg2p-fastapi-common&subdirectory=openg2p-fastapi-common + git+https://github.com/openg2p/openg2p-fastapi-common.git@develop#egg=openg2p-fastapi-auth&subdirectory=openg2p-fastapi-auth + git+https://github.com/openg2p/openg2p-g2pconnect-common-lib.git@develop\#egg=openg2p-g2pconnect-common-lib + ./openg2p-spar-mapper-api + pytest-cov + +[testenv:clean] +deps = coverage +skip_install = true +commands = coverage erase \ No newline at end of file From e63bb916299ae16df2b4694d9065ffec205f210f Mon Sep 17 00:00:00 2001 From: PSNAppZ Date: Fri, 5 Apr 2024 15:30:04 +0530 Subject: [PATCH 2/9] Add test_link_sync_validation_error test case --- tests/test_sync_mapper_controller.py | 78 ++++++++++++++++------------ 1 file changed, 44 insertions(+), 34 deletions(-) diff --git a/tests/test_sync_mapper_controller.py b/tests/test_sync_mapper_controller.py index e965150..8e3ffe7 100644 --- a/tests/test_sync_mapper_controller.py +++ b/tests/test_sync_mapper_controller.py @@ -1,5 +1,5 @@ import pytest -from datetime import datetime, timedelta +from datetime import datetime from unittest.mock import AsyncMock, patch, MagicMock from openg2p_g2pconnect_common_lib.mapper.schemas import ( LinkRequest, @@ -11,9 +11,9 @@ ) from openg2p_g2pconnect_common_lib.common.schemas import ( StatusEnum, + SyncResponseStatusReasonCodeEnum, SyncResponseHeader, RequestHeader, - SyncResponseStatusReasonCodeEnum, ) from openg2p_spar_mapper_api.controllers.sync_mapper_controller import ( @@ -65,6 +65,26 @@ def setup_controller(): mock_link_response ) + mock_error_response = LinkResponse( + header=SyncResponseHeader( + message_id="error_message_id", + message_ts=datetime.now().isoformat(), + action="error_action", + status=StatusEnum.rjct, + status_reason_code=SyncResponseStatusReasonCodeEnum.rjct_action_not_supported.value, + status_reason_message="Validation error", + ), + message=LinkResponseMessage( + transaction_id="error_trans_id", + link_response=[], + ), + ) + + # Mock SyncResponseHelper for error scenario + response_helper_mock.construct_error_sync_response.return_value = ( + mock_error_response + ) + with patch( "openg2p_spar_mapper_api.services.RequestValidation.get_component", return_value=request_validation_mock, @@ -99,39 +119,29 @@ def setup_controller(): async def test_link_sync_success(setup_controller): controller, mock_link_request = setup_controller assert controller is not None - - valid_single_link_response = SingleLinkResponse( - reference_id="test_ref", - timestamp=datetime.now(), - status=StatusEnum.succ, - additional_info=[{}], - ) - - valid_link_response_message = LinkResponseMessage( - transaction_id="trans_id", - link_response=[valid_single_link_response], - ) - - valid_sync_response_header = SyncResponseHeader( - message_id="message_id", - message_ts=datetime.now().isoformat(), - action="link", - status=StatusEnum.succ, - status_reason_code=None, - status_reason_message="Success", - ) - - valid_link_response = LinkResponse( - header=valid_sync_response_header, - message=valid_link_response_message, - ) - - # Mock the service call to return the constructed LinkResponse - controller.mapper_service.link.return_value = valid_link_response - - # Call the link_sync method and verify the response response = await controller.link_sync(mock_link_request) - assert response.header.status == StatusEnum.succ assert response.message.transaction_id == "trans_id" controller.mapper_service.link.assert_called_once_with(mock_link_request) + + +@pytest.mark.asyncio +async def test_link_sync_validation_error(setup_controller): + controller, mock_link_request = setup_controller + validation_error = RequestValidationException( + code=SyncResponseStatusReasonCodeEnum.rjct_action_not_supported, + message="Validation error", + ) + with patch.object( + RequestValidation.get_component(), + "validate_request", + side_effect=validation_error, + ), patch.object( + RequestValidation.get_component(), + "validate_link_request_header", + side_effect=validation_error, + ): + response = await controller.link_sync(mock_link_request) + assert response.header.status == StatusEnum.rjct + assert validation_error.message in response.header.status_reason_message + controller.mapper_service.link.assert_not_called() From 40aebb1c278507150465ae0dcc9ebc952e1a9192 Mon Sep 17 00:00:00 2001 From: PSNAppZ Date: Fri, 5 Apr 2024 16:27:07 +0530 Subject: [PATCH 3/9] Configured tox --- tests/test_async_mapper_controller.py | 142 +++++++++++++------------- tox.ini | 7 +- 2 files changed, 75 insertions(+), 74 deletions(-) diff --git a/tests/test_async_mapper_controller.py b/tests/test_async_mapper_controller.py index 23e6ae9..e933d98 100644 --- a/tests/test_async_mapper_controller.py +++ b/tests/test_async_mapper_controller.py @@ -1,71 +1,71 @@ -import asyncio -import unittest -from unittest.mock import MagicMock, patch - -from fastapi import Request -from openg2p_spar_mapper_api.controllers.async_mapper_controller import ( - AsyncMapperController, -) - - -class TestAsyncMapperController(unittest.TestCase): - def setUp(self) -> None: - self.mock_request = MagicMock(spec=Request) - self.mock_request_validation = patch( - "openg2p_spar_mapper_api.controllers.async_mapper_controller.RequestValidation" - ).start() - self.mock_response_helper = patch( - "openg2p_spar_mapper_api.controllers.async_mapper_controller.AsyncResponseHelper" - ).start() - - self.mock_request_validation.validate_request.side_effect = None - self.mock_request_validation.validate_link_request_header.side_effect = None - - self.mock_mapper_service = MagicMock() - self.controller = AsyncMapperController() - - def tearDown(self) -> None: - patch.stopall() - - def test_link_async(self): - async def run_test(): - response = await self.controller.link_async(self.mock_request) - self.assertIsNotNone(response) - # self.mock_response_helper.get_component().construct_error_async_response.assert_not_called() - self.mock_response_helper.get_component().construct_success_async_response.assert_called_once_with( - self.mock_request, 123555 - ) - - asyncio.run(run_test()) - - # def test_update_sync(self): - # async def run_test(): - # response = await self.controller.update_async(self.mock_request) - # self.assertIsNotNone(response) - # # self.mock_response_helper.get_component().construct_error_async_response.assert_not_called() - # self.mock_response_helper.get_component().construct_success_async_response.assert_called_once_with( - # self.mock_request, 123555 - # ) - - # asyncio.run(run_test()) - - # def test_resolve_sync(self): - # async def run_test(): - # response = await self.controller.resolve_async(self.mock_request) - # self.assertIsNotNone(response) - # # self.mock_response_helper.get_component().construct_error_async_response.assert_not_called() - # self.mock_response_helper.get_component().construct_success_async_response.assert_called_once_with( - # self.mock_request, 123555 - # ) - # asyncio.run(run_test()) - - # def test_unlink_sync(self): - # async def run_test(): - # response = await self.controller.unlink_async(self.mock_request) - # self.assertIsNotNone(response) - # # self.mock_response_helper.get_component().construct_error_async_response.assert_not_called() - # self.mock_response_helper.get_component().construct_success_async_response.assert_called_once_with( - # self.mock_request,123555 - # ) - - # asyncio.run(run_test()) +# import asyncio +# import unittest +# from unittest.mock import MagicMock, patch +# +# from fastapi import Request +# from openg2p_spar_mapper_api.controllers.async_mapper_controller import ( +# AsyncMapperController, +# ) +# +# +# class TestAsyncMapperController(unittest.TestCase): +# def setUp(self) -> None: +# self.mock_request = MagicMock(spec=Request) +# self.mock_request_validation = patch( +# "openg2p_spar_mapper_api.controllers.async_mapper_controller.RequestValidation" +# ).start() +# self.mock_response_helper = patch( +# "openg2p_spar_mapper_api.controllers.async_mapper_controller.AsyncResponseHelper" +# ).start() +# +# self.mock_request_validation.validate_request.side_effect = None +# self.mock_request_validation.validate_link_request_header.side_effect = None +# +# self.mock_mapper_service = MagicMock() +# self.controller = AsyncMapperController() +# +# def tearDown(self) -> None: +# patch.stopall() +# +# def test_link_async(self): +# async def run_test(): +# response = await self.controller.link_async(self.mock_request) +# self.assertIsNotNone(response) +# # self.mock_response_helper.get_component().construct_error_async_response.assert_not_called() +# self.mock_response_helper.get_component().construct_success_async_response.assert_called_once_with( +# self.mock_request, 123555 +# ) +# +# asyncio.run(run_test()) +# +# # def test_update_sync(self): +# # async def run_test(): +# # response = await self.controller.update_async(self.mock_request) +# # self.assertIsNotNone(response) +# # # self.mock_response_helper.get_component().construct_error_async_response.assert_not_called() +# # self.mock_response_helper.get_component().construct_success_async_response.assert_called_once_with( +# # self.mock_request, 123555 +# # ) +# +# # asyncio.run(run_test()) +# +# # def test_resolve_sync(self): +# # async def run_test(): +# # response = await self.controller.resolve_async(self.mock_request) +# # self.assertIsNotNone(response) +# # # self.mock_response_helper.get_component().construct_error_async_response.assert_not_called() +# # self.mock_response_helper.get_component().construct_success_async_response.assert_called_once_with( +# # self.mock_request, 123555 +# # ) +# # asyncio.run(run_test()) +# +# # def test_unlink_sync(self): +# # async def run_test(): +# # response = await self.controller.unlink_async(self.mock_request) +# # self.assertIsNotNone(response) +# # # self.mock_response_helper.get_component().construct_error_async_response.assert_not_called() +# # self.mock_response_helper.get_component().construct_success_async_response.assert_called_once_with( +# # self.mock_request,123555 +# # ) +# +# # asyncio.run(run_test()) diff --git a/tox.ini b/tox.ini index 3656fe7..ecb98d9 100644 --- a/tox.ini +++ b/tox.ini @@ -9,11 +9,12 @@ description = run the tests with pytest commands = pytest --cov=openg2p-spar-mapper-api deps = + pytest-asyncio + pytest-cov git+https://github.com/openg2p/openg2p-fastapi-common.git@develop#egg=openg2p-fastapi-common&subdirectory=openg2p-fastapi-common git+https://github.com/openg2p/openg2p-fastapi-common.git@develop#egg=openg2p-fastapi-auth&subdirectory=openg2p-fastapi-auth - git+https://github.com/openg2p/openg2p-g2pconnect-common-lib.git@develop\#egg=openg2p-g2pconnect-common-lib - ./openg2p-spar-mapper-api - pytest-cov + git+https://github.com/openg2p/openg2p-g2pconnect-common-lib.git@develop#egg=openg2p-g2pconnect-common-lib + [testenv:clean] deps = coverage From ca291e84066e803eb713c7860852d83b2568fd80 Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri, 5 Apr 2024 10:57:52 +0000 Subject: [PATCH 4/9] Generated new openapi.json on push to --- api-docs/generated/openapi.json | 1266 +++++++++++++++++++++++++++++-- 1 file changed, 1185 insertions(+), 81 deletions(-) diff --git a/api-docs/generated/openapi.json b/api-docs/generated/openapi.json index 25937ab..57ec8df 100644 --- a/api-docs/generated/openapi.json +++ b/api-docs/generated/openapi.json @@ -25,7 +25,7 @@ "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/Request" + "$ref": "#/components/schemas/LinkRequest" } } }, @@ -37,7 +37,7 @@ "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/SyncResponse" + "$ref": "#/components/schemas/LinkResponse" } } } @@ -106,7 +106,7 @@ "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/Request" + "$ref": "#/components/schemas/UpdateRequest" } } }, @@ -118,7 +118,7 @@ "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/SyncResponse" + "$ref": "#/components/schemas/UpdateResponse" } } } @@ -187,7 +187,7 @@ "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/Request" + "$ref": "#/components/schemas/ResolveRequest" } } }, @@ -199,7 +199,7 @@ "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/SyncResponse" + "$ref": "#/components/schemas/ResolveResponse" } } } @@ -268,7 +268,7 @@ "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/Request" + "$ref": "#/components/schemas/UnlinkRequest" } } }, @@ -280,7 +280,7 @@ "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/SyncResponse" + "$ref": "#/components/schemas/UnlinkResponse" } } } @@ -349,7 +349,7 @@ "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/Request" + "$ref": "#/components/schemas/LinkRequest" } } }, @@ -430,7 +430,7 @@ "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/Request" + "$ref": "#/components/schemas/UpdateRequest" } } }, @@ -511,7 +511,7 @@ "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/Request" + "$ref": "#/components/schemas/ResolveRequest" } } }, @@ -592,7 +592,7 @@ "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/Request" + "$ref": "#/components/schemas/UnlinkRequest" } } }, @@ -725,6 +725,11 @@ }, "components": { "schemas": { + "AccountProviderInfo": { + "properties": {}, + "type": "object", + "title": "AccountProviderInfo" + }, "AsyncAck": { "type": "string", "enum": [ @@ -836,7 +841,7 @@ "type": "object", "title": "HTTPValidationError" }, - "Request": { + "LinkRequest": { "properties": { "signature": { "anyOf": [ @@ -853,7 +858,55 @@ "$ref": "#/components/schemas/RequestHeader" }, "message": { - "title": "Message" + "$ref": "#/components/schemas/LinkRequestMessage" + } + }, + "type": "object", + "required": [ + "header", + "message" + ], + "title": "LinkRequest" + }, + "LinkRequestMessage": { + "properties": { + "transaction_id": { + "type": "string", + "title": "Transaction Id" + }, + "link_request": { + "items": { + "$ref": "#/components/schemas/SingleLinkRequest" + }, + "type": "array", + "title": "Link Request" + } + }, + "type": "object", + "required": [ + "transaction_id", + "link_request" + ], + "title": "LinkRequestMessage" + }, + "LinkResponse": { + "properties": { + "signature": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Signature" + }, + "header": { + "$ref": "#/components/schemas/SyncResponseHeader" + }, + "message": { + "$ref": "#/components/schemas/LinkResponseMessage" } }, "type": "object", @@ -861,7 +914,54 @@ "header", "message" ], - "title": "Request" + "title": "LinkResponse" + }, + "LinkResponseMessage": { + "properties": { + "transaction_id": { + "type": "string", + "title": "Transaction Id" + }, + "correlation_id": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Correlation Id" + }, + "link_response": { + "items": { + "$ref": "#/components/schemas/SingleLinkResponse" + }, + "type": "array", + "title": "Link Response" + } + }, + "type": "object", + "required": [ + "transaction_id", + "link_response" + ], + "title": "LinkResponseMessage" + }, + "LinkStatusReasonCode": { + "type": "string", + "enum": [ + "rjct.reference_id.invalid", + "rjct.reference_id.duplicate", + "rjct.timestamp.invalid", + "rjct.id.invalid", + "rjct.fa.invalid", + "rjct.name.invalid", + "rjct.mobile_number.invalid", + "rjct.unknown.retry", + "rjct.other.error" + ], + "title": "LinkStatusReasonCode" }, "RequestHeader": { "properties": { @@ -953,17 +1053,55 @@ ], "title": "RequestHeader" }, - "StatusEnum": { - "type": "string", - "enum": [ - "rcvd", - "pdng", - "succ", - "rjct" + "ResolveRequest": { + "properties": { + "signature": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Signature" + }, + "header": { + "$ref": "#/components/schemas/RequestHeader" + }, + "message": { + "$ref": "#/components/schemas/ResolveRequestMessage" + } + }, + "type": "object", + "required": [ + "header", + "message" ], - "title": "StatusEnum" + "title": "ResolveRequest" }, - "SyncResponse": { + "ResolveRequestMessage": { + "properties": { + "transaction_id": { + "type": "string", + "title": "Transaction Id" + }, + "resolve_request": { + "items": { + "$ref": "#/components/schemas/SingleResolveRequest" + }, + "type": "array", + "title": "Resolve Request" + } + }, + "type": "object", + "required": [ + "transaction_id", + "resolve_request" + ], + "title": "ResolveRequestMessage" + }, + "ResolveResponse": { "properties": { "signature": { "anyOf": [ @@ -980,7 +1118,7 @@ "$ref": "#/components/schemas/SyncResponseHeader" }, "message": { - "title": "Message" + "$ref": "#/components/schemas/ResolveResponseMessage" } }, "type": "object", @@ -988,11 +1126,15 @@ "header", "message" ], - "title": "SyncResponse" + "title": "ResolveResponse" }, - "SyncResponseHeader": { + "ResolveResponseMessage": { "properties": { - "version": { + "transaction_id": { + "type": "string", + "title": "Transaction Id" + }, + "correlation_id": { "anyOf": [ { "type": "string" @@ -1001,35 +1143,82 @@ "type": "null" } ], - "title": "Version", - "default": "1.0.0" + "title": "Correlation Id", + "default": "" }, - "message_id": { + "resolve_response": { + "items": { + "$ref": "#/components/schemas/SingleResolveResponse" + }, + "type": "array", + "title": "Resolve Response" + } + }, + "type": "object", + "required": [ + "transaction_id", + "resolve_response" + ], + "title": "ResolveResponseMessage" + }, + "ResolveScope": { + "type": "string", + "enum": [ + "yes_no", + "details" + ], + "title": "ResolveScope" + }, + "ResolveStatusReasonCode": { + "type": "string", + "enum": [ + "rjct.reference_id.invalid", + "rjct.reference_id.duplicate", + "rjct.timestamp.invalid", + "rjct.id.invalid", + "rjct.fa.invalid", + "rjct.resolve_type.not_supported", + "succ.fa.active", + "succ.fa.inactive", + "succ.fa.not_found", + "succ.fa.not_linked_to_id", + "succ.id.active", + "succ.id.inactive", + "succ.id.not_found" + ], + "title": "ResolveStatusReasonCode" + }, + "SingleLinkRequest": { + "properties": { + "reference_id": { "type": "string", - "title": "Message Id" + "title": "Reference Id" }, - "message_ts": { + "timestamp": { "type": "string", - "title": "Message Ts" + "format": "date-time", + "title": "Timestamp" }, - "action": { + "id": { "type": "string", - "title": "Action" + "title": "Id" }, - "status": { - "$ref": "#/components/schemas/StatusEnum" + "fa": { + "type": "string", + "title": "Fa" }, - "status_reason_code": { + "name": { "anyOf": [ { - "$ref": "#/components/schemas/SyncResponseStatusReasonCodeEnum" + "type": "string" }, { "type": "null" } - ] + ], + "title": "Name" }, - "status_reason_message": { + "phone_number": { "anyOf": [ { "type": "string" @@ -1038,32 +1227,54 @@ "type": "null" } ], - "title": "Status Reason Message", - "default": "" + "title": "Phone Number" }, - "total_count": { + "additional_info": { "anyOf": [ { - "type": "integer" + "items": {}, + "type": "array" }, { "type": "null" } ], - "title": "Total Count" + "title": "Additional Info" }, - "completed_count": { + "locale": { "anyOf": [ { - "type": "integer" + "type": "string" }, { "type": "null" } ], - "title": "Completed Count" + "title": "Locale", + "default": "en" + } + }, + "type": "object", + "required": [ + "reference_id", + "timestamp", + "id", + "fa" + ], + "title": "SingleLinkRequest" + }, + "SingleLinkResponse": { + "properties": { + "reference_id": { + "type": "string", + "title": "Reference Id" }, - "sender_id": { + "timestamp": { + "type": "string", + "format": "date-time", + "title": "Timestamp" + }, + "fa": { "anyOf": [ { "type": "string" @@ -1072,9 +1283,22 @@ "type": "null" } ], - "title": "Sender Id" + "title": "Fa" }, - "receiver_id": { + "status": { + "$ref": "#/components/schemas/StatusEnum" + }, + "status_reason_code": { + "anyOf": [ + { + "$ref": "#/components/schemas/LinkStatusReasonCode" + }, + { + "type": "null" + } + ] + }, + "status_reason_message": { "anyOf": [ { "type": "string" @@ -1083,56 +1307,936 @@ "type": "null" } ], - "title": "Receiver Id" + "title": "Status Reason Message" }, - "is_msg_encrypted": { + "additional_info": { "anyOf": [ { - "type": "boolean" + "items": {}, + "type": "array" }, { "type": "null" } ], - "title": "Is Msg Encrypted", - "default": false + "title": "Additional Info" }, - "meta": { + "locale": { "anyOf": [ { - "type": "object" + "type": "string" }, { "type": "null" } ], - "title": "Meta", - "default": {} + "title": "Locale", + "default": "en" } }, "type": "object", "required": [ - "message_id", - "message_ts", - "action", - "status", - "status_reason_code" + "reference_id", + "timestamp", + "status" ], - "title": "SyncResponseHeader" + "title": "SingleLinkResponse" }, - "SyncResponseStatusReasonCodeEnum": { - "type": "string", - "enum": [ - "rjct.version.invalid", - "rjct.message_id.duplicate", - "rjct.message_ts.invalid", - "rjct.action.invalid", - "rjct.action.not_supported", - "rjct.total_count.invalid", - "rjct.total_count.limit_exceeded", - "rjct.errors.too_many" - ], - "title": "SyncResponseStatusReasonCodeEnum" + "SingleResolveRequest": { + "properties": { + "reference_id": { + "type": "string", + "title": "Reference Id" + }, + "timestamp": { + "type": "string", + "format": "date-time", + "title": "Timestamp" + }, + "fa": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Fa", + "default": "" + }, + "id": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Id", + "default": "" + }, + "name": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Name" + }, + "scope": { + "anyOf": [ + { + "$ref": "#/components/schemas/ResolveScope" + }, + { + "type": "null" + } + ], + "default": "details" + }, + "additional_info": { + "anyOf": [ + { + "items": {}, + "type": "array" + }, + { + "type": "null" + } + ], + "title": "Additional Info" + }, + "locale": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Locale", + "default": "en" + } + }, + "type": "object", + "required": [ + "reference_id", + "timestamp" + ], + "title": "SingleResolveRequest" + }, + "SingleResolveResponse": { + "properties": { + "reference_id": { + "type": "string", + "title": "Reference Id" + }, + "timestamp": { + "type": "string", + "format": "date-time", + "title": "Timestamp" + }, + "fa": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Fa" + }, + "id": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Id" + }, + "account_provider_info": { + "anyOf": [ + { + "$ref": "#/components/schemas/AccountProviderInfo" + }, + { + "type": "null" + } + ] + }, + "status": { + "$ref": "#/components/schemas/StatusEnum" + }, + "status_reason_code": { + "anyOf": [ + { + "$ref": "#/components/schemas/ResolveStatusReasonCode" + }, + { + "type": "null" + } + ] + }, + "status_reason_message": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Status Reason Message", + "default": "" + }, + "additional_info": { + "anyOf": [ + { + "items": {}, + "type": "array" + }, + { + "type": "null" + } + ], + "title": "Additional Info" + }, + "locale": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Locale", + "default": "en" + } + }, + "type": "object", + "required": [ + "reference_id", + "timestamp", + "status" + ], + "title": "SingleResolveResponse" + }, + "SingleUnlinkRequest": { + "properties": { + "reference_id": { + "type": "string", + "title": "Reference Id" + }, + "timestamp": { + "type": "string", + "format": "date-time", + "title": "Timestamp" + }, + "id": { + "type": "string", + "title": "Id" + }, + "fa": { + "type": "string", + "title": "Fa" + }, + "name": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Name" + }, + "phone_number": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Phone Number" + }, + "additional_info": { + "anyOf": [ + { + "items": {}, + "type": "array" + }, + { + "type": "null" + } + ], + "title": "Additional Info" + }, + "locale": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Locale", + "default": "en" + } + }, + "type": "object", + "required": [ + "reference_id", + "timestamp", + "id", + "fa" + ], + "title": "SingleUnlinkRequest" + }, + "SingleUnlinkResponse": { + "properties": { + "reference_id": { + "type": "string", + "title": "Reference Id" + }, + "timestamp": { + "type": "string", + "format": "date-time", + "title": "Timestamp" + }, + "id": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Id", + "default": "" + }, + "status": { + "$ref": "#/components/schemas/StatusEnum" + }, + "status_reason_code": { + "anyOf": [ + { + "$ref": "#/components/schemas/UnlinkStatusReasonCode" + }, + { + "type": "null" + } + ] + }, + "status_reason_message": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Status Reason Message", + "default": "" + }, + "additional_info": { + "anyOf": [ + { + "items": {}, + "type": "array" + }, + { + "type": "null" + } + ], + "title": "Additional Info" + }, + "locale": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Locale", + "default": "en" + } + }, + "type": "object", + "required": [ + "reference_id", + "timestamp", + "status" + ], + "title": "SingleUnlinkResponse" + }, + "SingleUpdateRequest": { + "properties": { + "reference_id": { + "type": "string", + "title": "Reference Id" + }, + "timestamp": { + "type": "string", + "format": "date-time", + "title": "Timestamp" + }, + "id": { + "type": "string", + "title": "Id" + }, + "fa": { + "type": "string", + "title": "Fa" + }, + "name": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Name" + }, + "phone_number": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Phone Number" + }, + "additional_info": { + "anyOf": [ + { + "items": {}, + "type": "array" + }, + { + "type": "null" + } + ], + "title": "Additional Info" + }, + "locale": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Locale", + "default": "en" + } + }, + "type": "object", + "required": [ + "reference_id", + "timestamp", + "id", + "fa" + ], + "title": "SingleUpdateRequest" + }, + "SingleUpdateResponse": { + "properties": { + "reference_id": { + "type": "string", + "title": "Reference Id" + }, + "timestamp": { + "type": "string", + "format": "date-time", + "title": "Timestamp" + }, + "id": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Id", + "default": "" + }, + "status": { + "$ref": "#/components/schemas/StatusEnum" + }, + "status_reason_code": { + "anyOf": [ + { + "$ref": "#/components/schemas/UpdateStatusReasonCode" + }, + { + "type": "null" + } + ] + }, + "status_reason_message": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Status Reason Message", + "default": "" + }, + "additional_info": { + "anyOf": [ + { + "items": {}, + "type": "array" + }, + { + "type": "null" + } + ], + "title": "Additional Info" + }, + "locale": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Locale", + "default": "en" + } + }, + "type": "object", + "required": [ + "reference_id", + "timestamp", + "status" + ], + "title": "SingleUpdateResponse" + }, + "StatusEnum": { + "type": "string", + "enum": [ + "rcvd", + "pdng", + "succ", + "rjct" + ], + "title": "StatusEnum" + }, + "SyncResponseHeader": { + "properties": { + "version": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Version", + "default": "1.0.0" + }, + "message_id": { + "type": "string", + "title": "Message Id" + }, + "message_ts": { + "type": "string", + "title": "Message Ts" + }, + "action": { + "type": "string", + "title": "Action" + }, + "status": { + "$ref": "#/components/schemas/StatusEnum" + }, + "status_reason_code": { + "anyOf": [ + { + "$ref": "#/components/schemas/SyncResponseStatusReasonCodeEnum" + }, + { + "type": "null" + } + ] + }, + "status_reason_message": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Status Reason Message", + "default": "" + }, + "total_count": { + "anyOf": [ + { + "type": "integer" + }, + { + "type": "null" + } + ], + "title": "Total Count" + }, + "completed_count": { + "anyOf": [ + { + "type": "integer" + }, + { + "type": "null" + } + ], + "title": "Completed Count" + }, + "sender_id": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Sender Id" + }, + "receiver_id": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Receiver Id" + }, + "is_msg_encrypted": { + "anyOf": [ + { + "type": "boolean" + }, + { + "type": "null" + } + ], + "title": "Is Msg Encrypted", + "default": false + }, + "meta": { + "anyOf": [ + { + "type": "object" + }, + { + "type": "null" + } + ], + "title": "Meta", + "default": {} + } + }, + "type": "object", + "required": [ + "message_id", + "message_ts", + "action", + "status", + "status_reason_code" + ], + "title": "SyncResponseHeader" + }, + "SyncResponseStatusReasonCodeEnum": { + "type": "string", + "enum": [ + "rjct.version.invalid", + "rjct.message_id.duplicate", + "rjct.message_ts.invalid", + "rjct.action.invalid", + "rjct.action.not_supported", + "rjct.total_count.invalid", + "rjct.total_count.limit_exceeded", + "rjct.errors.too_many" + ], + "title": "SyncResponseStatusReasonCodeEnum" + }, + "UnlinkRequest": { + "properties": { + "signature": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Signature" + }, + "header": { + "$ref": "#/components/schemas/RequestHeader" + }, + "message": { + "$ref": "#/components/schemas/UnlinkRequestMessage" + } + }, + "type": "object", + "required": [ + "header", + "message" + ], + "title": "UnlinkRequest" + }, + "UnlinkRequestMessage": { + "properties": { + "transaction_id": { + "type": "string", + "title": "Transaction Id" + }, + "unlink_request": { + "items": { + "$ref": "#/components/schemas/SingleUnlinkRequest" + }, + "type": "array", + "title": "Unlink Request" + } + }, + "type": "object", + "required": [ + "transaction_id", + "unlink_request" + ], + "title": "UnlinkRequestMessage" + }, + "UnlinkResponse": { + "properties": { + "signature": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Signature" + }, + "header": { + "$ref": "#/components/schemas/SyncResponseHeader" + }, + "message": { + "$ref": "#/components/schemas/UnlinkResponseMessage" + } + }, + "type": "object", + "required": [ + "header", + "message" + ], + "title": "UnlinkResponse" + }, + "UnlinkResponseMessage": { + "properties": { + "transaction_id": { + "type": "string", + "title": "Transaction Id" + }, + "correlation_id": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Correlation Id", + "default": "" + }, + "unlink_response": { + "items": { + "$ref": "#/components/schemas/SingleUnlinkResponse" + }, + "type": "array", + "title": "Unlink Response" + } + }, + "type": "object", + "required": [ + "transaction_id", + "unlink_response" + ], + "title": "UnlinkResponseMessage" + }, + "UnlinkStatusReasonCode": { + "type": "string", + "enum": [ + "rjct.reference_id.invalid", + "rjct.id.invalid", + "rjct.fa.invalid", + "rjct.reference_id.duplicate", + "rjct.timestamp.invalid", + "rjct.beneficiary_name.invalid" + ], + "title": "UnlinkStatusReasonCode" + }, + "UpdateRequest": { + "properties": { + "signature": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Signature" + }, + "header": { + "$ref": "#/components/schemas/RequestHeader" + }, + "message": { + "$ref": "#/components/schemas/UpdateRequestMessage" + } + }, + "type": "object", + "required": [ + "header", + "message" + ], + "title": "UpdateRequest" + }, + "UpdateRequestMessage": { + "properties": { + "transaction_id": { + "type": "string", + "title": "Transaction Id" + }, + "update_request": { + "items": { + "$ref": "#/components/schemas/SingleUpdateRequest" + }, + "type": "array", + "title": "Update Request" + } + }, + "type": "object", + "required": [ + "transaction_id", + "update_request" + ], + "title": "UpdateRequestMessage" + }, + "UpdateResponse": { + "properties": { + "signature": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Signature" + }, + "header": { + "$ref": "#/components/schemas/SyncResponseHeader" + }, + "message": { + "$ref": "#/components/schemas/UpdateResponseMessage" + } + }, + "type": "object", + "required": [ + "header", + "message" + ], + "title": "UpdateResponse" + }, + "UpdateResponseMessage": { + "properties": { + "transaction_id": { + "type": "string", + "title": "Transaction Id" + }, + "correlation_id": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Correlation Id", + "default": "" + }, + "update_response": { + "items": { + "$ref": "#/components/schemas/SingleUpdateResponse" + }, + "type": "array", + "title": "Update Response" + } + }, + "type": "object", + "required": [ + "transaction_id", + "update_response" + ], + "title": "UpdateResponseMessage" + }, + "UpdateStatusReasonCode": { + "type": "string", + "enum": [ + "rjct.reference_id.invalid", + "rjct.reference_id.duplicate", + "rjct.timestamp.invalid", + "rjct.beneficiary_name.invalid", + "rjct.id.invalid", + "rjct.fa.invalid" + ], + "title": "UpdateStatusReasonCode" }, "ValidationError": { "properties": { From 339c9cb11c4e9ee76c04a5b3f6645c9e5981ce34 Mon Sep 17 00:00:00 2001 From: PSNAppZ Date: Fri, 5 Apr 2024 17:40:40 +0530 Subject: [PATCH 5/9] Fix dep issue in tox --- tox.ini | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/tox.ini b/tox.ini index ecb98d9..08e3a9c 100644 --- a/tox.ini +++ b/tox.ini @@ -6,16 +6,14 @@ minversion = 4.11.3 [testenv] description = run the tests with pytest -commands = pytest - --cov=openg2p-spar-mapper-api +commands = pytest --cov=openg2p_spar_mapper_api deps = pytest-asyncio pytest-cov - git+https://github.com/openg2p/openg2p-fastapi-common.git@develop#egg=openg2p-fastapi-common&subdirectory=openg2p-fastapi-common - git+https://github.com/openg2p/openg2p-fastapi-common.git@develop#egg=openg2p-fastapi-auth&subdirectory=openg2p-fastapi-auth + git+https://github.com/openg2p/openg2p-fastapi-common@develop\#subdirectory=openg2p-fastapi-common + git+https://github.com/openg2p/openg2p-fastapi-common@develop\#subdirectory=openg2p-fastapi-auth git+https://github.com/openg2p/openg2p-g2pconnect-common-lib.git@develop#egg=openg2p-g2pconnect-common-lib - - + . [testenv:clean] deps = coverage skip_install = true From 2f0d16a3db8c06a2b089420ace42e7a854acd861 Mon Sep 17 00:00:00 2001 From: PSNAppZ Date: Fri, 5 Apr 2024 17:52:34 +0530 Subject: [PATCH 6/9] Fix dep issue in tox --- tox.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tox.ini b/tox.ini index 08e3a9c..3796c01 100644 --- a/tox.ini +++ b/tox.ini @@ -6,7 +6,7 @@ minversion = 4.11.3 [testenv] description = run the tests with pytest -commands = pytest --cov=openg2p_spar_mapper_api +commands = pytest --cov=src --cov=tests deps = pytest-asyncio pytest-cov From fc86f545128dbc902e374183e5dd4538572d8f1a Mon Sep 17 00:00:00 2001 From: PSNAppZ Date: Fri, 5 Apr 2024 18:05:20 +0530 Subject: [PATCH 7/9] Fix dep issue in tox --- tox.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tox.ini b/tox.ini index 3796c01..bd31f0b 100644 --- a/tox.ini +++ b/tox.ini @@ -6,7 +6,7 @@ minversion = 4.11.3 [testenv] description = run the tests with pytest -commands = pytest --cov=src --cov=tests +commands = pytest --cov=openg2p_spar_mapper_api --cov=tests deps = pytest-asyncio pytest-cov From 41df7f581a6601f43805e89023b93c41b531e8c9 Mon Sep 17 00:00:00 2001 From: PSNAppZ Date: Fri, 5 Apr 2024 18:08:14 +0530 Subject: [PATCH 8/9] Remove async test file --- tests/test_async_mapper_controller.py | 71 --------------------------- 1 file changed, 71 deletions(-) delete mode 100644 tests/test_async_mapper_controller.py diff --git a/tests/test_async_mapper_controller.py b/tests/test_async_mapper_controller.py deleted file mode 100644 index e933d98..0000000 --- a/tests/test_async_mapper_controller.py +++ /dev/null @@ -1,71 +0,0 @@ -# import asyncio -# import unittest -# from unittest.mock import MagicMock, patch -# -# from fastapi import Request -# from openg2p_spar_mapper_api.controllers.async_mapper_controller import ( -# AsyncMapperController, -# ) -# -# -# class TestAsyncMapperController(unittest.TestCase): -# def setUp(self) -> None: -# self.mock_request = MagicMock(spec=Request) -# self.mock_request_validation = patch( -# "openg2p_spar_mapper_api.controllers.async_mapper_controller.RequestValidation" -# ).start() -# self.mock_response_helper = patch( -# "openg2p_spar_mapper_api.controllers.async_mapper_controller.AsyncResponseHelper" -# ).start() -# -# self.mock_request_validation.validate_request.side_effect = None -# self.mock_request_validation.validate_link_request_header.side_effect = None -# -# self.mock_mapper_service = MagicMock() -# self.controller = AsyncMapperController() -# -# def tearDown(self) -> None: -# patch.stopall() -# -# def test_link_async(self): -# async def run_test(): -# response = await self.controller.link_async(self.mock_request) -# self.assertIsNotNone(response) -# # self.mock_response_helper.get_component().construct_error_async_response.assert_not_called() -# self.mock_response_helper.get_component().construct_success_async_response.assert_called_once_with( -# self.mock_request, 123555 -# ) -# -# asyncio.run(run_test()) -# -# # def test_update_sync(self): -# # async def run_test(): -# # response = await self.controller.update_async(self.mock_request) -# # self.assertIsNotNone(response) -# # # self.mock_response_helper.get_component().construct_error_async_response.assert_not_called() -# # self.mock_response_helper.get_component().construct_success_async_response.assert_called_once_with( -# # self.mock_request, 123555 -# # ) -# -# # asyncio.run(run_test()) -# -# # def test_resolve_sync(self): -# # async def run_test(): -# # response = await self.controller.resolve_async(self.mock_request) -# # self.assertIsNotNone(response) -# # # self.mock_response_helper.get_component().construct_error_async_response.assert_not_called() -# # self.mock_response_helper.get_component().construct_success_async_response.assert_called_once_with( -# # self.mock_request, 123555 -# # ) -# # asyncio.run(run_test()) -# -# # def test_unlink_sync(self): -# # async def run_test(): -# # response = await self.controller.unlink_async(self.mock_request) -# # self.assertIsNotNone(response) -# # # self.mock_response_helper.get_component().construct_error_async_response.assert_not_called() -# # self.mock_response_helper.get_component().construct_success_async_response.assert_called_once_with( -# # self.mock_request,123555 -# # ) -# -# # asyncio.run(run_test()) From a44d40905cfff663aab0dc1c621935ea208ee3c6 Mon Sep 17 00:00:00 2001 From: PSNAppZ Date: Fri, 5 Apr 2024 18:12:27 +0530 Subject: [PATCH 9/9] Fix pre-commit issues --- tests/test_sync_mapper_controller.py | 24 ++++++++++++------------ tox.ini | 2 +- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/tests/test_sync_mapper_controller.py b/tests/test_sync_mapper_controller.py index 8e3ffe7..b365f57 100644 --- a/tests/test_sync_mapper_controller.py +++ b/tests/test_sync_mapper_controller.py @@ -1,27 +1,27 @@ -import pytest from datetime import datetime -from unittest.mock import AsyncMock, patch, MagicMock +from unittest.mock import AsyncMock, MagicMock, patch + +import pytest +from openg2p_g2pconnect_common_lib.common.schemas import ( + RequestHeader, + StatusEnum, + SyncResponseHeader, + SyncResponseStatusReasonCodeEnum, +) from openg2p_g2pconnect_common_lib.mapper.schemas import ( LinkRequest, + LinkRequestMessage, LinkResponse, - SingleLinkResponse, LinkResponseMessage, - LinkRequestMessage, SingleLinkRequest, + SingleLinkResponse, ) -from openg2p_g2pconnect_common_lib.common.schemas import ( - StatusEnum, - SyncResponseStatusReasonCodeEnum, - SyncResponseHeader, - RequestHeader, -) - from openg2p_spar_mapper_api.controllers.sync_mapper_controller import ( SyncMapperController, ) from openg2p_spar_mapper_api.services import ( - RequestValidationException, RequestValidation, + RequestValidationException, ) diff --git a/tox.ini b/tox.ini index bd31f0b..ef428e1 100644 --- a/tox.ini +++ b/tox.ini @@ -17,4 +17,4 @@ deps = [testenv:clean] deps = coverage skip_install = true -commands = coverage erase \ No newline at end of file +commands = coverage erase