-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
…s-endpoint LTD-5688: Productionise footnotes endpoint
- Loading branch information
Showing
7 changed files
with
153 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
api/data_workspace/v2/tests/bdd/scenarios/footnotes.feature
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
@db | ||
Feature: applications Table | ||
|
||
Scenario: Draft application | ||
Given a draft standard application | ||
Then the `footnotes` table is empty | ||
|
||
Scenario: Submit an application | ||
Given a draft standard application | ||
When the application is submitted | ||
Then the `footnotes` table is empty | ||
|
||
Scenario: Approving an application with footnotes | ||
Given a draft standard application with attributes: | ||
| name | value | | ||
| id | 03fb08eb-1564-4b68-9336-3ca8906543f9 | | ||
When the application is submitted | ||
And a recommendation is added with footnotes: | ||
| team | footnotes | | ||
| FCDO | Commercial end user | | ||
Then the `footnotes` table has the following rows: | ||
| application_id | team_name | type | footnote | | ||
| 03fb08eb-1564-4b68-9336-3ca8906543f9 | FCDO | approve | Commercial end user | | ||
|
||
Scenario: Approving an application with no footnotes | ||
Given a draft standard application with attributes: | ||
| name | value | | ||
| id | 03fb08eb-1564-4b68-9336-3ca8906543f9 | | ||
When the application is submitted | ||
And a recommendation is added with footnotes: | ||
| team | footnotes | | ||
| FCDO | | | ||
Then the `footnotes` table is empty |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import pytest | ||
|
||
from pytest_bdd import ( | ||
parsers, | ||
scenarios, | ||
when, | ||
) | ||
|
||
from django.urls import reverse | ||
|
||
from api.staticdata.statuses.enums import CaseStatusEnum | ||
from api.teams.models import Team | ||
|
||
|
||
scenarios("./scenarios/footnotes.feature") | ||
|
||
|
||
@pytest.fixture() | ||
def add_recommendation( | ||
api_client, | ||
ogd_advisor, | ||
ogd_advisor_headers, | ||
): | ||
def _add_recommendation(application, footnotes_data): | ||
|
||
url = reverse("caseworker_applications:change_status", kwargs={"pk": str(application.pk)}) | ||
response = api_client.post(url, data={"status": CaseStatusEnum.OGD_ADVICE}, **ogd_advisor_headers) | ||
assert response.status_code == 200 | ||
|
||
ogd_advisor.team = Team.objects.get(name=footnotes_data[0]["team"]) | ||
ogd_advisor.save() | ||
|
||
subjects = [("good_id", good_on_application.good.id) for good_on_application in application.goods.all()] + [ | ||
(poa.party.type, poa.party.id) for poa in application.parties.all() | ||
] | ||
|
||
data = [ | ||
{ | ||
"type": "approve", | ||
"text": "Recommend issuing licence", | ||
"proviso": "", | ||
"footnote_required": True, | ||
"footnote": footnotes_data[0]["footnotes"], | ||
subject_name: str(subject_id), | ||
"denial_reasons": [], | ||
} | ||
for subject_name, subject_id in subjects | ||
] | ||
url = reverse("cases:user_advice", kwargs={"pk": str(application.pk)}) | ||
response = api_client.post(url, data=data, **ogd_advisor_headers) | ||
assert response.status_code == 201 | ||
|
||
return _add_recommendation | ||
|
||
|
||
@when(parsers.parse("a recommendation is added with footnotes:{footnotes}")) | ||
def when_a_recommendation_is_added_with_footnotes( | ||
submitted_standard_application, add_recommendation, parse_table, footnotes | ||
): | ||
footnotes_data = [{"team": team, "footnotes": text} for team, text in parse_table(footnotes)[1:]] | ||
add_recommendation(submitted_standard_application, footnotes_data) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters