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

Added a solution.hide.py with the guide code, and corrected repeated … #87

Merged
merged 1 commit into from
Mar 14, 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
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]
Loading