fixing test and inform_changed_data call

This commit is contained in:
FinnStutzenstein 2017-03-24 08:14:08 +01:00
parent 08bd1251a7
commit 0220a03350
3 changed files with 8 additions and 7 deletions

View File

@ -277,7 +277,8 @@ class Assignment(RESTModelMixin, models.Model):
options.append({
'candidate': related_user.user,
'weight': related_user.weight})
poll.set_options(options)
poll.set_options(options, skip_autoupdate=True)
inform_changed_data(self)
# Add all candidates to list of speakers of related agenda item
# TODO: Try to do this in a bulk create

View File

@ -4,7 +4,6 @@ from django.core.exceptions import ObjectDoesNotExist
from django.db import models
from django.utils.translation import ugettext as _
from openslides.utils.autoupdate import inform_changed_data
from openslides.utils.models import MinMaxIntegerField
@ -123,7 +122,7 @@ class BasePoll(models.Model):
return True
return False
def set_options(self, options_data=[]):
def set_options(self, options_data=[], skip_autoupdate=False):
"""
Adds new option objects to the poll.
@ -132,8 +131,7 @@ class BasePoll(models.Model):
for option_data in options_data:
option = self.get_option_class()(**option_data)
option.poll = self
option.save(skip_autoupdate=True)
inform_changed_data(self.get_assignment())
option.save(skip_autoupdate=skip_autoupdate)
def get_options(self):
"""

View File

@ -52,9 +52,10 @@ class ItemViewSetManageSpeaker(TestCase):
mock_queryset = mock_speaker.objects.filter.return_value.exclude.return_value
mock_queryset.get.return_value.delete.assert_called_with()
@patch('openslides.agenda.views.inform_changed_data')
@patch('openslides.agenda.views.has_perm')
@patch('openslides.agenda.views.Speaker')
def test_remove_someone_else(self, mock_speaker, mock_has_perm):
def test_remove_someone_else(self, mock_speaker, mock_has_perm, mock_inform_changed_data):
self.request.method = 'DELETE'
self.request.user = 1
self.request.data = {'speaker': '1'}
@ -63,7 +64,8 @@ class ItemViewSetManageSpeaker(TestCase):
self.view_instance.manage_speaker(self.request)
mock_speaker.objects.get.assert_called_with(pk=1)
mock_speaker.objects.get.return_value.delete.assert_called_with()
mock_speaker.objects.get.return_value.delete.assert_called_with(skip_autoupdate=True)
mock_inform_changed_data.assert_called_with(self.mock_item)
class ItemViewSetSpeak(TestCase):