def test_create_zero_dollar_payment_record(session, public_user_mock):
    """Assert that the payment records are created and completed."""
    payment_response = PaymentService.create_invoice(get_zero_dollar_payment_request(), get_auth_basic_user())
    account_model = PaymentAccount.find_by_auth_account_id(get_auth_basic_user().get('account').get('id'))
    account_id = account_model.id
    assert account_id is not None
    assert payment_response.get('id') is not None
    assert payment_response.get('status_code') == 'COMPLETED'
    # Create another payment with same request, the account should be the same
    PaymentService.create_invoice(get_zero_dollar_payment_request(), get_auth_basic_user())
    account_model = PaymentAccount.find_by_auth_account_id(get_auth_basic_user().get('account').get('id'))
    assert account_id == account_model.id
    assert payment_response.get('status_code') == 'COMPLETED'
def test_create_zero_dollar_payment_record(session, public_user_mock):
    """Assert that the payment records are created and completed."""
    payment_response = PaymentService.create_payment(
        get_zero_dollar_payment_request())
    account_model = PaymentAccount.find_by_corp_number_and_corp_type_and_system(
        'CP0001234', 'CP', 'INTERNAL')
    account_id = account_model.id
    assert account_id is not None
    assert payment_response.get('id') is not None
    assert payment_response.get('status_code') == 'COMPLETED'
    # Create another payment with same request, the account should be the same
    PaymentService.create_payment(get_zero_dollar_payment_request())
    account_model = PaymentAccount.find_by_corp_number_and_corp_type_and_system(
        'CP0001234', 'CP', 'INTERNAL')
    assert account_id == account_model.id
    assert payment_response.get('status_code') == 'COMPLETED'
Beispiel #3
0
def test_zero_dollar_payment_creation(session, client, jwt, app):
    """Assert that the endpoint returns 201."""
    token = jwt.create_jwt(get_claims(role='staff'), token_header)
    headers = {
        'Authorization': f'Bearer {token}',
        'content-type': 'application/json'
    }

    rv = client.post('/api/v1/payment-requests',
                     data=json.dumps(get_zero_dollar_payment_request()),
                     headers=headers)

    assert rv.status_code == 201
    assert rv.json.get('_links') is not None
    assert rv.json.get('statusCode', None) == 'COMPLETED'

    assert schema_utils.validate(rv.json, 'invoice')[0]
Beispiel #4
0
def test_delete_completed_payment(session, client, jwt, app):
    """Assert that the endpoint returns 400."""
    token = jwt.create_jwt(get_claims(role='staff'), token_header)
    headers = {
        'Authorization': f'Bearer {token}',
        'content-type': 'application/json'
    }

    rv = client.post(f'/api/v1/payment-requests',
                     data=json.dumps(get_zero_dollar_payment_request()),
                     headers=headers)
    assert rv.status_code == 201
    assert rv.json.get('_links') is not None
    assert rv.json.get('statusCode', None) == 'COMPLETED'

    pay_id = rv.json.get('id')
    rv = client.delete(f'/api/v1/payment-requests/{pay_id}', headers=headers)
    assert rv.status_code == 400
def test_create_payment_record_with_rs(session, public_user_mock):
    """Assert that the payment records are created and completed."""
    payment_account = factory_payment_account()
    payment_account.save()
    rs = factory_routing_slip(payment_account_id=payment_account.id, total=1000, remaining_amount=1000)
    rs.save()
    cfs_response = Mock(spec=Response)
    cfs_response.json.return_value = {'invoice_number': 'abcde', }
    cfs_response.status_code = 200

    request = get_payment_request()
    request['accountInfo'] = {'routingSlip': rs.number}
    with patch.object(CFSService, 'create_account_invoice', return_value=cfs_response) as mock_post:
        PaymentService.create_invoice(request, get_auth_basic_user())
        mock_post.assert_called()

    request = get_zero_dollar_payment_request()
    request['accountInfo'] = {'routingSlip': rs.number}
    with patch.object(CFSService, 'create_account_invoice', return_value=cfs_response) as mock_post:
        PaymentService.create_invoice(request, get_auth_basic_user())
        mock_post.assert_not_called()
Beispiel #6
0
def test_receipt_creation_for_internal_payments(session, client, jwt, app):
    """Assert that the endpoint returns 201."""
    token = jwt.create_jwt(get_claims(app_request=app), token_header)
    headers = {
        'Authorization': f'Bearer {token}',
        'content-type': 'application/json'
    }

    rv = client.post('/api/v1/payment-requests',
                     data=json.dumps(get_zero_dollar_payment_request()),
                     headers=headers)
    pay_id = rv.json.get('id')

    filing_data = {
        'corpName': 'CP0001234',
        'filingDateTime': 'June 27, 2019',
        'fileName': 'director-change'
    }
    rv = client.post(f'/api/v1/payment-requests/{pay_id}/receipts',
                     data=json.dumps(filing_data),
                     headers=headers)
    assert rv.status_code == 201