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

Don't attempt to parse different request types: fixes adding new experiences #65

Merged
merged 3 commits into from
Sep 25, 2024
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
9 changes: 3 additions & 6 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,13 +116,10 @@ def experience():
return jsonify([exp.__dict__ for exp in data["experience"]]), 200

if request.method == "POST":
request_body = (
request.form
if request.content_type == "multipart/form-data"
else request.get_json()
)
request_body = request.form

if not request_body:
return jsonify({"error": "Request must be JSON or include form data"}), 400
return jsonify({"error": "Request must include form data"}), 400

required_fields = {
"title": str,
Expand Down
2 changes: 1 addition & 1 deletion test_pytest.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def test_experience(client):
"description": "Writing JavaScript Code",
"logo": "default.jpg",
}
item_id = client.post("/resume/experience", json=example_experience).json["id"]
item_id = client.post("/resume/experience", data=example_experience).json["id"]
response = client.get("/resume/experience")
assert any(exp["id"] == item_id for exp in response.json)

Expand Down
Loading