Skip to content

Commit

Permalink
FWF-3222: [Bugfix] Added Testcase & pylint fix
Browse files Browse the repository at this point in the history
  • Loading branch information
auslin-aot committed Jul 12, 2024
1 parent 9bb9e25 commit 827ff69
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
26 changes: 26 additions & 0 deletions forms-flow-api/tests/unit/api/test_application_history.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from typing import Dict, List

from tests.utilities.base_test import get_token
from formsflow_api.models import Application


def get_history_create_payload():
Expand Down Expand Up @@ -68,3 +69,28 @@ def test_application_history_get_un_authorized(app, client, session, jwt):
# sending get request withouttoken
rv = client.get("/application/1/history")
assert rv.status_code == 401


def create_application_history_service_account(app, client, session, jwt):
"""Tests if the initial application history created with a service account replaced by application creator."""
application = Application()
application.created_by = "client"
application.application_status = "New"
application.form_process_mapper_id = 1
application.submission_id = "2345"
application.latest_form_id = "1234"
application.save()

payload = {
"applicationId": 1,
"applicationStatus": "New",
"formUrl": "http://testsample.com/form/23/submission/3423",
"submittedBy": "service-account-pmn",
}
token = get_token(jwt)
headers = {"Authorization": f"Bearer {token}", "content-type": "application/json"}
new_entry = client.post(
"/application/1/history", headers=headers, json=payload
)
assert new_entry.status_code == 201
assert new_entry.submitted_by == "client"
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def test_create_application_history(app, client, session):
}
payload["application_id"] = 1222 # sample value
application_history = application_history_service.create_application_history(
data=payload
data=payload, application_id=1222
)
assert application_history.application_id == 1222
assert application_history.application_status == "Pending"
Expand Down

0 comments on commit 827ff69

Please sign in to comment.