testing framework

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

testing framework

Bugzilla from nnorwitz@gmail.com

Is there any interest in a little testing framework that mocks out
django to make it relatively easy to unit test views code?

At work I've got a little framework that does this.  It's only a couple
hundred lines cause it only provides the APIs we use on my project.
Many things are no-ops because I'm not trying to test Django (nor the
ORM, nor other DB access, nor templates), solely the views code itself.
 This happens to be where most of our code is because we are primarly
reading from a db and providing various views of the results.

Tests look something like this:

  def testMyView(self):
    request = HttpRequest()
    response = views.MyView(request)
    # Probably check some attrs of response.
    self.assertEqual(response, ....)
    self.assertEqual(1, len(models.MyModel.objects.get_saved()))

The framework mocks out models automatically, but you may need to mock
out other dependencies in views code (stuff outside Django).

The framework would need quite a bit of work to fake out many more
Django APIs as well as providing nicer access to the saved state.  It
shouldn't be too hard to open source this, but I'm not real keen on
maintaining it myself.  Would this be useful for people?

Cheers,
n

PS I'm not likely to read a response unless I'm copied.


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/django-users
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: testing framework

Russell Keith-Magee-2

On 10/12/06, Neal  Norwitz <[hidden email]> wrote:
>
> Is there any interest in a little testing framework that mocks out
> django to make it relatively easy to unit test views code?

A nice little testing framework already exists. It contains the
ability to test URL dispatch, view execution, and the templates that
are generated during view execution. Work is underway to add fixtures
and ties into browser tests (e.g., Selenium based tests)

For more details, see:

http://www.djangoproject.com/documentation/testing/

Yours,
Russ Magee %-)

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/django-users
-~----------~----~----~----~------~----~------~--~---