Skip to content

Commit

Permalink
Changed name of checks to be positive Valid*
Browse files Browse the repository at this point in the history
  • Loading branch information
jcadam14 committed Dec 11, 2024
1 parent dbb42d2 commit dbd7e3f
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 41 deletions.
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]

Expand Down
4 changes: 2 additions & 2 deletions src/.env.local
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
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"]
14 changes: 7 additions & 7 deletions src/sbl_filing_api/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down
16 changes: 8 additions & 8 deletions src/sbl_filing_api/services/validators/filing_validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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")):
Expand Down
4 changes: 2 additions & 2 deletions src/sbl_filing_api/services/validators/period_validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
28 changes: 14 additions & 14 deletions tests/services/test_request_action_validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
)
Expand All @@ -121,20 +121,20 @@ 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",
)
await run_validations(request_mock_valid_context)


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)

Expand All @@ -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:
Expand Down

0 comments on commit dbd7e3f

Please sign in to comment.