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.
0:03 So the idea is we're going to create the entire web app
0:05 and spin that up and then interact with it
0:08 from, well as a whole right, we're going to give it a URL
0:12 and it's going to go through all the stuff that
0:14 whatever the real web app would do to find
0:16 the view method to call it, to find the template
0:18 that's going to generate the response, and so on.
0:20 So we really get some deep integration tests going here.
0:25 The idea is we're going to create some test class
0:28 some test case.
0:29 We're going to have our app, we're going to set it up.
0:32 Here we're going to create this test web app, right so we
0:35 want to make sure that it's not already set.
0:37 This is one way we could do it that
0:38 might be a little more handy.
0:40 We can use class setup instead of just regular setup maybe.
0:43 And then we're going to import the main method.
0:46 And we're going to call it, potentially passing additional
0:49 settings that are not shown here.
0:51 And we're going to wrap that app in a test app
0:53 which let's us issue fake HTTP requests to it.
0:56 It's like a testing WSGI wrapper type of thing.
0:59 So we're going to do this to get everything set up
1:02 and get the app created.
1:04 And we just issue request to it.
1:06 So there's no real Arrange here.
1:07 That was the thing we just saw.
1:08 But the act is go to the app and do a GET request
1:11 to this URL and verify we get the 200 status back
1:16 or various other things, right.
1:17 We could pass all sorts of data.
1:18 And then we can make basic assert statements.
1:21 What we get back is the actual final text
1:23 that would've been sent to the user.
1:25 So you've got to work with it like in the body.
1:27 Maybe you could check for cookies, things like that.
1:29 Whatever you want to assert you assert that on the response.