Mike, thanks. Makes sense. Out of curiosity, if I wanted to mock the models in a test of views, how would I do that?
On Tue, Jan 25, 2011 at 11:33 AM, Mike Orr <sluggos...@gmail.com> wrote: > On Tue, Jan 25, 2011 at 10:38 AM, Ryan <ryan.mckil...@gmail.com> wrote: > > I use PyMox for mocking in unit testing of models. While testing views, > I'd > > like to mock model methods as well. Any examples of how to do this? > > Or, is this the wrong approach? Should the view tests be considered full > > integration tests, and therefore not be mocked? > > View tests are a higher level of unit test, because you can test the > return dict rather than the rendered HTML. > > The extreme approach to testing is to "mock everything possible, > providing only the minimum dummy features necessary to exercise the > test". But most programmers would just test the real models in views, > using a test database with sample data. Because if you already have > other tests testing the model in isolation, they should have caught > any problems in the model. And if you have high-level model-access > methods (usually class methods on the model) which the view calls, > you'd test those in isolation too. Then you can just let the views > test the real models, and if the view result contains model > instance(s), you can examine those too and make sure they have the > correct values. > > -- > Mike Orr <sluggos...@gmail.com> > > -- > You received this message because you are subscribed to the Google Groups > "pylons-devel" group. > To post to this group, send email to pylons-devel@googlegroups.com. > To unsubscribe from this group, send email to > pylons-devel+unsubscr...@googlegroups.com<pylons-devel%2bunsubscr...@googlegroups.com> > . > For more options, visit this group at > http://groups.google.com/group/pylons-devel?hl=en. > > -- You received this message because you are subscribed to the Google Groups "pylons-devel" group. To post to this group, send email to pylons-devel@googlegroups.com. To unsubscribe from this group, send email to pylons-devel+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/pylons-devel?hl=en.