Closed ElSnoMan closed 3 years ago
@gleekzorp
When I inspected the request with runner.Root.post_todo.help()
, I saw that the headers had the Content-Type set to application/json
. Because of this, you need to replace the default data
field with a json
field:
runner = Postman(path)
runner.Root.post_todo.help() # 1
req = runner.Root.post_todo.request
req["json"] = req.pop("data")
runner.Root.post_todo.help() # 2
response = runner.Root.post_todo()
assert response.ok
The request dictionary to send at #1
{
'method': 'POST',
'url': 'https://df-flask-todo-api-class.herokuapp.com/todo',
'data': {'title': 'check new stuff', 'done': False},
'headers': {'Content-Type': 'application/json'}
}
After renaming data
to json
, here's what the request looks like in #2
{
'method': 'POST',
'url': 'https://df-flask-todo-api-class.herokuapp.com/todo',
'headers': {'Content-Type': 'application/json'},
'json': {'title': 'check new stuff', 'done': False}
}
Why would my test_create_todo() not be working here? The test_get_todos() works. When I just build it out manually with requests it works. I can post this on your git repo instead if you want. BTW did slack get rid of the big code snippet with line numbers? I can't seem to find it.
I also tried it like this:
Todo-Flask-Heroku.postman_collection.json