diff --git a/.github/workflows/ee-ep-merge-end-to-end.yml b/.github/workflows/ee-ep-merge-end-to-end.yml index 2eff292759..9435cc3970 100644 --- a/.github/workflows/ee-ep-merge-end-to-end.yml +++ b/.github/workflows/ee-ep-merge-end-to-end.yml @@ -8,7 +8,7 @@ on: workflow_call: env: - COMPOSE_PROFILES: 'bip' + COMPOSE_PROFILES: 'bip,bgs' VRO_DEV_SECRETS_FOLDER: "${{ github.workspace }}/.cache/abd-vro-dev-secrets" jobs: @@ -62,18 +62,6 @@ jobs: # Quit after 60 seconds retries: 30 - # Temporary step added to avoid condition where bipApiExchange is not yet created. - - name: 'Create bipApiExchange exchange' - uses: indiesdev/curl@v1.1 - with: - url: 'http://localhost:15672/api/exchanges/%2f/bipApiExchange' - method: 'PUT' - basic-auth-token: '${{env.RABBITMQ_BASIC_AUTH}}' - body: '{"type":"direct", "durable":true, "auto_delete":true}' - accept: 201, 204 - retries: 3 - log-response: true - - name: "Run Employee Experience Integration Tests" run: | ./gradlew :domain-ee:ee-ep-merge-app:integrationTest diff --git a/domain-ee/ee-ep-merge-app/integration/conftest.py b/domain-ee/ee-ep-merge-app/integration/conftest.py index 2b668f979a..c3e6ac4cd7 100644 --- a/domain-ee/ee-ep-merge-app/integration/conftest.py +++ b/domain-ee/ee-ep-merge-app/integration/conftest.py @@ -1,7 +1,9 @@ +import asyncio + import pytest import pytest_asyncio from integration.mq_endpoint import MqEndpoint -from src.python_src.config import QUEUES, REPLY_QUEUES, ClientName +from src.python_src.config import EXCHANGES, QUEUES, REPLY_QUEUES, ClientName @pytest.fixture(autouse=True, scope="session") @@ -29,22 +31,29 @@ def cancel_claim_endpoint(): return create_mq_endpoint(ClientName.CANCEL_CLAIM) +@pytest.fixture(autouse=True, scope="session") +def add_claim_note_endpoint(): + return create_mq_endpoint(ClientName.BGS_ADD_CLAIM_NOTE) + + def create_mq_endpoint(name): - return MqEndpoint(name, QUEUES[name], REPLY_QUEUES[name]) + return MqEndpoint(name, EXCHANGES[name], QUEUES[name], REPLY_QUEUES[name]) @pytest_asyncio.fixture(autouse=True, scope="session") -async def endpoint_lifecycle(event_loop, - get_claim_endpoint: MqEndpoint, +async def endpoint_lifecycle(get_claim_endpoint: MqEndpoint, get_claim_contentions_endpoint: MqEndpoint, put_tsoj_endpoint: MqEndpoint, create_claim_contentions_endpoint: MqEndpoint, - cancel_claim_endpoint: MqEndpoint): + cancel_claim_endpoint: MqEndpoint, + add_claim_note_endpoint: MqEndpoint): + event_loop = asyncio.get_running_loop() await get_claim_endpoint.start(event_loop) await get_claim_contentions_endpoint.start(event_loop) await put_tsoj_endpoint.start(event_loop) await create_claim_contentions_endpoint.start(event_loop) await cancel_claim_endpoint.start(event_loop) + await add_claim_note_endpoint.start(event_loop) yield @@ -53,3 +62,4 @@ async def endpoint_lifecycle(event_loop, put_tsoj_endpoint.stop() create_claim_contentions_endpoint.stop() cancel_claim_endpoint.stop() + add_claim_note_endpoint.stop() diff --git a/domain-ee/ee-ep-merge-app/integration/mq_endpoint.py b/domain-ee/ee-ep-merge-app/integration/mq_endpoint.py index c47b37d24b..e0e536b086 100644 --- a/domain-ee/ee-ep-merge-app/integration/mq_endpoint.py +++ b/domain-ee/ee-ep-merge-app/integration/mq_endpoint.py @@ -4,19 +4,17 @@ from hoppy import async_consumer, async_publisher from hoppy.hoppy_properties import ExchangeProperties, QueueProperties from pika import BasicProperties -from src.python_src.config import EXCHANGE - -exchange_props = ExchangeProperties(name=EXCHANGE) class MqEndpoint: - def __init__(self, name, req_queue, response_queue): + def __init__(self, name, exchange, req_queue, response_queue): self.name = name self.index = 0 self.auto_response_files = [] - queue_props = QueueProperties(name=req_queue, passive_declare=False) + exchange_props = ExchangeProperties(name=exchange, auto_delete=True, passive_declare=False) + queue_props = QueueProperties(name=req_queue, auto_delete=True, passive_declare=False) self.consumer = async_consumer.AsyncConsumer(exchange_properties=exchange_props, queue_properties=queue_props, routing_key=req_queue, diff --git a/domain-ee/ee-ep-merge-app/integration/test_merge_request.py b/domain-ee/ee-ep-merge-app/integration/test_merge_request.py index 1b0e9d7ebe..14d5310396 100644 --- a/domain-ee/ee-ep-merge-app/integration/test_merge_request.py +++ b/domain-ee/ee-ep-merge-app/integration/test_merge_request.py @@ -1,5 +1,3 @@ -import asyncio - import pytest import pytest_asyncio from httpx import AsyncClient @@ -19,16 +17,6 @@ ep400_duplicate_contentions_200 = f'{RESPONSE_DIR}/claim_contentions_increase_tendinitis_200.json' -@pytest.fixture(scope="session") -def event_loop(): - try: - loop = asyncio.get_running_loop() - except RuntimeError: - loop = asyncio.new_event_loop() - yield loop - loop.close() - - @pytest_asyncio.fixture(autouse=True, scope="session") async def app_lifespan(): await on_start_up() @@ -65,18 +53,20 @@ async def submit_request(self, client): assert response_json['job']['state'] == JobState.PENDING.value return response_json['job']['job_id'] - @pytest.mark.asyncio + @pytest.mark.asyncio(scope="session")(scope="session") async def test_completed_success(self, get_claim_endpoint: MqEndpoint, get_claim_contentions_endpoint: MqEndpoint, put_tsoj_endpoint: MqEndpoint, create_claim_contentions_endpoint: MqEndpoint, - cancel_claim_endpoint: MqEndpoint): + cancel_claim_endpoint: MqEndpoint, + add_claim_note_endpoint: MqEndpoint): get_claim_endpoint.set_responses([pending_claim_200]) get_claim_contentions_endpoint.set_responses([pending_contentions_200, ep400_contentions_200]) put_tsoj_endpoint.set_responses([response_200]) create_claim_contentions_endpoint.set_responses([response_201]) cancel_claim_endpoint.set_responses([response_200]) + add_claim_note_endpoint.set_responses([response_200]) async with AsyncClient(app=app, base_url="http://test") as client: job_id = await self.submit_request(client) @@ -90,7 +80,7 @@ async def test_completed_success(self, assert response_json['job']['ep400_claim_id'] == self.ep400_claim_id assert response_json['job']['state'] == JobState.COMPLETED_SUCCESS.value - @pytest.mark.asyncio + @pytest.mark.asyncio(scope="session") async def test_completed_success_with_duplicate_contention(self, get_claim_endpoint: MqEndpoint, get_claim_contentions_endpoint: MqEndpoint, @@ -113,7 +103,7 @@ async def test_completed_success_with_duplicate_contention(self, assert response_json['job']['ep400_claim_id'] == self.ep400_claim_id assert response_json['job']['state'] == JobState.COMPLETED_SUCCESS.value - @pytest.mark.asyncio + @pytest.mark.asyncio(scope="session") async def test_completed_error_at_get_pending_claim(self, get_claim_endpoint: MqEndpoint): get_claim_endpoint.set_responses([response_500]) @@ -131,7 +121,7 @@ async def test_completed_error_at_get_pending_claim(self, assert response_json['job']['state'] == JobState.COMPLETED_ERROR.value assert response_json['job']['error_state'] == JobState.RUNNING_GET_PENDING_CLAIM.value - @pytest.mark.asyncio + @pytest.mark.asyncio(scope="session") async def test_completed_error_at_get_pending_contentions(self, get_claim_endpoint: MqEndpoint, get_claim_contentions_endpoint: MqEndpoint): @@ -151,7 +141,7 @@ async def test_completed_error_at_get_pending_contentions(self, assert response_json['job']['state'] == JobState.COMPLETED_ERROR.value assert response_json['job']['error_state'] == JobState.RUNNING_GET_PENDING_CLAIM_CONTENTIONS.value - @pytest.mark.asyncio + @pytest.mark.asyncio(scope="session") async def test_completed_error_at_get_ep400_contentions(self, get_claim_endpoint: MqEndpoint, get_claim_contentions_endpoint: MqEndpoint): @@ -171,7 +161,7 @@ async def test_completed_error_at_get_ep400_contentions(self, assert response_json['job']['state'] == JobState.COMPLETED_ERROR.value assert response_json['job']['error_state'] == JobState.RUNNING_GET_EP400_CLAIM_CONTENTIONS.value - @pytest.mark.asyncio + @pytest.mark.asyncio(scope="session") async def test_completed_error_at_set_tsoj(self, get_claim_endpoint: MqEndpoint, get_claim_contentions_endpoint: MqEndpoint, @@ -193,7 +183,7 @@ async def test_completed_error_at_set_tsoj(self, assert response_json['job']['state'] == JobState.COMPLETED_ERROR.value assert response_json['job']['error_state'] == JobState.RUNNING_SET_TEMP_STATION_OF_JURISDICTION.value - @pytest.mark.asyncio + @pytest.mark.asyncio(scope="session") async def test_completed_error_at_create_claim_contentions(self, get_claim_endpoint: MqEndpoint, get_claim_contentions_endpoint: MqEndpoint, @@ -217,7 +207,7 @@ async def test_completed_error_at_create_claim_contentions(self, assert response_json['job']['state'] == JobState.COMPLETED_ERROR.value assert response_json['job']['error_state'] == JobState.RUNNING_MOVE_CONTENTIONS_TO_PENDING_CLAIM.value - @pytest.mark.asyncio + @pytest.mark.asyncio(scope="session") async def test_completed_error_at_cancel_claim(self, get_claim_endpoint: MqEndpoint, get_claim_contentions_endpoint: MqEndpoint, @@ -242,3 +232,31 @@ async def test_completed_error_at_cancel_claim(self, assert response_json['job']['ep400_claim_id'] == self.ep400_claim_id assert response_json['job']['state'] == JobState.COMPLETED_ERROR.value assert response_json['job']['error_state'] == JobState.RUNNING_CANCEL_EP400_CLAIM.value + + @pytest.mark.asyncio(scope="session") + async def test_completed_error_at_add_claim_note(self, + get_claim_endpoint: MqEndpoint, + get_claim_contentions_endpoint: MqEndpoint, + put_tsoj_endpoint: MqEndpoint, + create_claim_contentions_endpoint: MqEndpoint, + cancel_claim_endpoint: MqEndpoint, + add_claim_note_endpoint: MqEndpoint): + get_claim_endpoint.set_responses([pending_claim_200]) + get_claim_contentions_endpoint.set_responses([pending_contentions_200, ep400_contentions_200]) + put_tsoj_endpoint.set_responses([response_200]) + create_claim_contentions_endpoint.set_responses([response_201]) + cancel_claim_endpoint.set_responses([response_200]) + add_claim_note_endpoint.set_responses([response_500]) + + async with AsyncClient(app=app, base_url="http://test") as client: + job_id = await self.submit_request(client) + + response = await client.get(url=f"/merge/{job_id}") + assert response.status_code == 200 + + response_json = response.json() + assert response_json is not None + assert response_json['job']['pending_claim_id'] == self.pending_claim_id + assert response_json['job']['ep400_claim_id'] == self.ep400_claim_id + assert response_json['job']['state'] == JobState.COMPLETED_ERROR.value + assert response_json['job']['error_state'] == JobState.RUNNING_ADD_CLAIM_NOTE_TO_EP400.value diff --git a/domain-ee/ee-ep-merge-app/src/python_src/config.py b/domain-ee/ee-ep-merge-app/src/python_src/config.py index 059f3306ac..4c3f0f36c5 100644 --- a/domain-ee/ee-ep-merge-app/src/python_src/config.py +++ b/domain-ee/ee-ep-merge-app/src/python_src/config.py @@ -24,9 +24,20 @@ class ClientName(str, Enum): PUT_TSOJ = "putTemporaryStationOfJurisdictionClient" CREATE_CLAIM_CONTENTIONS = "createClaimContentionsClient" CANCEL_CLAIM = "cancelClaimClient" + BGS_ADD_CLAIM_NOTE = "addClaimNoteClient" -EXCHANGE = "bipApiExchange" +BIP_EXCHANGE = "bipApiExchange" +BGS_EXCHANGE = "bgs-api" + +EXCHANGES = { + ClientName.GET_CLAIM: os.environ.get("BIP_API_EXCHANGE") or BIP_EXCHANGE, + ClientName.GET_CLAIM_CONTENTIONS: os.environ.get("BIP_API_EXCHANGE") or BIP_EXCHANGE, + ClientName.PUT_TSOJ: os.environ.get("BIP_API_EXCHANGE") or BIP_EXCHANGE, + ClientName.CREATE_CLAIM_CONTENTIONS: os.environ.get("BIP_API_EXCHANGE") or BIP_EXCHANGE, + ClientName.CANCEL_CLAIM: os.environ.get("BIP_API_EXCHANGE") or BIP_EXCHANGE, + ClientName.BGS_ADD_CLAIM_NOTE: os.environ.get("BGS_API_EXCHANGE") or BGS_EXCHANGE, +} QUEUES = { ClientName.GET_CLAIM: @@ -39,6 +50,8 @@ class ClientName(str, Enum): os.environ.get("CREATE_CLAIM_CONTENTIONS_REQUEST") or "createClaimContentionsQueue", ClientName.CANCEL_CLAIM: os.environ.get("CANCEL_CLAIM_REQUEST") or "cancelClaimQueue", + ClientName.BGS_ADD_CLAIM_NOTE: + os.environ.get("ADD_CLAIM_NOTE_REQUEST") or "add-note", } REPLY_QUEUES = { @@ -52,4 +65,6 @@ class ClientName(str, Enum): os.environ.get("CREATE_CLAIM_CONTENTIONS_RESPONSE") or "createClaimContentionsResponseQueue", ClientName.CANCEL_CLAIM: os.environ.get("CANCEL_CLAIM_RESPONSE") or "cancelClaimResponseQueue", + ClientName.BGS_ADD_CLAIM_NOTE: + os.environ.get("ADD_CLAIM_NOTE_RESPONSE") or "add-note-response", } diff --git a/domain-ee/ee-ep-merge-app/src/python_src/model/add_claim_note.py b/domain-ee/ee-ep-merge-app/src/python_src/model/add_claim_note.py new file mode 100644 index 0000000000..8ea4836da3 --- /dev/null +++ b/domain-ee/ee-ep-merge-app/src/python_src/model/add_claim_note.py @@ -0,0 +1,16 @@ +from pydantic import ConfigDict +from pydantic.alias_generators import to_camel + +from .request import GeneralRequest +from .response import GeneralResponse + + +class Request(GeneralRequest): + model_config = ConfigDict(populate_by_name=True, alias_generator=to_camel) + + vbms_claim_id: int + claim_notes: list[str] + + +class Response(GeneralResponse): + pass diff --git a/domain-ee/ee-ep-merge-app/src/python_src/model/merge_job.py b/domain-ee/ee-ep-merge-app/src/python_src/model/merge_job.py index c03ac0e4f6..0073d397f5 100644 --- a/domain-ee/ee-ep-merge-app/src/python_src/model/merge_job.py +++ b/domain-ee/ee-ep-merge-app/src/python_src/model/merge_job.py @@ -15,6 +15,7 @@ class JobState(str, Enum): RUNNING_MERGE_CONTENTIONS = 'RUNNING_MERGE_CONTENTIONS' RUNNING_MOVE_CONTENTIONS_TO_PENDING_CLAIM = 'RUNNING_MOVE_CONTENTIONS_TO_PENDING_CLAIM' RUNNING_CANCEL_EP400_CLAIM = 'RUNNING_CANCEL_EP400_CLAIM' + RUNNING_ADD_CLAIM_NOTE_TO_EP400 = 'RUNNING_ADD_CLAIM_NOTE_TO_EP400' COMPLETED_SUCCESS = 'COMPLETED_SUCCESS' @@ -26,9 +27,9 @@ class MergeJob(BaseModel): error_state: JobState | None = None messages: list[Any] | None = None - def error(self, current_state, message): - self.error_state = current_state + def error(self, messages): + self.error_state = self.state self.state = JobState.COMPLETED_ERROR if self.messages is None: self.messages = [] - self.messages.append(message) + self.messages.extend(messages) diff --git a/domain-ee/ee-ep-merge-app/src/python_src/service/ep_merge_machine.py b/domain-ee/ee-ep-merge-app/src/python_src/service/ep_merge_machine.py index 155c58e8bc..badc1051c5 100644 --- a/domain-ee/ee-ep-merge-app/src/python_src/service/ep_merge_machine.py +++ b/domain-ee/ee-ep-merge-app/src/python_src/service/ep_merge_machine.py @@ -2,8 +2,15 @@ import logging from typing import Type +from fastapi.encoders import jsonable_encoder from hoppy.exception import ResponseException -from model import cancel_claim, create_contentions, get_claim, get_contentions +from model import ( + add_claim_note, + cancel_claim, + create_contentions, + get_claim, + get_contentions, +) from model import update_temp_station_of_jurisdiction as tsoj from model.merge_job import JobState, MergeJob from model.request import GeneralRequest @@ -30,6 +37,7 @@ class EpMergeMachine(StateMachine): running_merge_contentions = State(value=JobState.RUNNING_MERGE_CONTENTIONS) running_move_contentions_to_pending_claim = State(value=JobState.RUNNING_MOVE_CONTENTIONS_TO_PENDING_CLAIM) running_cancel_ep400_claim = State(value=JobState.RUNNING_CANCEL_EP400_CLAIM) + running_add_claim_note_to_ep400 = State(value=JobState.RUNNING_ADD_CLAIM_NOTE_TO_EP400) completed_success = State(final=True, value=JobState.COMPLETED_SUCCESS) completed_error = State(final=True, value=JobState.COMPLETED_ERROR) @@ -48,8 +56,10 @@ class EpMergeMachine(StateMachine): | running_merge_contentions.to(completed_error, cond="has_error") | running_move_contentions_to_pending_claim.to(running_cancel_ep400_claim, unless="has_error") | running_move_contentions_to_pending_claim.to(completed_error, cond="has_error") - | running_cancel_ep400_claim.to(completed_success, unless="has_error") + | running_cancel_ep400_claim.to(running_add_claim_note_to_ep400, unless="has_error") | running_cancel_ep400_claim.to(completed_error, cond="has_error") + | running_add_claim_note_to_ep400.to(completed_success, unless="has_error") + | running_add_claim_note_to_ep400.to(completed_error, cond="has_error") ) def __init__(self, merge_job: MergeJob): @@ -138,6 +148,16 @@ def on_cancel_ep400_claim(self): response_type=cancel_claim.Response) self.process() + @running_add_claim_note_to_ep400.enter + def on_add_claim_note_to_ep400(self): + request = add_claim_note.Request(vbms_claim_id=self.job.ep400_claim_id, + claim_notes=[self.cancellation_reason]) + self.make_request( + request=request, + hoppy_client=HOPPY.get_client(ClientName.BGS_ADD_CLAIM_NOTE), + response_type=add_claim_note.Response) + self.process() + @completed_success.enter @completed_error.enter def on_completed(self, state): @@ -180,5 +200,5 @@ def log_error(self, error): f"pending_claim_id={self.job.pending_claim_id} " f"ep400_claim_id={self.job.ep400_claim_id} " f"state={self.job.state} " - f"error=\'{error}\'") - self.job.error(self.job.state, error) + f"error=\"{jsonable_encoder(error)}\"") + self.job.error(error if isinstance(error, list) else [error]) diff --git a/domain-ee/ee-ep-merge-app/src/python_src/service/hoppy_service.py b/domain-ee/ee-ep-merge-app/src/python_src/service/hoppy_service.py index 1b132cff35..a68928fdb1 100644 --- a/domain-ee/ee-ep-merge-app/src/python_src/service/hoppy_service.py +++ b/domain-ee/ee-ep-merge-app/src/python_src/service/hoppy_service.py @@ -1,6 +1,6 @@ import asyncio -from config import EXCHANGE, QUEUES, REPLY_QUEUES, ClientName, config +from config import EXCHANGES, QUEUES, REPLY_QUEUES, ClientName, config from hoppy.async_hoppy_client import RetryableAsyncHoppyClient from hoppy.hoppy_properties import ExchangeProperties, QueueProperties @@ -8,19 +8,20 @@ class HoppyService: clients = {} - exchange_props = ExchangeProperties(name=EXCHANGE, - passive_declare=False) - def __init__(self): self.create_client(ClientName.GET_CLAIM) self.create_client(ClientName.GET_CLAIM_CONTENTIONS) self.create_client(ClientName.PUT_TSOJ) self.create_client(ClientName.CREATE_CLAIM_CONTENTIONS) self.create_client(ClientName.CANCEL_CLAIM) + self.create_client(ClientName.BGS_ADD_CLAIM_NOTE) def create_client(self, name): + exchange = EXCHANGES[name] req_queue = QUEUES[name] reply_queue = REPLY_QUEUES[name] + exchange_props = ExchangeProperties(name=exchange, + passive_declare=False) request_queue_props = QueueProperties(name=req_queue, passive_declare=False) reply_queue_props = QueueProperties(name=reply_queue, @@ -28,7 +29,7 @@ def create_client(self, name): client = RetryableAsyncHoppyClient(name=name.value, app_id=config["app_id"], config=config, - exchange_properties=self.exchange_props, + exchange_properties=exchange_props, request_queue_properties=request_queue_props, request_routing_key=req_queue, reply_queue_properties=reply_queue_props, diff --git a/domain-ee/ee-ep-merge-app/tests/service/test_merge_machine.py b/domain-ee/ee-ep-merge-app/tests/service/test_merge_machine.py index 60971fd3dc..8c7f270db6 100644 --- a/domain-ee/ee-ep-merge-app/tests/service/test_merge_machine.py +++ b/domain-ee/ee-ep-merge-app/tests/service/test_merge_machine.py @@ -5,7 +5,13 @@ import pytest from hoppy.exception import ResponseException -from model import cancel_claim, create_contentions, get_claim, get_contentions +from model import ( + add_claim_note, + cancel_claim, + create_contentions, + get_claim, + get_contentions, +) from model import update_temp_station_of_jurisdiction as tsoj from model.claim import ClaimDetail from model.merge_job import JobState, MergeJob @@ -20,6 +26,7 @@ PENDING_CLAIM_ID = 1 PENDING_CLAIM_EP_CODE = "010" EP400_CLAIM_ID = 2 +cancel_reason = CANCELLATION_REASON_FORMAT.format(ep_code=PENDING_CLAIM_EP_CODE, claim_id=PENDING_CLAIM_ID) RESPONSE_DIR = os.path.abspath('./tests/responses') response_200 = f'{RESPONSE_DIR}/200_response.json' @@ -62,11 +69,12 @@ def load_response(file, response_type): create_contentions_on_pending_claim_201 = load_response(response_201, create_contentions.Response) cancel_ep400_claim_req = cancel_claim.Request(claim_id=EP400_CLAIM_ID, lifecycle_status_reason_code=CANCEL_TRACKING_EP, - close_reason_text=CANCELLATION_REASON_FORMAT.format( - ep_code=PENDING_CLAIM_EP_CODE, - claim_id=PENDING_CLAIM_ID) + close_reason_text=cancel_reason ).model_dump(by_alias=True) cancel_claim_200 = load_response(response_200, cancel_claim.Response) +add_claim_note_req = add_claim_note.Request(vbms_claim_id=EP400_CLAIM_ID, + claim_notes=[cancel_reason]).model_dump(by_alias=True) +add_claim_note_200 = load_response(response_200, add_claim_note.Response) @pytest.fixture(autouse=True) @@ -262,6 +270,34 @@ def test_invalid_request_at_cancel_claim_due_to_exception(machine, mock_hoppy_as ]) +@pytest.mark.parametrize("invalid_request", + [ + pytest.param(ResponseException("Oops"), id="Caught Exception"), + pytest.param(load_response(response_400, add_claim_note.Response), id="400"), + pytest.param(load_response(response_500, add_claim_note.Response), id="500") + ]) +def test_invalid_request_at_add_claim_note_due_to_exception(machine, mock_hoppy_async_client, invalid_request): + mock_async_responses(mock_hoppy_async_client, + [ + get_pending_claim_200, + get_pending_contentions_200, + get_ep400_contentions_200, + update_temporary_station_of_duty_200, + create_contentions_on_pending_claim_201, + cancel_claim_200, + invalid_request + ]) + process_and_assert(machine, JobState.COMPLETED_ERROR, JobState.RUNNING_ADD_CLAIM_NOTE_TO_EP400) + mock_hoppy_async_client.make_request.assert_has_calls([ + call(machine.job.job_id, get_pending_contentions_req), + call(machine.job.job_id, get_ep400_contentions_req), + call(machine.job.job_id, update_temporary_station_of_duty_req), + call(machine.job.job_id, create_contentions_on_pending_claim_req), + call(machine.job.job_id, cancel_ep400_claim_req), + call(machine.job.job_id, add_claim_note_req) + ]) + + @pytest.mark.parametrize("get_contentions_res", [ pytest.param( @@ -293,7 +329,8 @@ def test_process_succeeds_with_different_contention(machine, mock_hoppy_async_cl ep400_contentions, update_temporary_station_of_duty_200, create_contentions_on_pending_claim_201, - cancel_claim_200 + cancel_claim_200, + add_claim_note_200 ]) process_and_assert(machine, JobState.COMPLETED_SUCCESS, None) mock_hoppy_async_client.make_request.assert_has_calls([ @@ -312,7 +349,8 @@ def test_process_succeeds_with_duplicate_contention(machine, mock_hoppy_async_cl get_pending_contentions_increase_tinnitus_200, get_ep400_contentions_200, update_temporary_station_of_duty_200, - cancel_claim_200 + cancel_claim_200, + add_claim_note_200 ]) process_and_assert(machine, JobState.COMPLETED_SUCCESS, None) mock_hoppy_async_client.make_request.assert_has_calls([