Sunday, February 12, 2012

Re: Unit test example for web froms

Coming from a non python/django background (my experience is groovy/
grails), but when we test our controllers (I think this is equivalent
to django views). We simply set up mock params on the request and set
expectations on the controller properties.

Simple example:

given:
request.params = [ param1: 'valid', param2: 'invalid' ]

when:
controller.submit() // the method called when the webform is
posted

then:
controller.hasErrors == true

and:
controller.param2.error == 'this is invalid'

The above example is obviously simplified, but hopefully it shows the
general idea.

On Feb 12, 2:41 am, Mario Gudelj <mario.gud...@gmail.com> wrote:
> Hi guys,
>
> I was wandering if anyone has a good example of a unit test where they have
> a view which processes a web form. I'm not sure how you'd test something
> like that.
>
> Thanks,
>
> mario

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate