def test_update_user(self, mock_ctrl, mock_model, mock_resp): """ Test user update """ request = mock.MagicMock() request.body = json.dumps({'delta': {'name': 'some-user'}}) user = UserResourceView() response = user.put(request, 'test-user') mock_ctrl.update_user.assert_called_once_with('test-user', {'name': 'some-user'}) mock_model.SERIALIZER.assert_called_once_with(mock_ctrl.update_user.return_value) mock_resp.assert_called_once_with(mock_model.SERIALIZER.return_value.data) self.assertTrue(response is mock_resp.return_value)
def test_update_user(self, mock_ctrl, mock_model, mock_resp): """ Test user update """ request = mock.MagicMock() request.body = json.dumps({'delta': {'name': 'some-user'}}) user = UserResourceView() response = user.put(request, 'test-user') mock_ctrl.update_user.assert_called_once_with('test-user', {'name': 'some-user'}) mock_model.serializer.assert_called_once_with(mock_ctrl.update_user.return_value) mock_resp.assert_called_once_with(mock_model.serializer.return_value.data) self.assertTrue(response is mock_resp.return_value)
def test_update_user(self, mock_factory, mock_resp): """ Test user update """ resp = {'login': '******', 'name': 'some-user', 'id': '12345'} mock_factory.user_manager.return_value.update_user.return_value = resp request = mock.MagicMock() request.body = json.dumps({'delta': {'name': 'some-user'}}) user = UserResourceView() response = user.put(request, 'test-user') expected_cont = {'login': '******', 'name': 'some-user'} mock_resp.assert_called_once_with(expected_cont) self.assertTrue(response is mock_resp.return_value)