Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added proper error handling when trying to return false templates #765

Merged
merged 6 commits into from
Jan 29, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions web/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,4 +250,23 @@ def test_api_not_found(self):

self.assertEqual(response.status_code, HTTPStatus.NOT_FOUND)

def test_single_concept_view_valid_language_version(self):
"""
Test if the API response contains 'meta' and 'concepts' keys. And doesnt return error.
"""
url = '/api/data_types/javascript/ECMAScript%202009/'

# Send GET request to the URL
response = self.client.get(url)

# Check the response status
self.assertEqual(response.status_code, HTTPStatus.OK)

# Parse the response JSON
response_data = response.json()

# Assert that 'meta' and 'concepts' keys exist
self.assertIn('meta', response_data)
self.assertIn('concepts', response_data)


3 changes: 3 additions & 0 deletions web/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,9 @@ def api_reference(request, structure_key, lang, version):
if response is False:
return HttpResponseNotFound()

print(response)
print("=======================")

return HttpResponse(response, content_type="application/json")

def api_compare(request, structure_key, lang1, version1, lang2, version2):
Expand Down