def test_get_application_history(client, jwt):
    """Get the json request for application /application/{application_id}/history"""
    token = factory_auth_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")

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

    ## This application create fails because of pessimistic DB management

    application_id = rv.json.get("applicationId")

    rv = client.get(f"/application/{application_id}/history", headers=headers)
    assert rv.status_code == 200
def test_application_update_details_api(session, client, jwt):
    token = factory_auth_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")

    rv = client.post(
        "/application/create",
        headers=headers,
        json=get_application_create_payload(form_id),
    )
    assert rv.status_code == 201
    application_id = rv.json.get("id")
    rv = client.get(f"/application/{application_id}", headers=headers)
    payload = rv.json()
    payload["applicationStatus"] = "New"
    rv = client.put(f"/application/{application_id}",
                    headers=headers,
                    json=payload)
    assert rv.status_code == 200
    assert rv.json() == "Updated successfully"
def test_post_application_history_create_method(client, jwt):
    token = factory_auth_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")

    rv = client.post(
        "/application/create",
        headers=headers,
        json=get_application_create_payload(form_id),
    )
    assert rv.status_code == 201
    application_id = rv.json.get("applicationId")
    new_application = client.post(
        f"/application/{application_id}/history",
        headers=headers,
        json={
            "applicationId": 1,
            "applicationStatus": "New",
            "formUrl": "http://testsample.com/form/23/submission/3423",
        },
    )
    assert new_application.status_code == 201
 def test_application_detailed_view(self, session, client, jwt):
     token = factory_auth_header()
     headers = {
         "Authorization": f"Bearer {token}",
         "content-type": "application/json",
     }
     response = client.get("/application/1", headers=headers)
     assert response.status_code == 403
示例#5
0
def test_get_dashboard_error_details(client):
    token = factory_auth_header()
    headers = {
        "Authorization": f"Bearer {token}",
        "content-type": "application/json"
    }

    rv = client.get("/dashboards/10000", headers=headers)
    assert rv.json == {"message": "Dashboard not found"}
示例#6
0
def test_get_dashboards(client):
    token = factory_auth_header()
    headers = {
        "Authorization": f"Bearer {token}",
        "content-type": "application/json"
    }
    rv = client.get("/dashboards", headers=headers)
    assert rv.status_code == 200
    assert len(rv.json) >= 1
 def test_application_paginated_list(self, session, client, jwt, pageNo,
                                     limit):
     token = factory_auth_header()
     headers = {
         "Authorization": f"Bearer {token}",
         "content-type": "application/json",
     }
     response = client.get(f"/application?pageNo={pageNo}&limit={limit}",
                           headers=headers)
     assert response.status_code == 200
示例#8
0
def test_non_existential_group_id(client):
    """non-existential group id"""
    token = factory_auth_header()
    headers = {
        "Authorization": f"Bearer {token}",
        "content-type": "application/json"
    }

    response = client.get("/groups/123", headers=headers)
    assert response.status_code == 404
示例#9
0
def test_get_dashboard_details(client):
    token = factory_auth_header()
    headers = {
        "Authorization": f"Bearer {token}",
        "content-type": "application/json"
    }

    rv = client.get("/dashboards/1", headers=headers)
    assert rv.json() is not None
    assert rv.status_code == 200
示例#10
0
def test_group_list(client):
    """Passing case of Group List API"""
    token = factory_auth_header()
    headers = {
        "Authorization": f"Bearer {token}",
        "content-type": "application/json"
    }

    response = client.get("/groups", headers=headers)
    assert response.status_code == 200
示例#11
0
def test_group_list_wrongmethod(client):
    """Instead of Get Request, what if POST request comes"""
    token = factory_auth_header()
    headers = {
        "Authorization": f"Bearer {token}",
        "content-type": "application/json"
    }

    response = client.post("/groups", headers=headers)
    assert response.status_code == 405
    assert response.json() == {
        "message": "The method is not allowed for the requested URL."
    }
示例#12
0
def test_group_details(client):
    token = factory_auth_header()
    headers = {
        "Authorization": f"Bearer {token}",
        "content-type": "application/json"
    }

    response = client.get("/groups", headers=headers)
    assert len(response.json()) > 0

    id = response.json()[0]["id"]
    response = client.get(f"/groups/{id}", headers=headers)
    assert response.status_code == 200
    assert len(response.json()) > 0
示例#13
0
def test_application_create_method(session, client, jwt):
    token = factory_auth_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")

    rv = client.post(
        "/application/create",
        headers=headers,
        json=get_application_create_payload(form_id),
    )
    assert rv.status_code == 201
示例#14
0
def test_groups_put_details(client):
    """good cases"""
    token = factory_auth_header()
    headers = {
        "Authorization": f"Bearer {token}",
        "content-type": "application/json"
    }

    response = client.get("/groups", headers=headers)
    assert len(response.json()) > 0
    id = response.json()[0]["id"]

    response = client.put(f"/groups/{id}",
                          headers=headers,
                          data={"dashboards": [{
                              100: "Test Dashboard"
                          }]})
    assert response.status_code == 204
示例#15
0
def test_groups_put_wrong_details(client):
    """wrong request object"""
    token = factory_auth_header()
    headers = {
        "Authorization": f"Bearer {token}",
        "content-type": "application/json"
    }

    response = client.get("/groups", headers=headers)
    assert len(response.json()) > 0
    id = response.json()[0]["id"]

    response = client.put(f"/groups/{id}",
                          headers=headers,
                          data={"dashboard": [{
                              100: "Test Dashboard"
                          }]})
    assert response.status_code == 400
    assert response.json() == {"message": "Invalid Request Object format"}
示例#16
0
    def test_application_submission(self, session, client, jwt):
        token = factory_auth_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")

        rv = client.post(
            "/application/create",
            headers=headers,
            json=get_application_create_payload(form_id),
        )
        assert rv.status_code == 201
        response = client.get("/application/formid/61b81b6f85589c44f62865c7",
                              headers=headers)
        assert response.status_code == 200