ki-backend/ki/test/test_languages_endpoint.py

40 lines
1.4 KiB
Python
Raw Permalink Normal View History

2021-07-12 20:18:45 +02:00
# SPDX-FileCopyrightText: WTF Kooperative eG <https://wtf-eg.de/>
#
# SPDX-License-Identifier: AGPL-3.0-or-later
import unittest
from ki.test.ApiTest import ApiTest
class TestLanguagesEndpoint(ApiTest):
2024-08-28 13:43:33 +02:00
2021-07-12 20:18:45 +02:00
def test_skills_options(self):
response = self.client.options("/languages")
self.assertEqual(response.status_code, 200)
self.assertIn("Access-Control-Allow-Origin", response.headers)
self.assertEqual(response.headers["Access-Control-Allow-Origin"], "*")
def test_search_languages_fr(self):
token = self.login("peter", "geheim")["token"]
response = self.client.get("/languages?search=fr", headers={"Authorization": "Bearer " + token})
self.assertEqual(response.status_code, 200)
self.assertEqual({"languages": [{
"id": "fr",
"name": "Französisch",
"icon_url": "/languages/fr/icon"
}]}, response.json)
self.assertIn("Access-Control-Allow-Origin", response.headers)
self.assertEqual(response.headers["Access-Control-Allow-Origin"], "*")
def test_get_fr_icon(self):
response = self.client.get("/languages/fr/icon")
self.assertEqual(response.status_code, 200)
self.assertIn("Content-Type", response.headers)
2022-01-15 17:51:42 +01:00
self.assertEqual(response.headers["Content-Type"], "image/svg+xml; charset=utf-8")
2021-07-12 20:18:45 +02:00
if __name__ == "main":
unittest.main()