#100DaysOfWeb in Python Transcripts
Chapter: Days 81-84: Unit testing web apps
Lecture: 3 types of tests

Login or purchase this course to watch this video and the rest of the course contents.
0:00 Now when we think of testing our web application there's actually different layers of our app that we might want to test.
0:07 At the lowest level, we might want to test these things called View Models, we'll talk more about those
0:11 but they're basically involved in the data exchange between the view and the template. And we're going to introduce those next.
0:17 We also might want to just call those View Methods and we might want to call them directly or we might want to let all the functionality
0:23 of the web application run and then create a sort of fake request against it. So you'll see there's these different levels
0:29 of testing within our web application and these different levels require different amounts of scaffolding or support structures to make them
0:37 believe that they're actually running in a web request in a web server. Now all this ignores the external types of testing.
0:44 Load testing, performance testing automation with selenium, things like that. But we're talking about using unit testing frameworks
0:51 and interacting with their web app and testing it that way. So in this world, we have these three types. We might test the View Model
0:57 and in our world the View Model probably requires a request. And this request comes from the web framework.
1:03 From Pyramid, Flash, Django, whatever, right. We got to create a way to get that request there. We might call the View Method directly
1:09 which may interact with this View Model we're going to define and again, that requires a request object
1:14 at least within the Pyramid framework to be passed over and sort of ambiently in Flask and finally we might want to create a fake web request
1:23 that calls the main method of our app it starts it up, it configures all the things the routing and everything, it actually runs
1:30 through the routing so it'll create a fake HTTP request and test it that way. So we'll see with the first two
1:36 we have a limited amount of scaffolding we have to create mostly around the request and not interacting with the database, things like that.
1:42 The one on the right here actually requires a little bit more work. So we're going to do all of this in this testing chapter.


Talk Python's Mastodon Michael Kennedy's Mastodon