2017-06-13 21:44:45 +02:00
|
|
|
from unittest import TestCase
|
|
|
|
|
2017-08-31 21:12:39 +02:00
|
|
|
from openslides.users.access_permissions import (
|
|
|
|
PersonalNoteAccessPermissions,
|
|
|
|
UserAccessPermissions,
|
|
|
|
)
|
2017-06-13 21:44:45 +02:00
|
|
|
from openslides.utils.collection import CollectionElement
|
|
|
|
|
|
|
|
|
|
|
|
class UserGetProjectorDataTest(TestCase):
|
|
|
|
def test_get_projector_data_with_collection(self):
|
|
|
|
"""
|
|
|
|
This test ensures that comment field is removed.
|
|
|
|
"""
|
2017-09-04 00:25:45 +02:00
|
|
|
full_data = {
|
2017-06-13 21:44:45 +02:00
|
|
|
'id': 42,
|
|
|
|
'username': 'username_ai3Oofu7eit0eeyu1sie',
|
|
|
|
'title': '',
|
|
|
|
'first_name': 'first_name_iu8toShae0oolie8aevo',
|
|
|
|
'last_name': 'last_name_OhZ4beezohY0doNoh2th',
|
|
|
|
'structure_level': '',
|
|
|
|
'number': '',
|
|
|
|
'about_me': '',
|
|
|
|
'groups_id': [],
|
|
|
|
'is_present': False,
|
|
|
|
'is_committee': False,
|
|
|
|
'comment': 'comment_gah7aipeJohv9xethoku',
|
2017-09-04 00:25:45 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
data = UserAccessPermissions().get_projector_data([full_data])
|
|
|
|
self.assertEqual(data[0], {
|
2017-06-13 21:44:45 +02:00
|
|
|
'id': 42,
|
|
|
|
'username': 'username_ai3Oofu7eit0eeyu1sie',
|
|
|
|
'title': '',
|
|
|
|
'first_name': 'first_name_iu8toShae0oolie8aevo',
|
|
|
|
'last_name': 'last_name_OhZ4beezohY0doNoh2th',
|
|
|
|
'structure_level': '',
|
|
|
|
'number': '',
|
|
|
|
'about_me': '',
|
|
|
|
'groups_id': [],
|
|
|
|
'is_present': False,
|
|
|
|
'is_committee': False,
|
|
|
|
})
|
2017-08-31 21:12:39 +02:00
|
|
|
|
|
|
|
|
|
|
|
class TestPersonalNoteAccessPermissions(TestCase):
|
|
|
|
def test_get_restricted_data(self):
|
|
|
|
ap = PersonalNoteAccessPermissions()
|
|
|
|
rd = ap.get_restricted_data(
|
2017-09-04 00:25:45 +02:00
|
|
|
[{'user_id': 1}],
|
2017-08-31 21:12:39 +02:00
|
|
|
CollectionElement.from_values('users/user', 5, full_data={}))
|
2017-09-04 00:25:45 +02:00
|
|
|
self.assertEqual(rd, [])
|
2017-08-31 21:12:39 +02:00
|
|
|
|
|
|
|
def test_get_restricted_data_for_anonymous(self):
|
|
|
|
ap = PersonalNoteAccessPermissions()
|
|
|
|
rd = ap.get_restricted_data(
|
2017-09-04 00:25:45 +02:00
|
|
|
[CollectionElement.from_values(
|
2017-08-31 21:12:39 +02:00
|
|
|
'users/personal_note',
|
|
|
|
1,
|
2017-09-04 00:25:45 +02:00
|
|
|
full_data={'user_id': 1})],
|
2017-08-31 21:12:39 +02:00
|
|
|
None)
|
2017-09-04 00:25:45 +02:00
|
|
|
self.assertEqual(rd, [])
|