Skip to content

Commit

Permalink
FWF-3749: [Feature] Testcase added
Browse files Browse the repository at this point in the history
  • Loading branch information
auslin-aot committed Jan 20, 2025
1 parent 725f739 commit 32d8876
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions forms-flow-api/tests/unit/api/test_application.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,44 @@ def test_application_list_with_no_draft(
assert response.status_code == 200
assert len(response.json["applications"]) == 0

def test_application_list_include_drafts_and_only_drafts(
self, app, client, session, jwt, create_mapper
):
"""Test Application list with includeDrafts & onlyDrafts query param."""
form_id = create_mapper["formId"]
token = get_token(jwt, role=CREATE_SUBMISSIONS)
headers = {
"Authorization": f"Bearer {token}",
"content-type": "application/json",
}
# creating application
rv = client.post(
"/application/create",
headers=headers,
json=get_application_create_payload(form_id),
)

assert rv.status_code == 201
# creating a draft
client.post("/draft", headers=headers, json=get_draft_create_payload(form_id))
token = get_token(jwt, role=VIEW_SUBMISSIONS)
headers = {
"Authorization": f"Bearer {token}",
"content-type": "application/json",
}
# With includeDrafts=true, includes drafts in-addition to submissions
response = client.get("/application?includeDrafts=true", headers=headers)
assert response.status_code == 200
assert len(response.json["applications"]) == 2
# With includeDrafts=false, returns only submissions
response = client.get("/application?includeDrafts=false", headers=headers)
assert response.status_code == 200
assert len(response.json["applications"]) == 1
# With onlyDrafts=true, application list api returns only drafts
response = client.get("/application?onlyDrafts=true", headers=headers)
assert response.status_code == 200
assert len(response.json["applications"]) == 1


class TestApplicationDetailView:
"""Test suite for the API/application/<id> endpoint."""
Expand Down

0 comments on commit 32d8876

Please sign in to comment.