Skip to content

Commit

Permalink
fs-3530 removing eoi from decision naming (#135)
Browse files Browse the repository at this point in the history
* fs-3530 removing eoi from decision naming

* Update version to 2.0.45

---------

Co-authored-by: FSD Github Actions <[email protected]>
  • Loading branch information
srh-sloan and FSD Github Actions authored Apr 12, 2024
1 parent 3040ef6 commit 65446a7
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 70 deletions.
8 changes: 4 additions & 4 deletions fsd_utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
from fsd_utils.config.commonconfig import CommonConfig # noqa
from fsd_utils.config.configclass import configclass # noqa
from fsd_utils.config.notify_constants import NotifyConstants # noqa
from fsd_utils.eoi.evaluate_eoi_response import Eoi_Decision
from fsd_utils.eoi.evaluate_eoi_response import evaluate_eoi_response
from fsd_utils.decision.evaluate_response_against_schema import Decision
from fsd_utils.decision.evaluate_response_against_schema import evaluate_response
from fsd_utils.locale_selector.set_lang import LanguageSelector
from fsd_utils.mapping.application.application_utils import generate_text_of_application
from fsd_utils.mapping.application.qa_mapping import (
Expand All @@ -34,7 +34,7 @@
toggles,
generate_text_of_application,
extract_questions_and_answers,
evaluate_eoi_response,
Eoi_Decision,
evaluate_response,
Decision,
services,
]
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from enum import IntEnum


class Eoi_Decision(IntEnum):
class Decision(IntEnum):
PASS = 0
PASS_WITH_CAVEATS = 1
FAIL = 2
Expand All @@ -12,7 +12,7 @@ class Eoi_Decision(IntEnum):

def _evaluate_with_supplied_operators(
conditions_to_evaluate: list, supplied_answer: any
) -> tuple[Eoi_Decision, list]:
) -> tuple[Decision, list]:
"""Evaluates an expression built from the operator in the schmea, the value to compare, and the supplied answer.
Uses the result of the evaluation to return a decision and applicable caveats
Casts the value to an integer for comparison
Expand All @@ -26,9 +26,9 @@ def _evaluate_with_supplied_operators(
cannot be converted to a float
Returns:
tuple[Eoi_Decision, list]: Tuple of the decision and the caveats (if there are any)
tuple[Decision, list]: Tuple of the decision and the caveats (if there are any)
"""
decision = Eoi_Decision.PASS
decision = Decision.PASS
caveats = []
for ec in conditions_to_evaluate:
# validate supplied operator
Expand All @@ -54,26 +54,26 @@ def _evaluate_with_supplied_operators(
if ec["caveat"]:
caveats.append(ec["caveat"])

if decision == Eoi_Decision.FAIL:
if decision == Decision.FAIL:
return decision, [] # don't return caveats for failure
else:
return decision, caveats


def evaluate_eoi_response(schema: dict, forms: dict) -> dict:
"""Takes in an EOI schema and a set of forms containing responses, then makes a decision on the EOI outcome
def evaluate_response(schema: dict, forms: dict) -> dict:
"""Takes in a decision schema and a set of forms containing responses, then makes a decision on the outcome
Args:
schema (dict): Schema defining decisions based on answers
forms (dict): Response forms in form-builder json format
Returns:
dict: Results of decision:
decision: value of Eoi_Decision ENUM
decision: value of Decision ENUM
caveats: list of strings of caveats for answers if decision is 'Pass with caveats', otherwise empty list
"""
result = {"decision": Eoi_Decision.PASS, "caveats": []}
result = {"decision": Decision.PASS, "caveats": []}

# Loop through every form, then every response in that form
for form in forms:
Expand Down Expand Up @@ -112,7 +112,7 @@ def evaluate_eoi_response(schema: dict, forms: dict) -> dict:
result["caveats"] += caveats

# If we failed on this question, we don't need to evaluate any further, just return a fail
if result["decision"] == Eoi_Decision.FAIL:
return {"decision": Eoi_Decision.FAIL, "caveats": []}
if result["decision"] == Decision.FAIL:
return {"decision": Decision.FAIL, "caveats": []}

return result
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ build-backend = "setuptools.build_meta"
[project]
name = "funding-service-design-utils"

version = "2.0.44"
version = "2.0.45"

authors = [
{ name="DLUHC", email="[email protected]" },
Expand Down
Loading

0 comments on commit 65446a7

Please sign in to comment.