Compare commits

..

1 Commits

Author SHA1 Message Date
178381b00c
extend seed skills
All checks were successful
continuous-integration/drone/push Build is passing
2021-07-26 20:17:38 +02:00
3 changed files with 19 additions and 19 deletions

View File

@ -8,6 +8,7 @@ import unittest
from app import app, db, migrate from app import app, db, migrate
from ki.actions import seed from ki.actions import seed
from ki.models import Skill
class ApiTest(unittest.TestCase): class ApiTest(unittest.TestCase):
@ -26,6 +27,8 @@ class ApiTest(unittest.TestCase):
command.upgrade(config, "head") command.upgrade(config, "head")
seed(True) seed(True)
max_skill = Skill.query.order_by(Skill.id.desc()).first()
self.max_skill_id = max_skill.id
def tearDown(self): def tearDown(self):
db.drop_all() db.drop_all()

View File

@ -143,7 +143,7 @@ class TestProfileEndpoint(ApiTest):
self.assertEqual(first_skill.level, 4) self.assertEqual(first_skill.level, 4)
second_skill = skills[1] second_skill = skills[1]
self.assertEqual(second_skill.skill.id, 13) self.assertEqual(second_skill.skill.id, self.max_skill_id + 1)
self.assertEqual(second_skill.skill.name, "Tschunkproduktion") self.assertEqual(second_skill.skill.name, "Tschunkproduktion")
self.assertEqual(second_skill.level, 5) self.assertEqual(second_skill.level, 5)
@ -155,7 +155,7 @@ class TestProfileEndpoint(ApiTest):
self.assertEqual(first_searchtopic.skill.name, "Python") self.assertEqual(first_searchtopic.skill.name, "Python")
second_searchtopic = searchtopics[1] second_searchtopic = searchtopics[1]
self.assertEqual(second_searchtopic.skill.id, 14) self.assertEqual(second_searchtopic.skill.id, self.max_skill_id + 2)
self.assertEqual(second_searchtopic.skill.name, "Assembler") self.assertEqual(second_searchtopic.skill.name, "Assembler")
languages = profile.languages languages = profile.languages

View File

@ -14,27 +14,24 @@ class TestSkillsEndpoint(ApiTest):
self.assertIn("Access-Control-Allow-Origin", response.headers) self.assertIn("Access-Control-Allow-Origin", response.headers)
self.assertEqual(response.headers["Access-Control-Allow-Origin"], "*") self.assertEqual(response.headers["Access-Control-Allow-Origin"], "*")
def test_get_skills1(self): def test_find_skills_php(self):
token = self.login("peter", "geheim")["token"]
response = self.client.get("/skills?search=php", headers={"Authorization": "Bearer " + token})
self.assertEqual(response.status_code, 200)
self.assertGreaterEqual(len(response.json['skills']), 1)
self.assertIn({"id": 1, "name": "PHP", "icon_url": "/skills/1/icon"}, response.json['skills'])
self.assertIn("Access-Control-Allow-Origin", response.headers)
self.assertEqual(response.headers["Access-Control-Allow-Origin"], "*")
def test_find_skills_p(self):
token = self.login("peter", "geheim")["token"] token = self.login("peter", "geheim")["token"]
response = self.client.get("/skills?search=p", headers={"Authorization": "Bearer " + token}) response = self.client.get("/skills?search=p", headers={"Authorization": "Bearer " + token})
self.assertEqual(response.status_code, 200) self.assertEqual(response.status_code, 200)
self.assertEqual( self.assertGreaterEqual(len(response.json['skills']), 3)
{
"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.assertIn("Access-Control-Allow-Origin", response.headers)
self.assertEqual(response.headers["Access-Control-Allow-Origin"], "*") self.assertEqual(response.headers["Access-Control-Allow-Origin"], "*")