add skills integration test
This commit is contained in:
parent
ab792ab2aa
commit
d387af0f37
@ -22,6 +22,13 @@ flask run
|
|||||||
http://localhost:5000/
|
http://localhost:5000/
|
||||||
|
|
||||||
|
|
||||||
|
### Tests ausführen
|
||||||
|
|
||||||
|
```
|
||||||
|
python -m unittest discover ki
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
### Testbenutzer
|
### Testbenutzer
|
||||||
|
|
||||||
Für ein Login ohne LDAP werden die Benutzer aus der [`auth.yml`](./data/auth.yml) benutzt.
|
Für ein Login ohne LDAP werden die Benutzer aus der [`auth.yml`](./data/auth.yml) benutzt.
|
||||||
|
@ -4,11 +4,11 @@ from ki.models import Language, Skill
|
|||||||
from app import app, db
|
from app import app, db
|
||||||
|
|
||||||
|
|
||||||
@app.cli.command("seed")
|
|
||||||
def seed():
|
def seed():
|
||||||
|
|
||||||
skill_seed_file_path = app.config["KI_DATA_DIR"] + "/seed_data/skills.csv"
|
skill_seed_file_path = app.config["KI_DATA_DIR"] + "/seed_data/skills.csv"
|
||||||
|
|
||||||
|
print("importing skills")
|
||||||
|
|
||||||
with open(skill_seed_file_path) as skills_file:
|
with open(skill_seed_file_path) as skills_file:
|
||||||
skills_csv_reader = csv.DictReader(skills_file)
|
skills_csv_reader = csv.DictReader(skills_file)
|
||||||
|
|
||||||
@ -32,3 +32,8 @@ def seed():
|
|||||||
db.session.add(Language(id=iso["639-1"], name=iso["Sprache"]))
|
db.session.add(Language(id=iso["639-1"], name=iso["Sprache"]))
|
||||||
|
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
|
|
||||||
|
|
||||||
|
@app.cli.command("seed")
|
||||||
|
def seed_command():
|
||||||
|
seed()
|
||||||
|
0
ki/test/__init__.py
Normal file
0
ki/test/__init__.py
Normal file
33
ki/test/test_skills_endpoint.py
Normal file
33
ki/test/test_skills_endpoint.py
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
from alembic import command
|
||||||
|
import unittest
|
||||||
|
|
||||||
|
from app import app, migrate
|
||||||
|
from ki.commands import seed
|
||||||
|
|
||||||
|
|
||||||
|
class TestSkillsEndpoint(unittest.TestCase):
|
||||||
|
def setUp(self):
|
||||||
|
app.debug = True
|
||||||
|
app.config["SQLALCHEMY_DATABASE_URI"] = "sqlite:///:memory:"
|
||||||
|
self.client = app.test_client()
|
||||||
|
|
||||||
|
with app.app_context():
|
||||||
|
config = migrate.get_config()
|
||||||
|
command.upgrade(config, "head")
|
||||||
|
|
||||||
|
seed()
|
||||||
|
|
||||||
|
def test_get_skills1(self):
|
||||||
|
response = self.client.get("/skills?search=p")
|
||||||
|
self.assertEqual(response.status_code, 200)
|
||||||
|
self.assertEqual( \
|
||||||
|
{"skills": [ \
|
||||||
|
{"id": 1, "name": "PHP"}, \
|
||||||
|
{"id": 3, "name": "Python"}
|
||||||
|
]}, \
|
||||||
|
response.json \
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "main":
|
||||||
|
unittest.main()
|
Loading…
Reference in New Issue
Block a user