Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: added all get all api and post request #23

Merged
merged 9 commits into from
Oct 9, 2024
41 changes: 35 additions & 6 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@
"October 2022",
"Present",
"Writing Python Code",
"example-logo.png"),
Experience("Intern",
"A Nice Company",
"October 2021",
"December 2021",
"Writing Scripts",
"example-logo.png")
],
"education": [
Expand Down Expand Up @@ -45,10 +51,20 @@ def experience():
Handle experience requests
'''
if request.method == 'GET':
return jsonify()
return jsonify({"experience": [exp.__dict__ for exp in data["experience"]]})

if request.method == 'POST':
return jsonify({})
new_experience = request.json
experience_instance = Experience(
new_experience["title"],
new_experience["company"],
new_experience["start_date"],
new_experience["end_date"],
new_experience["description"],
new_experience["logo"]
)
data["experience"].append(experience_instance)
return jsonify({"id": len(data["experience"]) - 1})

return jsonify({})

Expand All @@ -58,10 +74,20 @@ def education():
Handles education requests
'''
if request.method == 'GET':
return jsonify({})
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({})

Expand All @@ -72,9 +98,12 @@ def skill():
Handles Skill requests
'''
if request.method == 'GET':
return jsonify({})
return jsonify({"skills": [skill.__dict__ for skill in data["skill"]]})

if request.method == 'POST':
return jsonify({})
new_skill = request.json
skill_instance = Skill(new_skill["name"], new_skill["proficiency"], new_skill["logo"])
data["skill"].append(skill_instance)
return jsonify({"id": len(data["skill"]) - 1})

return jsonify({})
6 changes: 3 additions & 3 deletions test_pytest.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def test_experience():
item_id = app.test_client().post('/resume/experience',
json=example_experience).json['id']
response = app.test_client().get('/resume/experience')
assert response.json[item_id] == example_experience
assert response.json["experience"][item_id] == example_experience


def test_education():
Expand All @@ -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():
Expand All @@ -71,4 +71,4 @@ def test_skill():
json=example_skill).json['id']

response = app.test_client().get('/resume/skill')
assert response.json[item_id] == example_skill
assert response.json["skills"][item_id] == example_skill
Loading