diff --git a/pyproject.toml b/pyproject.toml index c1e5e47c..26ea194a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -79,8 +79,8 @@ env = [ "FS_DOWNLOAD_CONFIG__PROTOCOL=file", "ENV=TEST", "MAIL_API_URL=http://mail-api:8765/internal/confirmation/send", - 'REQUEST_VALIDATORS__SIGN_AND_SUBMIT=["check_lei_status","check_lei_tin","check_filing_not_exists","check_sub_accepted","check_voluntary_filer","check_contact_info"]', - 'REQUEST_VALIDATORS__FILING_CREATE=["check_period_not_exists", "check_filing_exists"]' + 'REQUEST_VALIDATORS__SIGN_AND_SUBMIT=["valid_lei_status","valid_lei_tin","valid_filing_exists","valid_sub_accepted","valid_voluntary_filer","valid_contact_info"]', + 'REQUEST_VALIDATORS__FILING_CREATE=["valid_period_exists", "valid_no_filing_exists"]' ] testpaths = ["tests"] diff --git a/src/.env.local b/src/.env.local index 7d483c6f..fd070a49 100644 --- a/src/.env.local +++ b/src/.env.local @@ -21,5 +21,5 @@ FS_UPLOAD_CONFIG__ROOT="../upload" EXPIRED_SUBMISSION_CHECK_SECS=120 SERVER_CONFIG__RELOAD="true" MAIL_API_URL=http://mail-api:8765/internal/confirmation/send -REQUEST_VALIDATORS__SIGN_AND_SUBMIT=["check_lei_status","check_lei_tin","check_filing_not_exists","check_sub_accepted","check_voluntary_filer","check_contact_info"] -REQUEST_VALIDATORS__FILING_CREATE=["check_period_not_exists", "check_filing_exists"] \ No newline at end of file +REQUEST_VALIDATORS__SIGN_AND_SUBMIT=["valid_lei_status","valid_lei_tin","valid_filing_exists","valid_sub_accepted","valid_voluntary_filer","valid_contact_info"] +REQUEST_VALIDATORS__FILING_CREATE=["valid_period_exists", "valid_no_filing_exists"] \ No newline at end of file diff --git a/src/sbl_filing_api/config.py b/src/sbl_filing_api/config.py index cfc6ef49..0309de73 100644 --- a/src/sbl_filing_api/config.py +++ b/src/sbl_filing_api/config.py @@ -85,15 +85,15 @@ def build_postgres_dsn(cls, postgres_dsn, info: ValidationInfo) -> Any: class RequestActionValidations(BaseSettings): sign_and_submit: Set[str] = { - "check_lei_status", - "check_lei_tin", - "check_filing_not_exists", - "check_sub_accepted", - "check_voluntary_filer", - "check_contact_info", + "valid_lei_status", + "valid_lei_tin", + "valid_filing_exists", + "valid_sub_accepted", + "valid_voluntary_filer", + "valid_contact_info", } - filing_create: Set[str] = {"check_period_not_exists", "check_filing_exists"} + filing_create: Set[str] = {"valid_period_exists", "valid_no_filing_exists"} model_config = SettingsConfigDict(env_prefix="request_validators__", env_file=env_files_to_load, extra="allow") diff --git a/src/sbl_filing_api/services/validators/filing_validators.py b/src/sbl_filing_api/services/validators/filing_validators.py index 79118b97..e615cf5d 100644 --- a/src/sbl_filing_api/services/validators/filing_validators.py +++ b/src/sbl_filing_api/services/validators/filing_validators.py @@ -6,36 +6,36 @@ log = logging.getLogger(__name__) -class CheckFilingExists(ActionValidator): +class ValidNoFilingExists(ActionValidator): def __init__(self): - super().__init__("check_filing_exists") + super().__init__("valid_no_filing_exists") def __call__(self, filing: FilingDAO, period_code: str, lei: str, **kwargs): if filing: return f"Filing already exists for Filing Period {period_code} and LEI {lei}" -class CheckFilingNotExists(ActionValidator): +class ValidFilingNotExists(ActionValidator): def __init__(self): - super().__init__("check_filing_not_exists") + super().__init__("valid_filing_exists") def __call__(self, filing: FilingDAO, lei: str, period_code: str, **kwargs): if not filing: return f"There is no Filing for LEI {lei} in period {period_code}, unable to sign a non-existent Filing." -class CheckVoluntaryFiler(ActionValidator): +class ValidVoluntaryFiler(ActionValidator): def __init__(self): - super().__init__("check_voluntary_filer") + super().__init__("valid_voluntary_filer") def __call__(self, filing: FilingDAO, **kwargs): if filing and filing.is_voluntary is None: return f"Cannot sign filing. Filing for {filing.lei} for period {filing.filing_period} does not have a selection of is_voluntary defined." -class CheckContactInfo(ActionValidator): +class ValidContactInfo(ActionValidator): def __init__(self): - super().__init__("check_contact_info") + super().__init__("valid_contact_info") def __call__(self, filing: FilingDAO, **kwargs): if filing and not filing.contact_info: diff --git a/src/sbl_filing_api/services/validators/institution_validators.py b/src/sbl_filing_api/services/validators/institution_validators.py index fb232531..038d3868 100644 --- a/src/sbl_filing_api/services/validators/institution_validators.py +++ b/src/sbl_filing_api/services/validators/institution_validators.py @@ -8,9 +8,9 @@ log = logging.getLogger(__name__) -class CheckLeiStatus(ActionValidator): +class ValidLeiStatus(ActionValidator): def __init__(self): - super().__init__("check_lei_status") + super().__init__("valid_lei_status") def __call__(self, institution: Dict[str, Any], **kwargs): try: @@ -22,9 +22,9 @@ def __call__(self, institution: Dict[str, Any], **kwargs): return "Unable to determine LEI status." -class CheckLeiTin(ActionValidator): +class ValidLeiTin(ActionValidator): def __init__(self): - super().__init__("check_lei_tin") + super().__init__("valid_lei_tin") def __call__(self, institution: Dict[str, Any], **kwargs): if not (institution and institution.get("tax_id")): diff --git a/src/sbl_filing_api/services/validators/period_validators.py b/src/sbl_filing_api/services/validators/period_validators.py index 7f9645c4..94d27991 100644 --- a/src/sbl_filing_api/services/validators/period_validators.py +++ b/src/sbl_filing_api/services/validators/period_validators.py @@ -6,9 +6,9 @@ log = logging.getLogger(__name__) -class CheckPeriodNotExists(ActionValidator): +class ValidPeriodExists(ActionValidator): def __init__(self): - super().__init__("check_period_not_exists") + super().__init__("valid_period_exists") def __call__(self, period: FilingPeriodDAO, period_code: str, **kwargs): if not period: diff --git a/src/sbl_filing_api/services/validators/submission_validators.py b/src/sbl_filing_api/services/validators/submission_validators.py index 1d74d623..c0ed055a 100644 --- a/src/sbl_filing_api/services/validators/submission_validators.py +++ b/src/sbl_filing_api/services/validators/submission_validators.py @@ -9,9 +9,9 @@ log = logging.getLogger(__name__) -class CheckSubAccepted(ActionValidator): +class ValidSubAccepted(ActionValidator): def __init__(self): - super().__init__("check_sub_accepted") + super().__init__("valid_sub_accepted") async def __call__(self, filing: FilingDAO, **kwargs): if filing: diff --git a/tests/services/test_request_action_validator.py b/tests/services/test_request_action_validator.py index 7e0390eb..ae3505ab 100644 --- a/tests/services/test_request_action_validator.py +++ b/tests/services/test_request_action_validator.py @@ -89,12 +89,12 @@ def log_mock(mocker: MockerFixture) -> Logger: async def test_validations_with_errors(request_mock_invalid_context: Request): run_validations = validate_user_action( { - "check_lei_status", - "check_lei_tin", - "check_filing_not_exists", - "check_sub_accepted", - "check_voluntary_filer", - "check_contact_info", + "valid_lei_status", + "valid_lei_tin", + "valid_filing_not_exists", + "valid_sub_accepted", + "valid_voluntary_filer", + "valid_contact_info", }, "Test Exception", ) @@ -121,12 +121,12 @@ async def test_validations_with_errors(request_mock_invalid_context: Request): async def test_validations_no_errors(request_mock_valid_context: Request): run_validations = validate_user_action( { - "check_lei_status", - "check_lei_tin", - "check_filing_not_exists", - "check_sub_accepted", - "check_voluntary_filer", - "check_contact_info", + "valid_lei_status", + "valid_lei_tin", + "valid_filing_exists", + "valid_sub_accepted", + "valid_voluntary_filer", + "valid_contact_info", }, "Test Exception", ) @@ -134,7 +134,7 @@ async def test_validations_no_errors(request_mock_valid_context: Request): async def test_lei_status_bad_api_res(request_mock: Request, httpx_unauthed_mock): - run_validations = validate_user_action({"check_lei_status"}, "Test Exception") + run_validations = validate_user_action({"valid_lei_status"}, "Test Exception") context_setter = set_context({UserActionContext.INSTITUTION}) await context_setter(request_mock) @@ -144,7 +144,7 @@ async def test_lei_status_bad_api_res(request_mock: Request, httpx_unauthed_mock async def test_lei_status_good_api_res(request_mock: Request, httpx_authed_mock): - run_validations = validate_user_action({"check_lei_status"}, "Test Exception") + run_validations = validate_user_action({"valid_lei_status"}, "Test Exception") context_setter = set_context({UserActionContext.INSTITUTION}) await context_setter(request_mock) with pytest.raises(RegTechHttpException) as e: