LPTHW - Ex52 POST tests

Greetings,

I’m trying to figure out how to craft/run tests with flask and pytest. My get requests work fine, but when I pass the parameter data=data to my post requests, the function doesn’t even seem to know that the data is there. Is there something else that I should be doing?

import pytest
from app import *

app.config['TESTING'] = True
web = app.test_client()

# Tests the app's help function
    data = {'room_name': 'central_corridor', 'action': 'help'}
    rv = web.post('/game', follow_redirects=True, data=data)
    assert b'you have three choices' in rv.data

When I run my tests, I get this message:

# Tests the app's help function
    data = {'room_name': 'central_corridor', 'action': 'help'}
    rv = web.post('/game', follow_redirects=True, data=data)
 >       assert b'you have three choices' in rv.data
E       AssertionError: assert b'you have three choices' in b'<html>\n    <head>\n        <title>Gothons From           
Planet Percal #25</title>\n    </head>\n\n    <body>\n        \n\n<h...   <input type=\'text\' name=\'action 
\'><input type=\'SUBMIT\'>\n        </form>\n    </p>\n\n\n\n    </body>\n</html>'
E        +  where b'<html>\n    <head>\n        <title>Gothons From Planet Percal #25</title>\n    </head>\n\n    
<body>\n        \n\n<h...   <input type=\'text\' name=\'action\'><input type=\'SUBMIT\'>\n        </form>\n    </p>\n\n\n\n    </body>\n</html>' = <Response 1184 bytes [200 OK]>.data

tests/app_tests.py:29: AssertionError

So take a look here:

http://flask.pocoo.org/docs/1.0/testing/#logging-in-and-out

I think flask changed so that you have to pass data={} and put your data for the post into that dict. They use the dict() function for some reason.