Fix test errors
Some checks failed
continuous-integration/drone/pr Build is failing

This commit is contained in:
Brain 2024-09-13 15:38:56 +02:00
parent b0652add43
commit 8478e8d76e
Signed by: Brain
GPG Key ID: EE936E31EE3AEE7A
3 changed files with 79 additions and 72 deletions

View File

@ -88,6 +88,7 @@ def seed_user(auth_id,
def seed(dev: bool):
with app.app_context():
seed_contacttypes()
skill_seed_file_path = app.config["KI_DATA_DIR"] + "/seed_data/skills.csv"
@ -136,7 +137,8 @@ def seed(dev: bool):
skills=[(3, 3), (1, 5)],
searchtopics=[3, 1],
languages=[("de", 5), ("fr", 3)],
address=("Peter Nichtlustig", "Waldweg", "23i", "Hinterhaus", "13337", "Bielefeld", "Deutschland"),
address=("Peter Nichtlustig", "Waldweg", "23i", "Hinterhaus", "13337", "Bielefeld",
"Deutschland"),
contacts=[(4, "@peter:wtf-eg.de"), (1, "peter@wtf-eg.de")])
seed_user("dirtydieter",

View File

@ -31,6 +31,7 @@ class ApiTest(unittest.TestCase):
self.max_skill_id = max_skill.id
def tearDown(self):
with app.app_context():
db.drop_all()
db.engine.dispose()

View File

@ -20,6 +20,7 @@ class TestProfileEndpoint(ApiTest):
self.assertEqual(login_response.status_code, 200)
self.assertIn("token", login_response.json)
with app.app_context():
babsi = User.query.filter(User.auth_id == "babsi1").first()
response = self.client.post(f"/users/{babsi.id}/profile",
data=json.dumps({}),
@ -103,6 +104,7 @@ class TestProfileEndpoint(ApiTest):
"level": 2
}]
}
with app.app_context():
peter = User.query.filter(User.auth_id == "peter").first()
response = self.client.post(f"/users/{peter.id}/profile",
data=json.dumps(data),
@ -185,6 +187,7 @@ class TestProfileEndpoint(ApiTest):
def test_get_visible_proifle(self):
token = self.login("peter", "geheim")["token"]
with app.app_context():
babsi = User.query.filter(User.auth_id == "babsi1").first()
response = self.client.get(f"/users/{babsi.id}/profile", headers={"Authorization": f"Bearer {token}"})
@ -197,6 +200,7 @@ class TestProfileEndpoint(ApiTest):
self.assertEqual(login_response.status_code, 200)
self.assertIn("token", login_response.json)
with app.app_context():
peter = User.query.filter(User.auth_id == "peter").first()
response = self.client.get(f"/users/{peter.id}/profile",
headers={"Authorization": "Bearer " + login_response.json["token"]})