Revision 52194c77 snf-cyclades-app/synnefo/plankton/tests.py

b/snf-cyclades-app/synnefo/plankton/tests.py
68 68
        .... make api calls ....
69 69

  
70 70
    """
71
    from synnefo.plankton import util
72
    orig_method = util.get_user
73

  
74 71
    def dummy_get_user(request, *args, **kwargs):
75 72
        request.user = {'username': user, 'groups': []}
76 73
        request.user_uniq = user
77
    util.get_user = dummy_get_user
78
    yield
79
    util.get_user = orig_method
74

  
75
    with patch('synnefo.plankton.util.get_user') as m:
76
        m.side_effect = dummy_get_user
77
        yield
80 78

  
81 79

  
82
class BaseTestCase(TestCase):
80
class BaseAPITest(TestCase):
83 81
    def get(self, url, user='user', *args, **kwargs):
84 82
        with astakos_user(user):
85 83
            response = self.client.get(url, *args, **kwargs)
......
193 191

  
194 192

  
195 193
@patch("synnefo.plankton.util.ImageBackend")
196
class PlanktonTest(BaseTestCase):
194
class PlanktonTest(BaseAPITest):
197 195
    @assert_backend_closed
198 196
    def test_list_images(self, backend):
199 197
        backend.return_value.list.return_value =\
......
277 275
        self.assertSuccess(response)
278 276
        backend.return_value.register.assert_called_once_with('dummy_name',
279 277
                                                              'dummy_location',
280
                                                              {'owner': 'dummy_owner'})
278
                                                      {'owner': 'dummy_owner'})
281 279

  
282 280
    @assert_backend_closed
283 281
    def test_get_image(self, backend):

Also available in: Unified diff