Skip to content

Commit 8a8a3cd

Browse files
committed
Added a solution.hide.py with the guide code, and corrected repeated function names in the test.py
1 parent 96e5382 commit 8a8a3cd

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
from flask import Flask, jsonify, request
2+
app = Flask(__name__)
3+
4+
todos = [{"label": "A dummy todo", "done": True}]
5+
6+
7+
@app.route('/todos', methods=['GET'])
8+
def hello_world():
9+
return jsonify(todos)
10+
11+
12+
@app.route('/todos', methods=['POST'])
13+
def add_new_todo():
14+
request_body = request.json
15+
print("Incoming request with the following body", request_body)
16+
return 'Response for the POST todo'
17+
18+
19+
# These two lines should always be at the end of your app.py file
20+
if __name__ == '__main__':
21+
app.run(host='0.0.0.0', port=3245, debug=True)

.learn/exercises/07.1-test-post-todo/test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ def test_return(client):
9595

9696

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

@@ -116,6 +116,6 @@ def test_add_new_todo():
116116

117117

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

0 commit comments

Comments
 (0)