Skip to content

Commit

Permalink
update for matching api
Browse files Browse the repository at this point in the history
  • Loading branch information
Tllew committed Feb 12, 2024
1 parent 499ecf4 commit 502176c
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 10 deletions.
5 changes: 5 additions & 0 deletions exporter/applications/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -586,3 +586,8 @@ def post_survey_feedback(request, json):
def get_survey(request, survey_id):
data = client.get(request, f"/survey/{survey_id}/")
return data.json(), data.status_code


def update_survey_feedback(request, survey_id, json):
data = client.put(request, f"/survey/{survey_id}/", json)
return data.json(), data.status_code
2 changes: 1 addition & 1 deletion exporter/applications/views/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ def get_context_data(self, **kwargs):
return context

@expect_status(
HTTPStatus.OK,
HTTPStatus.CREATED,
"Error sending feedback",
"Unexpected error sending feedback",
)
Expand Down
9 changes: 4 additions & 5 deletions exporter/applications/views/hcsat.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from core.decorators import expect_status
from exporter.applications.services import (
get_survey,
post_survey_feedback,
update_survey_feedback,
)

from exporter.applications.forms.hcsat import HCSATApplicationForm
Expand Down Expand Up @@ -34,8 +34,8 @@ def get_context_data(self, **kwargs):
"Error sending feedback",
"Unexpected error sending feedback",
)
def post_survey_feedback(self, request, data):
return post_survey_feedback(request, data)
def update_survey_feedback(self, request, survey_id, data):
return update_survey_feedback(request, survey_id, data)

@expect_status(
HTTPStatus.OK,
Expand All @@ -46,7 +46,6 @@ def get_survey(self, request, survey_id):
return get_survey(request, survey_id)

def get_initial(self):
self.object_pk = self.kwargs["pk"]
self.survey, _ = self.get_survey(self.request, self.kwargs["sid"])
initial = super().get_initial()
initial["recommendation"] = self.survey.get("recommendation")
Expand All @@ -55,7 +54,7 @@ def get_initial(self):
def form_valid(self, form):
form_data = form.cleaned_data.copy()
form_data["id"] = self.survey.get("id")
self.post_survey_feedback(self.request, form_data)
self.update_survey_feedback(self.request, self.survey.get("id"), form_data)
return super().form_valid(form)

def get_success_url(self):
Expand Down
6 changes: 3 additions & 3 deletions unit_tests/exporter/applications/views/test_hcsat.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ def application_reference_number(data_standard_case):


@pytest.fixture(autouse=True)
def mock_post_survey(requests_mock, survey_id):
survey_url = client._build_absolute_uri(f"/survey/")
return requests_mock.post(
def mock_update_survey(requests_mock, survey_id):
survey_url = client._build_absolute_uri(f"/survey/{survey_id}")
return requests_mock.put(
survey_url,
json={"id": survey_id},
status_code=200,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def mock_post_survey(requests_mock, survey_id):
return requests_mock.post(
survey_url,
json={"id": survey_id},
status_code=200,
status_code=201,
)


Expand Down

0 comments on commit 502176c

Please sign in to comment.