def test_only_viewers_added(self): register_security_policies(self.config) context = self._fixture_and_setup() context.add_groups('hanna', [security.ROLE_VIEWER]) context.add_groups('anders', [security.ROLE_VIEWER]) obj = self._cut(context) self.assertEqual(obj.get_unread_userids(), frozenset(('admin', 'hanna', 'anders')))
def test_inline_add_form_no_permission(self): register_security_policies(self.config) self.config.scan('voteit.core.models.proposal') self.config.scan('voteit.core.schemas.proposal') context = self._fixture() request = testing.DummyRequest(params={'content_type': 'Proposal'}) obj = self._cut(context, request) self.assertRaises(HTTPForbidden, obj.process_inline_add_form)
def test_with_nonexistent_user(self): register_security_policies(self.config) register_workflows(self.config) root = _fixture(self.config) context = root['meeting'] obj = self._cut(context) node = None self.assertRaises(colander.Invalid, obj, node, "@admin says that naming @nonexistent should raise Invalid")
def test_with_at_links(self): register_security_policies(self.config) register_workflows(self.config) root = _fixture(self.config) context = root['meeting'] obj = self._cut(context) node = None self.assertEqual(obj(node, "@admin says to @tester that this shouldn't be valid."), None)
def test_mark_as_read(self): register_security_policies(self.config) context = self._fixture_and_setup() obj = self._cut(context) userid = 'somebody' obj.unread_storage.add(userid) self.assertTrue(userid in obj.get_unread_userids()) obj.mark_as_read(userid) self.assertFalse(userid in obj.get_unread_userids())
def test_with_nonexistent_user(self): register_security_policies(self.config) register_workflows(self.config) root = _fixture(self.config) context = root['meeting'] obj = self._cut(context) node = None self.assertRaises( colander.Invalid, obj, node, "@admin says that naming @nonexistent should raise Invalid")
def test_with_at_links(self): register_security_policies(self.config) register_workflows(self.config) root = _fixture(self.config) context = root['meeting'] obj = self._cut(context) node = None self.assertEqual( obj(node, "@admin says to @tester that this shouldn't be valid."), None)
def test_with_user_outside_of_meeting_context(self): from voteit.core.models.user import User register_security_policies(self.config) register_workflows(self.config) root = _fixture(self.config) context = root['meeting'] #New user root.users['new'] = User() obj = self._cut(context) node = None self.assertRaises(colander.Invalid, obj, node, "@new doesn't exist in this meeting so this shouldn't work")
def test_with_user_outside_of_meeting_context(self): from voteit.core.models.user import User register_security_policies(self.config) register_workflows(self.config) root = _fixture(self.config) context = root['meeting'] #New user root.users['new'] = User() obj = self._cut(context) node = None self.assertRaises( colander.Invalid, obj, node, "@new doesn't exist in this meeting so this shouldn't work")
def test_verify_obj(self): register_security_policies(self.config) context = self._fixture_and_setup() obj = self._cut(context) self.assertTrue(verifyObject(IUnread, obj))
def test_existing_userid(self): register_security_policies(self.config) root = _fixture(self.config) obj = self._cut(root) node = None self.assertRaises(colander.Invalid, obj, node, "admin")
def test_unread_on_check(self): register_security_policies(self.config) context = self._fixture_and_setup() obj = self._cut(context) self.assertEqual(obj.get_unread_userids(), frozenset(('admin',)))
def setUp(self): self.config = testing.setUp() self.config.include('arche.testing') register_security_policies(self.config)
def test_unread_on_check(self): register_security_policies(self.config) context = self._fixture_and_setup() obj = self._cut(context) self.assertEqual(obj.get_unread_userids(), frozenset(('admin', )))
def setUp(self): self.config = testing.setUp() register_security_policies(self.config)
def test_working_userid(self): register_security_policies(self.config) root = _fixture(self.config) obj = self._cut(root) node = None self.assertEqual(obj(node, "john_doe"), None)