Skip to content

Commit

Permalink
update goodStanding validator for search_api and add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Patrick Wang authored and Patrick Wang committed Sep 15, 2023
1 parent 8667477 commit 0e1bbf1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
6 changes: 3 additions & 3 deletions search-api/src/search_api/services/validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,9 @@ def validate_solr_update_request(request_json: dict): # pylint: disable=too-man

good_standing_path = '/business/goodStanding'
good_standing = get_str(request_json, good_standing_path)

if good_standing is not None and good_standing not in ['true', 'false']:
err.append({'error': 'Good standing must be "true" or "false".', 'path': good_standing_path})
if good_standing is not None:
if not (good_standing == 'None' or good_standing.lower() == 'true' or good_standing.lower() == 'false'):
err.append({'error': 'Good standing must be a valid boolean value', 'path': good_standing_path})

Check warning on line 86 in search-api/src/search_api/services/validator.py

View check run for this annotation

Codecov / codecov/patch

search-api/src/search_api/services/validator.py#L86

Added line #L86 was not covered by tests

for index, party in enumerate(request_json.get('parties', [])):

Expand Down
6 changes: 5 additions & 1 deletion search-api/tests/unit/api/internal/test_update_solr.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,12 @@ def test_update_business_in_solr(session, client, jwt, mocker):
@integration_solr
@pytest.mark.parametrize('test_name, legal_name, good_standing, tax_id', [
('remove-tax-id', 'ABCD Prop', 'true', None),
('update-good-standing', 'ABCD Prop', 'false', '123456789'),
('update-legal-name', 'ABCDE Prop', 'true', '123456789'),
('update-good-standing-string-false', 'ABCD Prop', 'false', '123456789'),
('update-good-standing-string-true', 'ABCD Prop', 'true', '123456789'),
('update-good-standing-boolean-false', 'ABCD Prop', False, '123456789'),
('update-good-standing-boolean-true', 'ABCD Prop', True, '123456789'),
('update-good-standing-none', 'ABCD Prop', None, '123456789'),
])
def test_update_business_in_solr_with_varying_data(session, client, jwt, mocker, test_name, legal_name, good_standing, tax_id):
"""Assert that update operation is successful."""
Expand Down

0 comments on commit 0e1bbf1

Please sign in to comment.