implement updating skills

This commit is contained in:
2021-06-27 13:38:16 +02:00
parent 68b84f50ca
commit 15b71459ee
7 changed files with 85 additions and 65 deletions

View File

@ -28,9 +28,7 @@ class TestProfileEndpoint(unittest.TestCase):
def test_update_profile(self):
login_data = {"username": "peter", "password": "geheim"}
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")
self.assertEqual(login_response.status_code, 200)
self.assertIn("token", login_response.json)
@ -60,15 +58,25 @@ class TestProfileEndpoint(unittest.TestCase):
"name": "Rohrpost"
},
"content": "Ausgang 2"
}],
"skills": [{
"id": 1,
"skill": {
"id": 3,
"name": "Python"
},
"level": 4
}, {
"skill": {
"name": "Tschunkproduktion"
},
"level": 5
}]
}
response = self.client.post("/users/1/profile",
data=json.dumps(data),
content_type="application/json",
headers={
"Authorization": "Bearer " +
login_response.json["token"]
})
headers={"Authorization": "Bearer " + login_response.json["token"]})
self.assertEqual(response.status_code, 200)
with app.app_context():
@ -100,18 +108,13 @@ class TestProfileEndpoint(unittest.TestCase):
def test_get_profile(self):
login_data = {"username": "peter", "password": "geheim"}
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")
self.assertEqual(login_response.status_code, 200)
self.assertIn("token", login_response.json)
response = self.client.get("/users/1/profile",
headers={
"Authorization": "Bearer " +
login_response.json["token"]
})
headers={"Authorization": "Bearer " + login_response.json["token"]})
self.assertEqual(response.status_code, 200)
self.assertDictEqual(
@ -151,13 +154,21 @@ class TestProfileEndpoint(unittest.TestCase):
"content": "peter@wtf-eg.de"
}],
"skills": [{
"profile_id": 1,
"skill": {
"id": 1,
"name": "PHP",
"icon_url": "/skills/1/icon"
},
"level": 5
}, {
"profile_id": 1,
"skill": {
"id": 3,
"name": "Python",
"icon_url": "/skills/3/icon"
},
"level": 5
"level": 3
}],
"languages": [{
"profile_id": 1,

View File

@ -36,6 +36,10 @@ class TestSkillsEndpoint(unittest.TestCase):
"id": 1,
"name": "PHP",
"icon_url": "/skills/1/icon"
}, {
"id": 10,
"name": "PostgreSQL",
"icon_url": "/skills/10/icon"
}, {
"id": 3,
"name": "Python",