On Jul 20, 2006, at 4:29 AM, atwork wrote:

>
> How do I unit test a controller that communicates with externals  
> like a
> database and sessions?
>
> I see two solutions:
> 1. Mock the externals
> 2. Set up a real session and initialize the database before each test
>
> The ideal solution would be to test the controller lightly by mocking
> out all database- and session calls, since I still have to do
> integration testing with for example selenium.
>
> I would like to know if someone has used any mocking framework with
> Python. If not, how hard would it be to use one in this case?

For the database, I usually use :memory: sqlite databases when testing.

For sessions, you can just stick a dictionary in cherrypy.session to  
stand-in for the real session with whatever data is useful for test.

I have used pmock (pymock?) on another project with success, for the  
times when I really needed to use a mock.

Kevin

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

Reply via email to