From c66f2b05f8dca007532e8fef58f4303b2c755158 Mon Sep 17 00:00:00 2001 From: Bilal <39002942+byhlel@users.noreply.github.com> Date: Tue, 24 Sep 2024 08:52:26 +0000 Subject: [PATCH] feat: Implement API route to add new "Education" Resolves Implement API route to add new "Education" #19 --- app.py | 12 +++++++++++- test_pytest.py | 2 +- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/app.py b/app.py index 0896f19..c0a7d07 100644 --- a/app.py +++ b/app.py @@ -67,7 +67,17 @@ def education(): return jsonify({"education": [edu.__dict__ for edu in data["education"]]}) if request.method == 'POST': - return jsonify({}) + new_education = request.json + education_instance = Education( + new_education["course"], + new_education["school"], + new_education["start_date"], + new_education["end_date"], + new_education["grade"], + new_education["logo"] + ) + data["education"].append(education_instance) + return jsonify({"id": len(data["education"]) - 1}) return jsonify({}) diff --git a/test_pytest.py b/test_pytest.py index 6f0baa0..045da6c 100644 --- a/test_pytest.py +++ b/test_pytest.py @@ -52,7 +52,7 @@ def test_education(): json=example_education).json['id'] response = app.test_client().get('/resume/education') - assert response.json[item_id] == example_education + assert response.json["education"][item_id] == example_education def test_skill():