56 lines
2.0 KiB
Python
56 lines
2.0 KiB
Python
# 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 TestSkillsEndpoint(ApiTest):
|
|
def test_skills_options(self):
|
|
response = self.client.options("/skills")
|
|
self.assertEqual(response.status_code, 200)
|
|
self.assertIn("Access-Control-Allow-Origin", response.headers)
|
|
self.assertEqual(response.headers["Access-Control-Allow-Origin"], "*")
|
|
|
|
def test_get_skills1(self):
|
|
token = self.login("peter", "geheim")["token"]
|
|
|
|
response = self.client.get("/skills?search=p", headers={"Authorization": "Bearer " + token})
|
|
self.assertEqual(response.status_code, 200)
|
|
self.assertEqual(
|
|
{
|
|
"skills": [{
|
|
"id": 1,
|
|
"name": "PHP",
|
|
"icon_url": "/skills/1/icon"
|
|
}, {
|
|
"id": 10,
|
|
"name": "PostgreSQL",
|
|
"icon_url": "/skills/10/icon"
|
|
}, {
|
|
"id": 3,
|
|
"name": "Python",
|
|
"icon_url": "/skills/3/icon"
|
|
}]
|
|
}, response.json)
|
|
self.assertIn("Access-Control-Allow-Origin", response.headers)
|
|
self.assertEqual(response.headers["Access-Control-Allow-Origin"], "*")
|
|
|
|
def test_get_php_skill_icon(self):
|
|
response = self.client.get("/skills/1/icon")
|
|
self.assertEqual(response.status_code, 200)
|
|
self.assertIn("Content-Type", response.headers)
|
|
self.assertEqual(response.headers["Content-Type"], "image/svg+xml; charset=utf-8")
|
|
|
|
def test_get_fallback_skill_icon(self):
|
|
response = self.client.get("/skills/2/icon")
|
|
self.assertEqual(response.status_code, 200)
|
|
self.assertIn("Content-Type", response.headers)
|
|
self.assertEqual(response.headers["Content-Type"], "image/svg+xml; charset=utf-8")
|
|
|
|
|
|
if __name__ == "main":
|
|
unittest.main()
|