extend seed skills
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
gulliver 2021-07-26 19:56:36 +02:00 committed by Michael Weimann
parent 730878847b
commit 178381b00c
Signed by: weeman
GPG Key ID: 34F0524D4DA694A1
4 changed files with 24 additions and 19 deletions

View File

@ -11,3 +11,8 @@ id,name
10,PostgreSQL 10,PostgreSQL
11,SQLite 11,SQLite
12,Node.js 12,Node.js
13,C++
14,C
15,VHDL
16,go
17, Perl
1 id name
11 10 PostgreSQL
12 11 SQLite
13 12 Node.js
14 13 C++
15 14 C
16 15 VHDL
17 16 go
18 17 Perl

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"], "*")