ki-backend/ki/test/test_skills_endpoint.py

40 lines
1.3 KiB
Python
Raw Normal View History

2021-06-13 21:41:01 +02:00
import unittest
2021-06-27 14:25:44 +02:00
from ki.test.ApiTest import ApiTest
2021-06-13 21:41:01 +02:00
2021-06-27 14:25:44 +02:00
class TestSkillsEndpoint(ApiTest):
2021-06-21 22:21:25 +02:00
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"], "*")
2021-06-13 21:41:01 +02:00
def test_get_skills1(self):
2021-06-27 14:25:44 +02:00
token = self.login("peter", "geheim")["token"]
response = self.client.get("/skills?search=p", headers={"Authorization": "Bearer " + token})
2021-06-13 21:41:01 +02:00
self.assertEqual(response.status_code, 200)
2021-06-15 18:08:57 +02:00
self.assertEqual(
{
2021-06-21 16:06:58 +02:00
"skills": [{
"id": 1,
2021-06-26 12:16:14 +02:00
"name": "PHP",
"icon_url": "/skills/1/icon"
2021-06-27 13:38:16 +02:00
}, {
"id": 10,
"name": "PostgreSQL",
"icon_url": "/skills/10/icon"
2021-06-21 16:06:58 +02:00
}, {
"id": 3,
2021-06-26 12:16:14 +02:00
"name": "Python",
"icon_url": "/skills/3/icon"
2021-06-21 16:06:58 +02:00
}]
}, response.json)
2021-06-21 22:21:25 +02:00
self.assertIn("Access-Control-Allow-Origin", response.headers)
self.assertEqual(response.headers["Access-Control-Allow-Origin"], "*")
2021-06-13 21:41:01 +02:00
if __name__ == "main":
unittest.main()