-
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.
Add advice data workspace endpoint
- Loading branch information
Showing
4 changed files
with
75 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
from rest_framework import viewsets | ||
from rest_framework.pagination import LimitOffsetPagination | ||
|
||
from api.cases.serializers import AdviceSerializer | ||
from api.core.authentication import DataWorkspaceOnlyAuthentication | ||
from api.applications.serializers.advice import Advice | ||
|
||
|
||
class AdviceListView(viewsets.ReadOnlyModelViewSet): | ||
authentication_classes = (DataWorkspaceOnlyAuthentication,) | ||
serializer_class = AdviceSerializer | ||
pagination_class = LimitOffsetPagination | ||
queryset = Advice.objects.all() |
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,52 @@ | ||
from django.urls import reverse | ||
|
||
from api.cases.enums import AdviceType, AdviceLevel | ||
from test_helpers.clients import DataTestClient | ||
|
||
|
||
class AdviceDataWorkspaceTests(DataTestClient): | ||
def setUp(self): | ||
super().setUp() | ||
self.standard_application = self.create_standard_application_case(self.organisation) | ||
self.create_advice( | ||
self.gov_user, | ||
self.standard_application, | ||
"good", | ||
AdviceType.APPROVE, | ||
AdviceLevel.FINAL, | ||
advice_text="advice_text", | ||
) | ||
|
||
def test_advice(self): | ||
url = reverse("data_workspace:dw-advice-list") | ||
response = self.client.get(url) | ||
payload = response.json() | ||
last_result = payload["results"][-1] | ||
|
||
# Ensure we get some expected fields | ||
expected_fields = { | ||
"id", | ||
"type", | ||
"created_at", | ||
"updated_at", | ||
"text", | ||
"note", | ||
"level", | ||
"footnote", | ||
"footnote_required", | ||
"proviso", | ||
"pv_grading", | ||
"collated_pv_grading", | ||
"case", | ||
"user", | ||
"team", | ||
"good", | ||
"goods_type", | ||
"country", | ||
"end_user", | ||
"ultimate_end_user", | ||
"consignee", | ||
"third_party", | ||
"denial_reasons", | ||
} | ||
assert set(last_result.keys()) == expected_fields |
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