Building Data-Driven Web Apps with Flask and SQLAlchemy Transcripts
Chapter: Testing web apps
Lecture: Concept: Testing the full web app
Login or
purchase this course
to watch this video and the rest of the course contents.
0:00
That last set of tests we wrote were the full integration tests. We fired up the entire web app the blueprints, the routing, the view methods
0:09
the view models, all at once and we fed URLs to it and we checked what happened. Ideally, those go to the right view methods that we were intending
0:18
and then generate the right response. But that's what our tests are meant to check. There's a lot of setup to make that happen.
0:25
Not a lot, but some that you don't want to repeat. So we created a pytest fixture called client that would put the app in the right configuration
0:33
it would create a test client register the blueprints things like that and then pass off the actual object that we're going to use.
0:40
Then, when we want to write a test here we want to test the home page, it's super easy. The arranged part is just a no-op
0:47
because that's what the pytest fixture does. Basically, that's the arrange. And then the act is just to issue a git
0:53
to forward slash, capture the response and check that the status code's 200 and that the title we're expecting
0:59
is in the data for the response, that's it.