2015-04-30 19:13:28 +02:00
|
|
|
from unittest import TestCase
|
|
|
|
from unittest.mock import MagicMock, patch
|
|
|
|
|
|
|
|
from openslides.motions.views import MotionViewSet
|
|
|
|
|
|
|
|
|
|
|
|
class MotionViewSetUpdate(TestCase):
|
|
|
|
"""
|
|
|
|
Tests update view of MotionViewSet.
|
|
|
|
"""
|
|
|
|
def setUp(self):
|
|
|
|
self.request = MagicMock()
|
|
|
|
self.view_instance = MotionViewSet()
|
|
|
|
self.view_instance.request = self.request
|
|
|
|
self.view_instance.kwargs = MagicMock()
|
|
|
|
self.view_instance.get_object = MagicMock()
|
|
|
|
self.view_instance.get_serializer = get_serializer_mock = MagicMock()
|
|
|
|
get_serializer_mock.return_value = self.mock_serializer = MagicMock()
|
|
|
|
|
2017-04-28 22:10:18 +02:00
|
|
|
@patch('openslides.motions.views.inform_changed_data')
|
2017-01-26 15:34:24 +01:00
|
|
|
@patch('openslides.motions.views.has_perm')
|
2015-04-30 19:13:28 +02:00
|
|
|
@patch('openslides.motions.views.config')
|
2017-04-28 22:10:18 +02:00
|
|
|
def test_simple_update(self, mock_config, mock_has_perm, mock_icd):
|
2018-11-04 14:02:30 +01:00
|
|
|
self.request.user = MagicMock()
|
|
|
|
self.request.user.pk = 1
|
2018-08-31 15:33:41 +02:00
|
|
|
self.request.data.get.return_value = MagicMock()
|
2017-01-26 15:34:24 +01:00
|
|
|
mock_has_perm.return_value = True
|
|
|
|
|
2015-04-30 19:13:28 +02:00
|
|
|
self.view_instance.update(self.request)
|
2017-01-26 15:34:24 +01:00
|
|
|
|
2018-08-31 15:33:41 +02:00
|
|
|
self.mock_serializer.save.assert_called()
|