Building Data-Driven Web Apps with Pyramid and SQLAlchemy Transcripts
Chapter: Testing web apps
Lecture: Concept: Testing view models
0:00 Let's review testing view models.
0:01 In this case, we're just going to focus on the simple version.
0:04 So we have a view model and we need to provide it a request.
0:07 What does that look like? Well, we have test.
0:10 We're going to validate that there's an error
0:11 if we have no email. So we're going to arrange.
0:15 Remember the 3 As of unit testing, Arrange, Act, Assert.
0:19 So here's our arrange. We're going to create the dummy_request.
0:21 We're going to give it the Post dictionary.
0:23 And this is the simulated values from the form
0:26 so we're simulating there's no email submitted
0:29 but there is a password of value pw submitted.
0:32 We're going to act. I'm going to create our login view model
0:35 using the dummy pregenerated request object
0:38 and then we're going to validate that
0:40 and then we're going to assert that email is in the error
0:43 first, effectively that there is an error
0:46 and that email is in it.