Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added filing validators class, rearranged code #530

Merged
merged 4 commits into from
Dec 12, 2024

Conversation

jcadam14
Copy link
Contributor

@jcadam14 jcadam14 commented Dec 9, 2024

Closes #529

@jcadam14 jcadam14 self-assigned this Dec 9, 2024
@jcadam14 jcadam14 linked an issue Dec 9, 2024 that may be closed by this pull request
Copy link

github-actions bot commented Dec 9, 2024

Coverage report

Click to see where and how coverage changed

FileStatementsMissingCoverageCoverage
(new stmts)
Lines missing
  src/sbl_filing_api
  config.py
  src/sbl_filing_api/routers
  filing.py
  src/sbl_filing_api/services
  request_action_validator.py
  src/sbl_filing_api/services/validators
  base_validator.py
  filing_validators.py
  institution_validators.py
  period_validators.py
  submission_validators.py
Project Total  

This report was generated by python-coverage-comment-action

Comment on lines 18 to 20
class CheckPeriodFilingExists(ActionValidator):
def __init__(self):
super().__init__("check_period_filing_exists")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe this one should be something like period filing not started; at the moment it has the same naming convention as period exists above, but it's the opposite logic as what's above.

Copy link
Contributor Author

@jcadam14 jcadam14 Dec 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The point is to check if a filing already exists for that period and if it does fail. So the two checks when starting a filing are:

  • does the period exist, if not fail
  • does a filing already exist for that period, if so fail

I had to name it something different from the sign "check_filing_exists" which has the reverse logic, it fails to sign if a the filing for that period + LEI doesn't exist yet. But since all the validators get put into one registry, I needed a different name (key) in the registry map. Naming is definitely something an issue we could run up against and is something I thought that maybe sticking all the validator subs into one file might help, but then that could potentially get very large. But I also though of moving your signing "check_filing_exists" into this filing_validators.py and naming it like "check_filing_not_exists" (since that's what it is doing) and have this one be "check_filing_exists".

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeap, I like the check_filing_exits, and check_filing_not_exists into filing_validator; just wanting to have the name to be what the function actually does.

@jcadam14 jcadam14 requested a review from lchen-2101 December 10, 2024 20:48
Comment on lines 9 to 24
class CheckFilingExists(ActionValidator):
def __init__(self):
super().__init__("check_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):
def __init__(self):
super().__init__("check_filing_not_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."
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These 2's name and logic are flipped compared to the voluntary filer, and contact info checks. My initial thought of these function names are passing conditions instead of failing conditions. We probably should rename all the checks to be more explicit then, like FailIfFilingExists and FailIfFilingNotExists; or maybe InvalidIfFilingExists, etc. if we want to make them pass conditions: ValidIfFilingExists, etc.; and we can make the other validators names explicit as well, i.e. ValidVoluntaryFilerStatus, or InvalidVoluntaryFilerStatus, etc.

Comment on lines 18 to 20
class ValidFilingNotExists(ActionValidator):
def __init__(self):
super().__init__("valid_filing_exists")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

name attribute and class name not matching

Copy link
Collaborator

@lchen-2101 lchen-2101 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@lchen-2101 lchen-2101 merged commit fb9c867 into main Dec 12, 2024
5 checks passed
@lchen-2101 lchen-2101 deleted the 529-update-post-filing-to-use-validator branch December 12, 2024 14:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Update post filing to use validator
2 participants