Skip to content

Commit

Permalink
Fixing tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
tomeksabala authored and ThrawnCA committed Jun 23, 2022
1 parent c906ee1 commit 233be7e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
11 changes: 11 additions & 0 deletions ckan/tests/controllers/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,3 +273,14 @@ def test_jsonp_does_not_work_on_post_requests(self, app):
assert sorted(res_dict["result"]) == sorted(
[dataset1["name"], dataset2["name"]]
)


def test_i18n_only_known_locales_are_accepted(app):

url = url_for("api.i18n_js_translations", ver=2, lang="fr")

assert app.get(url).status_code == 200

url = url_for("api.i18n_js_translations", ver=2, lang="unknown_lang")
r = app.get(url, status=400)
assert "Bad request - Unknown locale" in r.get_data(as_text=True)
2 changes: 1 addition & 1 deletion ckan/views/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,7 @@ def snippet(snippet_path, ver=API_REST_DEFAULT_VERSION):
def i18n_js_translations(lang, ver=API_REST_DEFAULT_VERSION):

if lang not in get_locales_from_config():
return _finish_bad_request('Unknown locale: {}'.format(lang))
return _finish_bad_request(u'Unknown locale: {}'.format(lang))

ckan_path = os.path.join(os.path.dirname(__file__), u'..')
source = os.path.abspath(os.path.join(ckan_path, u'public',
Expand Down

0 comments on commit 233be7e

Please sign in to comment.