WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion app.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,14 @@ def skill():
return jsonify({"error": "Invalid request"}), 400

except TypeError as e:
return jsonify({"error": str(e)}), 400
return jsonify({"error": str(e)}), 400

@app.route('/resume/skill/<int:skill_id>', methods=['GET'])
def get_skill(skill_id):
try:
skill = data["skill"][skill_id]
return jsonify(skill.__dict__)
except IndexError:
return jsonify({"error": "Skill not found"}), 404
except TypeError as e:
return jsonify({"error": str(e)}), 400
17 changes: 17 additions & 0 deletions test_pytest.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,20 @@ def test_skill():

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


def test_get_skill_by_id():
example_skill = {
"name": "Blowing Bubbles an Fighting Crime",
"proficiency": "5+ years",
"logo": "some-logo.png"
}

item_id = app.test_client().post('/resume/skill',
json=example_skill).json['id']

response = app.test_client().get(f'/resume/skill/{item_id}')
data = response.json

assert response.status_code == 200
assert data == example_skill
Loading