Skip to content

Commit

Permalink
- Updated return type of decorators
Browse files Browse the repository at this point in the history
- Updated test and removed print
  • Loading branch information
elipe17 committed Dec 20, 2024
1 parent 2c7ab0d commit 7757a46
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -647,14 +647,13 @@ def test_deprecate__WORK_ELIGIBLE_INDICATOR__HOH__AGE():
'RPT_MONTH_YEAR': '202010',
}
result = deprecate_call(category3.validate__WORK_ELIGIBLE_INDICATOR__HOH__AGE())(instance, schema)
print(result)
assert result == [
assert result == (
False,
'T1: Since Item 1 (work eligible indicator) is 11 and Item 3 (Age) is less than 19, '
'then Item 2 (relationship w/ head of household) must not be 1.',
['WORK_ELIGIBLE_INDICATOR', 'RELATIONSHIP_HOH', 'DATE_OF_BIRTH'],
True
]
)
instance['DATE_OF_BIRTH'] = '19950101'
result = category3.validate__WORK_ELIGIBLE_INDICATOR__HOH__AGE()(instance, schema)
assert result == (True, None, ['WORK_ELIGIBLE_INDICATOR', 'RELATIONSHIP_HOH', 'DATE_OF_BIRTH'], False)
Expand Down
14 changes: 8 additions & 6 deletions tdrs-backend/tdpservice/parsers/validators/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,10 @@ def wrapper(*args, **kwargs):

def deprecated_validator(*args, **kwargs):
make_val = validator(*wrapper_args, **wrapper_kwargs)
is_valid, error, _ = make_val(*args, **kwargs)
return (is_valid, error, True)
result = []
result.extend(make_val(*args, **kwargs))
result[-1] = True
return tuple(result)
return deprecated_validator
return wrapper

Expand All @@ -55,10 +57,10 @@ def deprecate_call(validator):
`deprecate_call(category1.recordHasLengthBetween(117, 156))`.
"""
def deprecated_validator(*args, **kwargs):
ret = []
ret.extend(validator(*args, **kwargs))
ret[-1] = True
return ret
result = []
result.extend(validator(*args, **kwargs))
result[-1] = True
return tuple(result)
return deprecated_validator


Expand Down

0 comments on commit 7757a46

Please sign in to comment.