Building Data-Driven Web Apps with Pyramid and SQLAlchemy Transcripts
Chapter: Testing web apps
Lecture: Concept: Testing the full web app
0:00 Let's review the functional tests concepts. So the idea is we're going to create the entire web app and spin that up and then interact with it
0:09 from, well as a whole right, we're going to give it a URL and it's going to go through all the stuff that whatever the real web app would do to find
0:17 the view method to call it, to find the template that's going to generate the response, and so on.
0:21 So we really get some deep integration tests going here. The idea is we're going to create some test class some test case.
0:30 We're going to have our app, we're going to set it up. Here we're going to create this test web app, right so we
0:36 want to make sure that it's not already set. This is one way we could do it that might be a little more handy.
0:41 We can use class setup instead of just regular setup maybe. And then we're going to import the main method.
0:47 And we're going to call it, potentially passing additional settings that are not shown here. And we're going to wrap that app in a test app
0:54 which let's us issue fake HTTP requests to it. It's like a testing WSGI wrapper type of thing. So we're going to do this to get everything set up
1:03 and get the app created. And we just issue request to it. So there's no real Arrange here. That was the thing we just saw.
1:09 But the act is go to the app and do a GET request to this URL and verify we get the 200 status back or various other things, right.
1:18 We could pass all sorts of data. And then we can make basic assert statements. What we get back is the actual final text
1:24 that would've been sent to the user. So you've got to work with it like in the body. Maybe you could check for cookies, things like that.
1:30 Whatever you want to assert you assert that on the response.