Example #1
0
def test_metrics_detailed_view(orderBy, session, client, jwt, app):
    token = jwt.create_jwt(get_token_body(), get_token_header())
    headers = {
        "Authorization": f"Bearer {token}",
        "content-type": "application/json"
    }

    rv = client.post("/form", headers=headers, json=get_form_request_payload())
    assert rv.status_code == 201
    form_id = rv.json.get("formId")
    mapper_id = rv.json.get("id")

    rv = client.post(
        "/application/create",
        headers=headers,
        json=get_application_create_payload(form_id),
    )
    assert rv.status_code == 201

    today = date.today().strftime("%Y-%m-%d")
    rv = client.get(
        f"/metrics/{mapper_id}?from={today}&to={today}&orderBy={orderBy}",
        headers=headers,
    )
    assert rv.status_code == 200
    assert rv.json.get("applications")
Example #2
0
def test_process_get_all_processes(client, session, jwt):
    """Test process get all processes"""
    token = jwt.create_jwt(get_token_body(), get_token_header())
    headers = {
        "Authorization": f"Bearer {token}",
        "content-type": "application/json"
    }
    response = client.get("/application", headers=headers)
    assert response.status_code == 200
Example #3
0
def test_get_profile(client, jwt, app, query_profile_mock):
    """Assert that the endpoint returns 200."""
    token = jwt.create_jwt(get_claims(role='system'), get_token_header())
    headers = {
        'content-type': 'application/json',
        'Authorization': f'Bearer {token}'
    }
    rv = client.get('/api/v1/profiles/PB25020', headers=headers)
    assert rv.status_code == 200
Example #4
0
def test_form_process_mapper_by_formid(client, jwt):
    token = jwt.create_jwt(get_token_body(), get_token_header())
    headers = {"Authorization": f"Bearer {token}", "content-type": "application/json"}
    response = client.post(
        "/form",
        headers=headers,
        json=get_form_request_payload(),
    )
    assert response.status_code == 201
    form_id = response.json.get("formId")
    rv = client.get(f"/form/formid/{form_id}", headers=headers)
    assert rv.status_code == 200
Example #5
0
def test_metrics_get_200(orderBy, session, client, jwt, app):
    token = jwt.create_jwt(get_token_body(), get_token_header())
    headers = {
        "Authorization": f"Bearer {token}",
        "content-type": "application/json"
    }

    today = date.today().strftime("%Y-%m-%d")
    rv = client.get(f"/metrics?from={today}&to={today}&orderBy={orderBy}",
                    headers=headers)
    assert rv.status_code == 200
    assert rv.status_code == 200
 def test_application_paginated_sorted_list(self, session, client, jwt,
                                            pageNo, limit, sortBy,
                                            sortOrder):
     token = jwt.create_jwt(get_token_body(), get_token_header())
     headers = {
         "Authorization": f"Bearer {token}",
         "content-type": "application/json",
     }
     response = client.get(
         f"/application?pageNo={pageNo}&limit={limit}&sortBy={sortBy}&sortOrder={sortOrder}",
         headers=headers,
     )
     assert response.status_code == 200
Example #7
0
def test_form_process_mapper_detail_view(session, client, jwt, app):
    token = jwt.create_jwt(get_token_body(), get_token_header())
    headers = {"Authorization": f"Bearer {token}", "content-type": "application/json"}
    response = client.post(
        "/form",
        headers=headers,
        json=get_form_request_payload(),
    )
    assert response.status_code == 201
    mapper_id = response.json.get("id")
    rv = client.get(f"/form/{mapper_id}", headers=headers)
    assert rv.status_code == 200
    assert rv.json.get("id") == mapper_id
Example #8
0
def test_post_payments_invalid_request(client, jwt, app, payment_mock):
    """Assert that the endpoint returns 400."""
    token = jwt.create_jwt(get_claims(), get_token_header())
    headers = {
        'content-type': 'application/json',
        'Authorization': f'Bearer {token}'
    }
    rv = client.post('/api/v1/payments',
                     data=json.dumps({
                         'feeCode': 'BSH105',
                         'userId': 'PB25020'
                     }),
                     headers=headers)
    assert rv.status_code == 400
Example #9
0
def test_post_accounts(client, jwt, app, ldap_mock, query_profile_mock):
    """Assert that the endpoint returns 200."""
    token = jwt.create_jwt(get_claims(), get_token_header())
    headers = {
        'content-type': 'application/json',
        'Authorization': f'Bearer {token}'
    }
    rv = client.post('/api/v1/profiles',
                     data=json.dumps({
                         'userId': 'TEST',
                         'password': '******'
                     }),
                     headers=headers)
    assert rv.status_code == 200
Example #10
0
def test_post_accounts_not_prime_error(client, jwt, app, ldap_mock,
                                       query_profile_contact_mock):
    """Assert that the endpoint returns 400."""
    token = jwt.create_jwt(get_claims(), get_token_header())
    headers = {
        'content-type': 'application/json',
        'Authorization': f'Bearer {token}'
    }
    rv = client.post('/api/v1/profiles',
                     data=json.dumps({
                         'userId': 'TEST',
                         'password': '******'
                     }),
                     headers=headers)
    assert rv.status_code == 400
    assert rv.json.get('type') == Error.NOT_A_PRIME_USER.name
Example #11
0
def test_post_payments_error(client, jwt, app, payment_mock_error):
    """Assert that the endpoint returns 200."""
    token = jwt.create_jwt(get_claims(), get_token_header())
    headers = {
        'content-type': 'application/json',
        'Authorization': f'Bearer {token}'
    }
    rv = client.post('/api/v1/payments',
                     data=json.dumps({
                         'feeCode': 'BSH105',
                         'userId': 'PB25020',
                         'invoiceNumber': 'TEST12345678901',
                         'folioNumber': 'TEST1234567890',
                         'formNumber': '',
                         'quantity': '',
                         'rate': '',
                         'amount': '',
                         'remarks': 'TEST',
                         'reduntantFlag': ' '
                     }),
                     headers=headers)
    assert rv.status_code == 400
Example #12
0
def test_form_process_mapper_list(session, client, jwt, app):
    token = jwt.create_jwt(get_token_body(), get_token_header())
    headers = {"Authorization": f"Bearer {token}", "content-type": "application/json"}
    response = client.get("/form", headers=headers)
    assert response.status_code == 200
Example #13
0
def test_form_process_mapper_creation(session, client, jwt, app):
    token = jwt.create_jwt(get_token_body(), get_token_header())
    headers = {"Authorization": f"Bearer {token}", "content-type": "application/json"}
    response = client.post("/form", headers=headers, json=get_form_request_payload())
    assert response.status_code == 201
    assert response.json.get("id") != None