def test_validate_nr_consent_required_received(): """Assert that nr mock data is conditionally approved and consent was received.""" validation_result = namex.validate_nr(nr_consent_required_received) assert validation_result['is_consumable'] assert validation_result['is_approved'] assert not validation_result['is_expired'] assert validation_result['consent_required'] assert validation_result['consent_received']
def test_validate_nr_already_consumed(): """Assert that nr mock data has already been consumed.""" validation_result = namex.validate_nr(nr_already_consumed) assert not validation_result['is_consumable'] assert not validation_result['is_approved'] assert not validation_result['is_expired'] assert not validation_result['consent_required'] assert not validation_result['consent_received']
def test_validate_nr_not_consumable_expired(): """Assert that nr mock data is not consumable as it has expired.""" validation_result = namex.validate_nr(nr_not_consumable_expired) assert not validation_result['is_consumable'] assert not validation_result['is_approved'] assert validation_result['is_expired'] assert not validation_result['consent_required'] assert not validation_result['consent_received']
def test_validate_nr_consent_required_not_received(): """Assert that nr mock data is conditionally approved, but consent not received.""" nr_consent_required = copy.deepcopy(nr_consumable_conditional) nr_consent_required['consentFlag'] = 'Y' validation_result = namex.validate_nr(nr_consent_required) assert not validation_result['is_consumable'] assert validation_result['is_approved'] assert not validation_result['is_expired'] assert validation_result['consent_required'] assert not validation_result['consent_received']
def test_validate_nr_consent_required_received(): """Assert that nr mock data is conditionally approved and consent was received.""" validation_result = namex.validate_nr(nr_consumable_conditional) assert validation_result['is_consumable'] assert validation_result['is_approved'] assert not validation_result['is_expired'] assert validation_result['consent_required'] assert validation_result['consent_received'] # N = consent waived nr_consent_waived = copy.deepcopy(nr_consumable_conditional) nr_consent_waived['consentFlag'] = 'N' validation_result = namex.validate_nr(nr_consent_waived) assert validation_result['is_consumable'] assert validation_result['is_approved'] assert not validation_result['is_expired'] assert not validation_result['consent_required'] assert not validation_result['consent_received'] # None = consent not required nr_consent_not_required = copy.deepcopy(nr_consumable_conditional) nr_consent_not_required['consentFlag'] = None validation_result = namex.validate_nr(nr_consent_not_required) assert validation_result['is_consumable'] assert validation_result['is_approved'] assert not validation_result['is_expired'] assert not validation_result['consent_required'] assert not validation_result['consent_received'] nr_consent_not_required = copy.deepcopy(nr_consumable_conditional) nr_consent_not_required['consentFlag'] = '' validation_result = namex.validate_nr(nr_consent_not_required) assert validation_result['is_consumable'] assert validation_result['is_approved'] assert not validation_result['is_expired'] assert not validation_result['consent_required'] assert not validation_result['consent_received']
def get(identifier): """Return a JSON object with meta information about the Service.""" business = Business.find_by_identifier(identifier) is_nr = identifier.startswith('NR') # Check if this is a NR if is_nr: # Fetch NR Data nr_response = namex.query_nr_number(identifier) # Validate NR data validation_result = namex.validate_nr(nr_response.json()) # Return error if the NR is not consumable (invalid) if not validation_result['is_consumable']: return jsonify({ 'message': f'{identifier} is invalid', 'validation': validation_result }), HTTPStatus.FORBIDDEN if not business: # Create Incorporate using NR to-do item if is_nr: rv = [] rv.append( TaskListResource.create_incorporate_nr_todo( nr_response.json(), 1, True)) # business does not exist and not an nr so return empty task list else: rv = [] else: rv = TaskListResource.construct_task_list(business) if not rv and is_nr: paid_completed_filings = Filing.get_filings_by_status( business.id, [Filing.Status.PAID.value, Filing.Status.COMPLETED.value]) # Append NR todo if there are no tasks and PAID or COMPLETED filings if not paid_completed_filings: rv.append( TaskListResource.create_incorporate_nr_todo( nr_response.json(), 1, True)) elif rv == 'pay_connection_error': return { 'message': 'Failed to get payment details for a filing. Please try again later.' }, HTTPStatus.SERVICE_UNAVAILABLE return jsonify(tasks=rv)
def company_name_validation(filing): """Validate share structure.""" msg = [] nr_path: Final = '/filing/alteration/nameRequest/nrNumber' if nr_number := get_str(filing, nr_path): # ensure NR is approved or conditionally approved nr_response = namex.query_nr_number(nr_number) validation_result = namex.validate_nr(nr_response) if not nr_response['requestTypeCd'] in ('CCR', 'CCP', 'BEC'): msg.append({ 'error': babel( 'Alteration only available for Change of Name Name requests.' ), 'path': nr_path }) if not validation_result['is_approved']: msg.append({ 'error': babel('Alteration of Name Request is not approved.'), 'path': nr_path }) # ensure NR request has the same legal name legal_name_path: Final = '/filing/alteration/nameRequest/legalName' legal_name = get_str(filing, legal_name_path) nr_name = namex.get_approved_name(nr_response) if nr_name != legal_name: msg.append({ 'error': babel( 'Alteration of Name Request has a different legal name.'), 'path': legal_name_path })