forked from kompetenzinventar/ki-backend
Compare commits
5 Commits
Author | SHA1 | Date | |
---|---|---|---|
a99dbe5016 | |||
8540623961 | |||
4529b07d54 | |||
86c2d7e84a | |||
eeb01bf6e8 |
@ -1,5 +1,4 @@
|
|||||||
# SPDX-FileCopyrightText: WTF Kooperative eG <https://wtf-eg.de/>
|
# SPDX-FileCopyrightText: WTF Kooperative eG <https://wtf-eg.de/>
|
||||||
#
|
|
||||||
# SPDX-License-Identifier: AGPL-3.0-or-later
|
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
|
|
||||||
import csv
|
import csv
|
||||||
@ -147,13 +146,13 @@ def seed(dev: bool):
|
|||||||
freetext="1001010010111!!!",
|
freetext="1001010010111!!!",
|
||||||
skills=[(1, 5)],
|
skills=[(1, 5)],
|
||||||
address=("Friedrich Witzig", "", "", "", "", "", ""))
|
address=("Friedrich Witzig", "", "", "", "", "", ""))
|
||||||
#all_skills = [(skill.id, 3) for skill in Skill.query.all()] # query causes problems
|
# all_skills = [(skill.id, 3) for skill in Skill.query.all()] # query causes problems
|
||||||
#seed_user("jutta", languages=[("fr", 5)], skills=all_skills)
|
# seed_user("jutta", languages=[("fr", 5)], skills=all_skills)
|
||||||
|
|
||||||
seed_user("giesela", skills=[(9, 3), (10, 5)])
|
seed_user("giesela", skills=[(9, 3), (10, 5)])
|
||||||
seed_user("bertha", visible=False, skills=[(11, 3), (10, 5)])
|
seed_user("bertha", visible=False, skills=[(11, 3), (10, 5)])
|
||||||
seed_user("monique", languages=[("fr", 4)])
|
seed_user("monique", languages=[("fr", 4)])
|
||||||
print("seeding done")
|
print("seeding done")
|
||||||
with app.app_context():
|
with app.app_context():
|
||||||
db.session.commit() # also problematic
|
db.session.commit() # also problematic
|
||||||
print("commit done")
|
print("commit done")
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
# SPDX-FileCopyrightText: WTF Kooperative eG <https://wtf-eg.de/>
|
# SPDX-FileCopyrightText: WTF Kooperative eG <https://wtf-eg.de/>
|
||||||
#
|
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
# SPDX-License-Identifier: AGPL-3.0-or-later
|
|
||||||
|
|
||||||
from alembic import command
|
from alembic import command
|
||||||
import json
|
import json
|
||||||
@ -9,7 +8,6 @@ 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
|
from ki.models import Skill
|
||||||
|
|
||||||
from sqlalchemy import select
|
from sqlalchemy import select
|
||||||
|
|
||||||
|
|
||||||
@ -26,29 +24,25 @@ class ApiTest(unittest.TestCase):
|
|||||||
self.client = app.test_client()
|
self.client = app.test_client()
|
||||||
|
|
||||||
config = migrate.get_config()
|
config = migrate.get_config()
|
||||||
|
|
||||||
with app.app_context():
|
with app.app_context():
|
||||||
command.upgrade(config, "head")
|
command.upgrade(config, "head")
|
||||||
seed(True)
|
seed(True)
|
||||||
|
|
||||||
#statement = select(Skill).order_by(Skill.id.desc())
|
# statement = select(Skill).order_by(Skill.id.desc())
|
||||||
#print(statement)
|
# print(statement)
|
||||||
#skill_obj = db.session.scalars(statement).all()
|
# skill_obj = db.session.scalars(statement).all()
|
||||||
#print(skill_obj)
|
# print(skill_obj)
|
||||||
#statement = select(Skill.id)
|
# statement = select(Skill.id)
|
||||||
#print(statement)
|
# print(statement)
|
||||||
|
# max_skill = db.session.Skill().order_by(Skill.id.desc()).first()
|
||||||
#max_skill = db.session.Skill().order_by(Skill.id.desc()).first()
|
# max_skill = Skill.query.order_by(Skill.id.desc()).first() # TODO: problematic
|
||||||
#max_skill = Skill.query.order_by(Skill.id.desc()).first() # TODO: problematic
|
with db.session.no_autoflush: # only works on first test run
|
||||||
|
max_skill = db.session.query(Skill).order_by(Skill.id.desc()).first() # TODO: also problematic,
|
||||||
with db.session.no_autoflush: # only works on first test run
|
# skills = db.session.execute(db.select(Skill)).scalars()
|
||||||
max_skill = db.session.query(Skill).order_by(Skill.id.desc()).first() # TODO: also problematic,
|
# print(max_skill)
|
||||||
|
# max_skill = db.session.execute(db.select(Skill)
|
||||||
#skills = db.session.execute(db.select(Skill)).scalars()
|
# .order_by(Skill.id.desc())
|
||||||
#print(max_skill)
|
# ).scalar_one()
|
||||||
#max_skill = db.session.execute(db.select(Skill)
|
|
||||||
## .order_by(Skill.id.desc())
|
|
||||||
# ).scalar_one()
|
|
||||||
print(max_skill)
|
print(max_skill)
|
||||||
print("max_skill done")
|
print("max_skill done")
|
||||||
self.max_skill_id = max_skill.id
|
self.max_skill_id = max_skill.id
|
||||||
@ -60,7 +54,7 @@ class ApiTest(unittest.TestCase):
|
|||||||
db.engine.dispose()
|
db.engine.dispose()
|
||||||
|
|
||||||
def login(self, username, password):
|
def login(self, username, password):
|
||||||
#with app.app_context():
|
# with app.app_context():
|
||||||
login_data = {"username": username, "password": password}
|
login_data = {"username": username, "password": password}
|
||||||
login_response = self.client.post("/users/login", data=json.dumps(login_data), content_type="application/json")
|
login_response = self.client.post("/users/login", data=json.dumps(login_data), content_type="application/json")
|
||||||
|
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
# SPDX-FileCopyrightText: WTF Kooperative eG <https://wtf-eg.de/>
|
# SPDX-FileCopyrightText: WTF Kooperative eG <https://wtf-eg.de/>
|
||||||
#
|
|
||||||
# SPDX-License-Identifier: AGPL-3.0-or-later
|
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
|
|
||||||
import unittest
|
import unittest
|
||||||
@ -10,7 +9,7 @@ from ki.test.ApiTest import ApiTest
|
|||||||
class TestContactTypesEndpoint(ApiTest):
|
class TestContactTypesEndpoint(ApiTest):
|
||||||
def test_skills_options(self):
|
def test_skills_options(self):
|
||||||
print("test_skills_options")
|
print("test_skills_options")
|
||||||
#with app.app_context():
|
# with app.app_context():
|
||||||
response = self.client.options("/contacttypes")
|
response = self.client.options("/contacttypes")
|
||||||
self.assertEqual(response.status_code, 200)
|
self.assertEqual(response.status_code, 200)
|
||||||
self.assertIn("Access-Control-Allow-Origin", response.headers)
|
self.assertIn("Access-Control-Allow-Origin", response.headers)
|
||||||
|
Reference in New Issue
Block a user