Building Data-Driven Web Apps with Pyramid and SQLAlchemy Transcripts
Chapter: Testing web apps
Lecture: Concept: Testing view models
Login or
purchase this course
to watch this video and the rest of the course contents.
0:00
Let's review testing view models. In this case, we're just going to focus on the simple version.
0:05
So we have a view model and we need to provide it a request. What does that look like? Well, we have test.
0:11
We're going to validate that there's an error if we have no email. So we're going to arrange. Remember the 3 As of unit testing, Arrange, Act, Assert.
0:20
So here's our arrange. We're going to create the dummy_request. We're going to give it the Post dictionary.
0:24
And this is the simulated values from the form so we're simulating there's no email submitted but there is a password of value pw submitted.
0:33
We're going to act. I'm going to create our login view model using the dummy pregenerated request object and then we're going to validate that
0:41
and then we're going to assert that email is in the error first, effectively that there is an error and that email is in it.