2015-02-14 10:10:08 +01:00
|
|
|
from unittest import TestCase
|
2015-06-16 10:37:23 +02:00
|
|
|
from unittest.mock import MagicMock, patch
|
2015-02-14 10:10:08 +01:00
|
|
|
|
|
|
|
from openslides.core import views
|
2015-02-18 01:45:39 +01:00
|
|
|
from openslides.utils.rest_api import ValidationError
|
2015-02-14 10:10:08 +01:00
|
|
|
|
|
|
|
|
2019-01-06 16:22:33 +01:00
|
|
|
@patch("openslides.core.views.ProjectorViewSet.get_object")
|
2015-02-18 01:45:39 +01:00
|
|
|
class ProjectorAPI(TestCase):
|
|
|
|
def setUp(self):
|
|
|
|
self.viewset = views.ProjectorViewSet()
|
|
|
|
self.viewset.format_kwarg = None
|
|
|
|
|
|
|
|
def test_activate_elements_no_list(self, mock_object):
|
2015-09-06 13:28:25 +02:00
|
|
|
mock_object.return_value.config = {
|
2019-01-06 16:22:33 +01:00
|
|
|
"3979c9fc3bee432fb25f354d6b4868b3": {
|
|
|
|
"name": "test_projector_element_ahshaiTie8xie3eeThu9",
|
|
|
|
"test_key_ohwa7ooze2angoogieM9": "test_value_raiL2ohsheij1seiqua5",
|
|
|
|
}
|
|
|
|
}
|
2015-02-18 01:45:39 +01:00
|
|
|
request = MagicMock()
|
2019-01-06 16:22:33 +01:00
|
|
|
request.data = {"name": "new_test_projector_element_buuDohphahWeeR2eeQu0"}
|
2015-02-18 01:45:39 +01:00
|
|
|
self.viewset.request = request
|
|
|
|
with self.assertRaises(ValidationError):
|
|
|
|
self.viewset.activate_elements(request=request, pk=MagicMock())
|
|
|
|
|
|
|
|
def test_activate_elements_bad_element(self, mock_object):
|
2015-09-06 13:28:25 +02:00
|
|
|
mock_object.return_value.config = {
|
2019-01-06 16:22:33 +01:00
|
|
|
"374000ee236a41e09cce22ffad29b455": {
|
|
|
|
"name": "test_projector_element_ieroa7eu3aechaip3eeD",
|
|
|
|
"test_key_mie3Eeroh9rooKeinga6": "test_value_gee1Uitae6aithaiphoo",
|
|
|
|
}
|
|
|
|
}
|
2015-02-18 01:45:39 +01:00
|
|
|
request = MagicMock()
|
2019-01-06 16:22:33 +01:00
|
|
|
request.data = [{"bad_quangah1ahoo6oKaeBai": "value_doh8ahwe0Zooc1eefu0o"}]
|
2015-02-18 01:45:39 +01:00
|
|
|
self.viewset.request = request
|
|
|
|
with self.assertRaises(ValidationError):
|
|
|
|
self.viewset.activate_elements(request=request, pk=MagicMock())
|