Skip to content

Commit

Permalink
aaq urgency check endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
Hlamallama committed Aug 6, 2024
1 parent 02fbae6 commit 3048457
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
6 changes: 5 additions & 1 deletion aaq/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -376,12 +376,14 @@ def test_search(self):
response = self.client.post(
self.url, data=payload, content_type="application/json"
)
[request] = responses.calls

self.assertEqual(response.status_code, 200)
self.assertIn("message", response.data)
self.assertIn("body", response.data)
self.assertIn("query_id", response.data)
self.assertIn("feedback_secret_key", response.data)
self.assertEqual(json.loads(request.request.body), json.loads(payload))

assert response.json() == {
"message": "*0* - Example content title\n*1* -"
Expand Down Expand Up @@ -552,6 +554,7 @@ def test_urgency_check_urgent(self):
response = self.client.post(
self.url, data=payload, content_type="application/json"
)
[request] = responses.calls

assert response.status_code == 200
assert response.json() == {
Expand All @@ -565,11 +568,12 @@ def test_urgency_check_urgent(self):
"Nausea that lasts for 3 days",
],
}
self.assertEqual(json.loads(request.request.body), json.loads(payload))

@responses.activate
def test_urgency_check_not_urgent(self):
"""
Test that we can get is urgent False
Test that we can get is False
"""
user = get_user_model().objects.create_user("test")
self.client.force_authenticate(user)
Expand Down
3 changes: 2 additions & 1 deletion aaq/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,8 @@ def search(request, *args, **kwargs):
def check_urgency_v2(request, *args, **kwargs):
serializer = UrgencyCheckV2Serializer(data=request.data)
serializer.is_valid(raise_exception=True)
message_text = serializer.validated_data["message_text"]
message_text = {}
message_text["message_text"] = serializer.validated_data["message_text"]
url = urllib.parse.urljoin(settings.AAQ_V2_API_URL, "/urgency-check-v2")
headers = {
"Authorization": settings.AAQ_V2_API_URL,
Expand Down

0 comments on commit 3048457

Please sign in to comment.