Skip to content

Commit

Permalink
EP Merge: Special Issue Code workaround for testing (#2645)
Browse files Browse the repository at this point in the history
Made special issue code an environment variable, so it can be switched without code change.
  • Loading branch information
dfitchett authored Feb 23, 2024
1 parent 422f591 commit 8c8a89c
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 8 deletions.
3 changes: 2 additions & 1 deletion domain-ee/ee-ep-merge-app/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ testpaths = [
]
env = [
"REQUEST_TIMEOUT = 1",
"REQUEST_RETRIES = 1"
"REQUEST_RETRIES = 1",
"EP_MERGE_SPECIAL_ISSUE_CODE = TEST"
]
2 changes: 2 additions & 0 deletions domain-ee/ee-ep-merge-app/src/python_src/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ class ClientName(str, Enum):
ClientName.BGS_ADD_CLAIM_NOTE: os.environ.get("ADD_CLAIM_NOTE_RESPONSE") or "add-note-response",
}

EP_MERGE_SPECIAL_ISSUE_CODE = os.environ.get("EP_MERGE_SPECIAL_ISSUE_CODE") or "EMP"


def create_sqlalchemy_db_uri():
user = quote(os.environ.get("POSTGRES_USER") or "vro_user")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from hoppy.async_hoppy_client import AsyncHoppyClient
from hoppy.exception import ResponseException
from pydantic import ValidationError
from config import EP_MERGE_SPECIAL_ISSUE_CODE
from schema import (
add_claim_note,
cancel_claim,
Expand Down Expand Up @@ -40,7 +41,6 @@

CANCEL_TRACKING_EP = "60"
CANCELLATION_REASON_FORMAT = "Issues moved into or confirmed in pending EP{ep_code} - claim #{claim_id}"
SPECIAL_ISSUE_CODE = "EMP"


class Workflow(str, Enum):
Expand Down Expand Up @@ -168,7 +168,12 @@ def on_get_pending_contentions(self, event):
@running_get_ep400_contentions.enter
def on_get_ep400_contentions(self, event, pending_contentions_response=None):
request = get_contentions.Request(claim_id=self.job.ep400_claim_id)
response = self.make_request(request=request, hoppy_client=HOPPY.get_client(ClientName.GET_CLAIM_CONTENTIONS), response_type=get_contentions.Response, expected_statuses=[200, 204])
response = self.make_request(
request=request,
hoppy_client=HOPPY.get_client(ClientName.GET_CLAIM_CONTENTIONS),
response_type=get_contentions.Response,
expected_statuses=[200, 204],
)
self.send(event=event, pending_contentions_response=pending_contentions_response, ep400_contentions_response=response)

@running_set_temp_station_of_jurisdiction.enter
Expand All @@ -191,7 +196,10 @@ def on_merge_contentions(self, event, pending_contentions_response=None, ep400_c
def on_move_contentions_to_pending_claim(self, event, new_contentions=None, ep400_contentions_response=None):
request = create_contentions.Request(claim_id=self.job.pending_claim_id, create_contentions=new_contentions)
self.make_request(
request=request, hoppy_client=HOPPY.get_client(ClientName.CREATE_CLAIM_CONTENTIONS), response_type=create_contentions.Response, expected_statuses=201
request=request,
hoppy_client=HOPPY.get_client(ClientName.CREATE_CLAIM_CONTENTIONS),
response_type=create_contentions.Response,
expected_statuses=201,
)
self.send(event=event, ep400_contentions_response=ep400_contentions_response)

Expand Down Expand Up @@ -230,7 +238,7 @@ def on_pre_cancel_step_failed_remove_special_issue_code(self, event, ep400_conte
updates = []
for contention in ContentionsUtil.to_existing_contentions(contentions):
contention.special_issue_codes = (
[code for code in contention.special_issue_codes if code != SPECIAL_ISSUE_CODE] if contention.special_issue_codes else None
[code for code in contention.special_issue_codes if code != EP_MERGE_SPECIAL_ISSUE_CODE] if contention.special_issue_codes else None
)
updates.append(contention)

Expand Down Expand Up @@ -291,7 +299,9 @@ def log_metrics(self, job_duration):
if self.skipped_merge:
increment(JOB_SKIPPED_MERGE_METRIC)

def make_request(self, request: GeneralRequest, hoppy_client: AsyncHoppyClient, response_type: Type[GeneralResponse], expected_statuses: list[int] | int = 200):
def make_request(
self, request: GeneralRequest, hoppy_client: AsyncHoppyClient, response_type: Type[GeneralResponse], expected_statuses: list[int] | int = 200
):
if not isinstance(expected_statuses, list):
expected_statuses = [expected_statuses]
try:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
"contentionId": 2,
"lastModified": "2023-09-30T00:00:00-06:00",
"specialIssueCodes": [
"EMP"
]
}
]
Expand Down
5 changes: 4 additions & 1 deletion domain-ee/ee-ep-merge-app/tests/service/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from unittest.mock import ANY, AsyncMock, call

import pytest
from src.python_src.config import EP_MERGE_SPECIAL_ISSUE_CODE
from schema import (
add_claim_note,
cancel_claim,
Expand Down Expand Up @@ -64,8 +65,10 @@ def load_response(file, response_type):
get_pending_contentions_increase_tinnitus_200 = load_response(pending_contentions_increase_tinnitus_200, get_contentions.Response)
get_ep400_contentions_req = get_contentions.Request(claim_id=EP400_CLAIM_ID).model_dump(by_alias=True)
get_ep400_contentions_200 = load_response(ep400_contentions_increase_tinnitus_200, get_contentions.Response)
# Add special issue code to contention from config
get_ep400_contentions_200.contentions[0].special_issue_codes.append(EP_MERGE_SPECIAL_ISSUE_CODE)
get_ep400_contentions_204 = load_response(response_204, get_contentions.Response)
get_ep400_contentions_without_special_issues_200 = load_response(ep400_contentions_increase_tinnitus_without_special_issues_200, get_contentions.Response)
get_ep400_contentions_without_special_issues_200 = load_response(ep400_contentions_increase_tinnitus_200, get_contentions.Response)
update_temporary_station_of_jurisdiction_req = tsoj.Request(claim_id=EP400_CLAIM_ID, temp_station_of_jurisdiction="398").model_dump(by_alias=True)
revert_temporary_station_of_jurisdiction_req = tsoj.Request(claim_id=EP400_CLAIM_ID, temp_station_of_jurisdiction="111").model_dump(by_alias=True)
update_temporary_station_of_jurisdiction_200 = load_response(response_200, tsoj.Response)
Expand Down

0 comments on commit 8c8a89c

Please sign in to comment.