Skip to content

Commit

Permalink
Merge pull request #87 from AnggieAlava/bug/1542
Browse files Browse the repository at this point in the history
Added a solution.hide.py with the guide code, and corrected repeated …
  • Loading branch information
tommygonzaleza authored Mar 14, 2024
2 parents 96e5382 + 8a8a3cd commit 8f942a2
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
21 changes: 21 additions & 0 deletions .learn/exercises/07.1-test-post-todo/solution.hide.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
from flask import Flask, jsonify, request
app = Flask(__name__)

todos = [{"label": "A dummy todo", "done": True}]


@app.route('/todos', methods=['GET'])
def hello_world():
return jsonify(todos)


@app.route('/todos', methods=['POST'])
def add_new_todo():
request_body = request.json
print("Incoming request with the following body", request_body)
return 'Response for the POST todo'


# These two lines should always be at the end of your app.py file
if __name__ == '__main__':
app.run(host='0.0.0.0', port=3245, debug=True)
4 changes: 2 additions & 2 deletions .learn/exercises/07.1-test-post-todo/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def test_return(client):


@pytest.mark.it("Pass the todo list to the jsonify function and return the output of the function")
def test_return(client):
def test_return_json(client):
response = client.get('/todos')
_body = json.loads(response.data)

Expand All @@ -116,6 +116,6 @@ def test_add_new_todo():


@pytest.mark.it("The endpoint POST /todos should exist")
def test_return(client):
def test_return_endpoint(client):
response = client.post('/todos', json=json.dumps({}))
assert response.status_code in [200, 201]

0 comments on commit 8f942a2

Please sign in to comment.