Re: How to mock a model backend

2015-03-29 Thread Alejandro Varas G.
Hi Sven, You can mock the call to the external service like this. @mock.patch.object(MyModelBackend, 'authenticate') # First the class of your model backend. Then the method you want to mock. def test_something_that_uses_login(self, mock_authenticate): # The mock object is passed to your

How to mock a model backend

2015-03-26 Thread Sven Mäurer
In my model backend I usually call an external service which returns me an user that is saved and returned. When I don't have credentials I want to mock the backend for some test cases. In the setup of each test case I am calling the login method where CRED contains the real credentials or mock