def validate_party_codes(json_data): """Verify party codes exist in the database for all parties in json_data.""" error_msg = '' code = None if 'registeringParty' in json_data and 'code' in json_data['registeringParty']: code = json_data['registeringParty']['code'] if not Party.verify_party_code(code): error_msg += REGISTERING_CODE_MSG.format(code) if 'securedParties' in json_data: for party in json_data['securedParties']: if 'code' in party: code = party['code'] if not Party.verify_party_code(code): error_msg += SECURED_CODE_MSG.format(code) if 'addSecuredParties' in json_data: for party in json_data['addSecuredParties']: if 'code' in party: code = party['code'] if not Party.verify_party_code(code): error_msg += SECURED_CODE_MSG.format(code) return error_msg
def test_verify_party_code_false(session): """Assert that Party.verify_party_code works correctly with an invalid code.""" result = Party.verify_party_code('300000000') assert not result
def test_verify_party_code_true(session): """Assert that Party.verify_party_code works correctly with a valid code.""" result = Party.verify_party_code('200000000') assert result