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
0:01 were the full integration tests.
0:03 We fired up the entire web app
0:05 the blueprints, the routing, the view methods
0:08 the view models, all at once and we fed URLs to it
0:12 and we checked what happened.
0:14 Ideally, those go to the right view methods
0:16 that we were intending
0:17 and then generate the right response.
0:19 But that's what our tests are meant to check.
0:21 There's a lot of setup to make that happen.
0:24 Not a lot, but some that you don't want to repeat.
0:26 So we created a pytest fixture called client
0:29 that would put the app in the right configuration
0:32 it would create a test client
0:33 register the blueprints
0:34 things like that and then pass off the actual object
0:38 that we're going to use.
0:39 Then, when we want to write a test
0:41 here we want to test the home page, it's super easy.
0:44 The arranged part is just a no-op
0:46 because that's what the pytest fixture does.
0:48 Basically, that's the arrange.
0:50 And then the act is just to issue a git
0:52 to forward slash, capture the response
0:54 and check that the status code's 200
0:56 and that the title we're expecting
0:58 is in the data for the response, that's it.