def _fixture(config):
    from voteit.core.models.user import User
    from voteit.core.models.meeting import Meeting
    config.include('pyramid_chameleon')
    root = bootstrap_and_fixture(config)
    config.include('arche.testing.setup_auth')
    config.include('voteit.core.models.meeting')
    tester = User(
        password='******',
        creators=['tester'],
        first_name=u'Tester',
        email="*****@*****.**",
    )
    root.users['tester'] = tester
    moderator = User(
        password='******',
        creators=['moderator'],
        first_name=u'Moderator',
        email="*****@*****.**",
    )
    root.users['moderator'] = moderator
    meeting = Meeting()
    meeting.add_groups('tester', [
        security.ROLE_DISCUSS, security.ROLE_PROPOSE, security.ROLE_VOTER,
        security.ROLE_VIEWER
    ])
    meeting.add_groups('moderator', [security.ROLE_MODERATOR])
    root['meeting'] = meeting
    return root
Exemple #2
0
def _setup_poll_fixture(config):
    # type: (Configurator) -> Poll
    config.testing_securitypolicy('admin', permissive=True)
    # config.include('pyramid_chameleon')
    # Register plugin
    config.include('voteit.stv')
    config.include('arche.testing')
    config.include('arche.testing.workflow')
    config.include('arche.testing.catalog')
    config.include('voteit.core.models.catalog')
    root = bootstrap_and_fixture(config)
    root['m'] = Meeting()
    unrestricted_wf_transition_to(root['m'], 'ongoing')
    root['m']['ai'] = ai = AgendaItem()
    unrestricted_wf_transition_to(ai, 'upcoming')
    unrestricted_wf_transition_to(ai, 'ongoing')
    #Setup poll
    ai['poll'] = Poll()
    poll = ai['poll']
    #Add proposals
    p1 = Proposal(creators = ['dummy'], text = 'first proposal')
    p1.uid = 'p1uid' #To make it simpler to test against
    ai['p1'] = p1
    p2 = Proposal(creators = ['dummy'], text = 'second proposal')
    p2.uid = 'p2uid'
    ai['p2'] = p2
    p3 = Proposal(creators = ['dummy'], text = 'third proposal')
    p3.uid = 'p3uid'
    ai['p3'] = p3
    #Select proposals for this poll
    poll.proposal_uids = (p1.uid, p2.uid, p3.uid)
    #Set poll as ongoing
    unrestricted_wf_transition_to(poll, 'upcoming')
    return poll
Exemple #3
0
 def test_show_moderator_actions(self):
     #FIXME: We still need a functional test for this
     root = bootstrap_and_fixture(self.config)
     self.config.testing_securitypolicy('admin', permissive=True)
     request = testing.DummyRequest()
     obj = self._cut(root, request)
     self.assertTrue(obj.show_moderator_actions)
 def test_nonexistent_users(self):
     root = bootstrap_and_fixture(self.config)
     obj = self._cut(root)
     self.assertRaises(colander.Invalid, obj, self._get_login_schema(), {
         'userid': u'moderator',
         'password': u'moderator'
     })
 def _fixture(self):
     from voteit.core.testing_helpers import bootstrap_and_fixture
     from voteit.core.testing_helpers import register_catalog
     self.config.registry.settings['default_timezone_name'] = "Europe/Stockholm"
     register_catalog(self.config)
     root = bootstrap_and_fixture(self.config)
     return root
Exemple #6
0
 def _fixture(self):
     from voteit.core.models.proposal import Proposal
     self.config.include('voteit.core.testing_helpers.register_catalog')
     self.config.include('voteit.core.testing_helpers.register_security_policies')
     root = bootstrap_and_fixture(self.config)
     root['p'] = Proposal()
     return root['p']
 def _fixture(self):
     from voteit.core.models.meeting import Meeting
     from voteit.core.models.user import User
     root = bootstrap_and_fixture(self.config)
     root['m'] = meeting = Meeting()
     root.users['dummy'] = User()
     return meeting
Exemple #8
0
 def test_show_moderator_actions(self):
     #FIXME: We still need a functional test for this
     root = bootstrap_and_fixture(self.config)
     self.config.testing_securitypolicy('admin', permissive = True)
     request = testing.DummyRequest()
     obj = self._cut(root, request)
     self.assertTrue(obj.show_moderator_actions)
Exemple #9
0
 def test_meeting_state(self):
     from voteit.core.models.meeting import Meeting
     root = bootstrap_and_fixture(self.config)
     meeting = root['m'] = Meeting()
     request = testing.DummyRequest()
     obj = self._cut(meeting, request)
     self.assertEqual(obj.meeting_state, u'upcoming')
Exemple #10
0
 def _fixture(self):
     from voteit.core.models.user import User
     root = bootstrap_and_fixture(self.config)
     root['users']['dummy'] = user = User(password = '******')
     user.auth_domains['some_auth'] = 'blabla'
     request = testing.DummyRequest()
     return root
Exemple #11
0
 def _fixture(self):
     from voteit.core.models.meeting import Meeting
     from voteit.core.models.user import User
     root = bootstrap_and_fixture(self.config)
     root['m'] = meeting = Meeting()
     root.users['dummy'] = User()
     return meeting
 def _fixture(self):
     from voteit.core.models.user import User
     root = bootstrap_and_fixture(self.config)
     root.users['dummy1'] = User(title='Dummy 1')
     root.users['dummy2'] = User(title='Dummy 2')
     root.users['dummy3'] = User(title='Dummy 3')
     return root.users
Exemple #13
0
 def _fixture(self):
     from voteit.core.models.meeting import Meeting
     from voteit.core.models.user import User
     root = bootstrap_and_fixture(self.config)
     root['m'] = Meeting()
     root['users']['dummy'] = User(first_name = 'John', last_name = 'Doe')
     return root
Exemple #14
0
 def _fixture(self):
     from voteit.core.models.agenda_item import AgendaItem
     from voteit.core.models.meeting import Meeting
     root = bootstrap_and_fixture(self.config)
     root['m'] = meeting = Meeting()
     meeting['ai'] = ai = AgendaItem()
     return ai
Exemple #15
0
def _setup_poll_fixture(config):
    config.testing_securitypolicy('admin', permissive = True)
    config.include('pyramid_chameleon')
    #Register plugin
    config.include('voteit.schulze')
    config.include('voteit.core.helpers')
    config.include('voteit.core.testing_helpers.register_catalog')
    root = bootstrap_and_fixture(config)
    root['m'] = Meeting()
    unrestricted_wf_transition_to(root['m'], 'ongoing')
    root['m']['ai'] = ai = AgendaItem()
    unrestricted_wf_transition_to(ai, 'upcoming')
    unrestricted_wf_transition_to(ai, 'ongoing')
    #Setup poll
    ai['poll'] = Poll()
    poll = ai['poll']
    #Add proposals
    p1 = Proposal(creators = ['dummy'], text = 'first proposal')
    p1.uid = 'p1uid' #To make it simpler to test against
    ai['p1'] = p1
    p2 = Proposal(creators = ['dummy'], text = 'second proposal')
    p2.uid = 'p2uid'
    ai['p2'] = p2
    p3 = Proposal(creators = ['dummy'], text = 'third proposal')
    p3.uid = 'p3uid'
    ai['p3'] = p3
    #Select proposals for this poll
    poll.proposal_uids = (p1.uid, p2.uid, p3.uid)
    #Set poll as ongoing
    unrestricted_wf_transition_to(poll, 'upcoming')
    unrestricted_wf_transition_to(poll, 'ongoing')
    return poll
Exemple #16
0
 def _fixture(self):
     from voteit.core.models.user import User
     self.config.scan('voteit.core.schemas.user')
     root = bootstrap_and_fixture(self.config)
     root['users']['dummy'] = user = User(password = '******')
     root['users']['other'] = User(password = '******')
     return user
Exemple #17
0
 def _fixture(self):
     from voteit.core.models.user import User
     root = bootstrap_and_fixture(self.config)
     root.users['dummy1'] = User(title='Dummy 1')
     root.users['dummy2'] = User(title='Dummy 2')
     root.users['dummy3'] = User(title='Dummy 3')
     return root.users
Exemple #18
0
 def test_meeting_state(self):
     from voteit.core.models.meeting import Meeting
     root = bootstrap_and_fixture(self.config)
     meeting = root['m'] = Meeting()
     request = testing.DummyRequest()
     obj = self._cut(meeting, request)
     self.assertEqual(obj.meeting_state, u'upcoming')
Exemple #19
0
 def _fixture(self):
     from voteit.core.models.meeting import Meeting
     from voteit.core.models.agenda_item import AgendaItem        
     root = bootstrap_and_fixture(self.config)
     root['m'] = Meeting() 
     root['m']['ai'] = AgendaItem()
     return root
Exemple #20
0
 def test_navigation_section_root(self):
     self.config.testing_securitypolicy(userid="dummy", permissive=True)
     context = bootstrap_and_fixture(self.config)
     request = testing.DummyRequest()
     va = _va(title="Upcoming", state="upcoming")
     api = _api(context, request)
     response = self._fut(context, request, va, api=api)
     self.assertIn("Upcoming", response)
 def _fixture(self):
     from voteit.core.models.proposal import Proposal
     self.config.include('voteit.core.testing_helpers.register_catalog')
     self.config.include(
         'voteit.core.testing_helpers.register_security_policies')
     root = bootstrap_and_fixture(self.config)
     root['p'] = Proposal()
     return root['p']
Exemple #22
0
 def _fixture(self):
     self.config.include('arche.testing')
     self.config.registry.settings['voteit.liquid.type'] = 'simple'
     self.config.include('voteit.liquid')
     self.config.testing_securitypolicy('jane', permissive = True)
     root = bootstrap_and_fixture(self.config)
     root['m'] = Meeting()
     return root['m']
Exemple #23
0
 def test_meeting_url(self):
     from voteit.core.models.meeting import Meeting
     root = bootstrap_and_fixture(self.config)
     meeting = root['m'] = Meeting()
     request = testing.DummyRequest()
     obj = self._cut(meeting, request)
     #example.com is from Pyramids testing env
     self.assertEqual(obj.meeting_url, 'http://example.com/m/')
Exemple #24
0
 def _fixture(self):
     from voteit.core.models.agenda_item import AgendaItem
     from voteit.core.models.meeting import Meeting
     from voteit.core.models.proposal import Proposal
     root = bootstrap_and_fixture(self.config)
     root['m'] = meeting = Meeting()
     meeting['ai'] = ai = AgendaItem()
     return ai
 def _fixture(self):
     from voteit.core.models.user import User
     root = bootstrap_and_fixture(self.config)
     root.users['dummy1'] = User(title='Dummy 1')
     root.users['dummy2'] = User(title='Dummy 2')
     root.users['dummy3'] = User(title='Dummy 3', email='*****@*****.**')
     root.users['dummy3'].set_password('dummy1234')
     return root.users
Exemple #26
0
 def _fixture(self):
     self.config.include('pyramid_mailer.testing')
     from voteit.core.models.user import User
     root = bootstrap_and_fixture(self.config)
     root['users']['dummy'] = user = User(password = '******')
     request = testing.DummyRequest()
     user.new_request_password_token(request)
     return root
Exemple #27
0
def _fixture(config):
    from voteit.core.models.meeting import Meeting
    config.testing_securitypolicy(userid='dummy', permissive=True)
    config.include('voteit.core.testing_helpers.register_catalog')
    root = bootstrap_and_fixture(config)
    root['users']['admin'].set_field_value('about_me', u"The story of an administrator")
    root['m'] = Meeting()
    return root
Exemple #28
0
 def test_get_user_by_email(self):
     self.config.include('arche.models.catalog')
     root = bootstrap_and_fixture(self.config)
     from voteit.core.models.user import User
     obj = root['users']
     obj['user'] = User(email = '*****@*****.**', first_name = 'Anders')
     res = obj.get_user_by_email('*****@*****.**')
     self.assertEqual(res.first_name, 'Anders')
 def test_action_contact_no_meeting(self):
     context = bootstrap_and_fixture(self.config)
     request = testing.DummyRequest()
     va = self._va()
     api = self._api(context, request)
     from voteit.core.views.components.help_actions import action_contact
     response = action_contact(context, request, va, api=api)
     self.assertEqual('', response)
 def test_navigation_section_root(self):
     self.config.testing_securitypolicy(userid='dummy', permissive=True)
     context = bootstrap_and_fixture(self.config)
     request = testing.DummyRequest()
     va = _va(title='Upcoming', state='upcoming')
     api = _api(context, request)
     response = self._fut(context, request, va, api=api)
     self.assertIn('Upcoming', response)
 def _fixture(self):
     from voteit.core.models.agenda_item import AgendaItem
     from voteit.core.models.meeting import Meeting
     root = bootstrap_and_fixture(self.config)
     root['users']['admin'].email = '*****@*****.**'
     root['m'] = meeting = Meeting()
     meeting['ai'] = ai = AgendaItem()
     return ai
Exemple #32
0
 def test_action_contact_no_meeting(self):
     context = bootstrap_and_fixture(self.config)
     request = testing.DummyRequest()
     va = self._va()
     api = self._api(context, request)
     from voteit.core.views.components.help_actions import action_contact
     response = action_contact(context, request, va, api=api)
     self.assertEqual('', response)
def _fixture(config):
    from voteit.core.models.meeting import Meeting
    config.include('arche.testing')
    config.include('voteit.core.schemas.contact')
    config.include('pyramid_mailer.testing')
    root = bootstrap_and_fixture(config)
    root['m'] = Meeting()
    return root
Exemple #34
0
 def test_meeting_url(self):
     from voteit.core.models.meeting import Meeting
     root = bootstrap_and_fixture(self.config)
     meeting = root['m'] = Meeting()
     request = testing.DummyRequest()
     obj = self._cut(meeting, request)
     #example.com is from Pyramids testing env
     self.assertEqual(obj.meeting_url, 'http://example.com/m/')
Exemple #35
0
 def test_get_user_by_email(self):
     self.config.include('arche.models.catalog')
     root = bootstrap_and_fixture(self.config)
     from voteit.core.models.user import User
     obj = root['users']
     obj['user'] = User(email='*****@*****.**', first_name='Anders')
     res = obj.get_user_by_email('*****@*****.**')
     self.assertEqual(res.first_name, 'Anders')
Exemple #36
0
 def _fixture(self):
     from voteit.core.testing_helpers import bootstrap_and_fixture
     from voteit.core.testing_helpers import register_catalog
     self.config.registry.settings[
         'default_timezone_name'] = "Europe/Stockholm"
     register_catalog(self.config)
     root = bootstrap_and_fixture(self.config)
     return root
Exemple #37
0
 def test_get_userinfo_url(self):
     from voteit.core.models.meeting import Meeting
     root = bootstrap_and_fixture(self.config)
     meeting = root['m'] = Meeting()
     request = testing.DummyRequest()
     obj = self._cut(meeting, request)
     #example.com is from Pyramids testing suite
     self.assertEqual(obj.get_userinfo_url('somebody'), 'http://example.com/m/_userinfo?userid=somebody')
def _fixture(config):
    from voteit.core.models.meeting import Meeting
    config.testing_securitypolicy(userid='dummy', permissive=True)
    config.include('voteit.core.testing_helpers.register_catalog')
    root = bootstrap_and_fixture(config)
    root['users']['admin'].about_me = u"The story of an administrator"
    root['m'] = Meeting()
    return root
 def _fixture(self):
     from voteit.core.models.meeting import Meeting
     from voteit.core.models.agenda_item import AgendaItem
     from voteit.core.models.user import User
     root = bootstrap_and_fixture(self.config)
     root.users['some_user'] = User() 
     root['m'] = Meeting()
     root['m']['ai'] = AgendaItem()
     return root['m']['ai']
Exemple #40
0
 def test_copy_users_and_perms(self):
     root = bootstrap_and_fixture(self.config)
     root['m1'] = m1 = self._cut()
     m1.add_groups('first', ['role:A', 'role:B'])
     m1.add_groups('second', ['role:A', 'role:C'])
     root['m2'] = m2 = self._cut()
     m2.copy_users_and_perms('m1')
     self.assertEqual(m1.get_security(), m2.get_security())
     self.assertEqual(m2.get_groups('second'), ('role:A', 'role:C'))
Exemple #41
0
 def _agenda_item_with_proposals_fixture(self):
     """ Create an agenda item with a poll and two proposals. """
     from voteit.core.models.agenda_item import AgendaItem
     from voteit.core.models.proposal import Proposal
     root = bootstrap_and_fixture(self.config)
     root['ai'] = agenda_item = AgendaItem()
     agenda_item['prop1'] = Proposal()
     agenda_item['prop2'] = Proposal()
     return agenda_item
 def _fixture(self):
     from voteit.core.models.meeting import Meeting
     self.config.include('arche.models.catalog')
     self.config.include('voteit.core.models.catalog')
     root = bootstrap_and_fixture(self.config)
     self.config.include('voteit.core.models.invite_ticket')
     root['m'] = Meeting()
     root['users']['admin'].email = '*****@*****.**'
     return root
Exemple #43
0
 def _fixture(self):
     from voteit.core.models.user import User
     self.config.scan('voteit.core.schemas.user')  #Login / register form
     root = bootstrap_and_fixture(self.config)
     root.users['dummy1'] = User(title='Dummy 1')
     root.users['dummy2'] = User(title='Dummy 2')
     root.users['dummy3'] = User(title='Dummy 3', email='*****@*****.**')
     root.users['dummy3'].set_password('dummy1234')
     return root
 def _fixture(self):
     from voteit.core.models.meeting import Meeting
     self.config.include('arche.models.catalog')
     self.config.include('voteit.core.models.catalog')
     root = bootstrap_and_fixture(self.config)
     self.config.include('voteit.core.models.invite_ticket')
     root['m'] = Meeting()
     root['users']['admin'].email = '*****@*****.**'
     return root
Exemple #45
0
 def test_get_user(self):
     root = bootstrap_and_fixture(self.config)
     request = testing.DummyRequest()
     obj = self._cut(root, request)
     self.failIf(hasattr(request, '_user_lookup_cache'))
     user = obj.get_user('admin')
     from voteit.core.models.interfaces import IUser
     self.failUnless(IUser.providedBy(user))
     self.assertEqual(user, request._user_lookup_cache['admin'])
Exemple #46
0
 def test_get_user(self):
     root = bootstrap_and_fixture(self.config)
     request = testing.DummyRequest()
     obj = self._cut(root, request)
     self.failIf(hasattr(request, '_user_lookup_cache'))
     user = obj.get_user('admin')
     from voteit.core.models.interfaces import IUser
     self.failUnless(IUser.providedBy(user))
     self.assertEqual(user, request._user_lookup_cache['admin'])
Exemple #47
0
 def test_get_userinfo_url(self):
     from voteit.core.models.meeting import Meeting
     root = bootstrap_and_fixture(self.config)
     meeting = root['m'] = Meeting()
     request = testing.DummyRequest()
     obj = self._cut(meeting, request)
     #example.com is from Pyramids testing suite
     self.assertEqual(obj.get_userinfo_url('somebody'),
                      'http://example.com/m/_userinfo?userid=somebody')
Exemple #48
0
 def _fixture(self):
     from voteit.core.models.user import User
     self.config.scan('voteit.core.schemas.user') #Login / register form
     root = bootstrap_and_fixture(self.config)
     root.users['dummy1'] = User(title='Dummy 1')
     root.users['dummy2'] = User(title='Dummy 2')
     root.users['dummy3'] = User(title='Dummy 3', email='*****@*****.**')
     root.users['dummy3'].set_password('dummy1234')
     return root
 def test_copy_users_and_perms(self):
     root = bootstrap_and_fixture(self.config)
     root['m1'] = m1 = self._cut()
     m1.add_groups('first', ['role:A', 'role:B'])
     m1.add_groups('second', ['role:A', 'role:C'])
     root['m2'] = m2 = self._cut()
     m2.copy_users_and_perms('m1')
     self.assertEqual(m1.get_security(), m2.get_security())
     self.assertEqual(m2.get_groups('second'), ('role:A', 'role:C'))
Exemple #50
0
 def _agenda_item_with_proposals_fixture(self):
     """ Create an agenda item with a poll and two proposals. """
     from voteit.core.models.agenda_item import AgendaItem
     from voteit.core.models.proposal import Proposal
     root = bootstrap_and_fixture(self.config)
     root['ai'] = agenda_item = AgendaItem()
     agenda_item['prop1'] = Proposal()
     agenda_item['prop2'] = Proposal()
     return agenda_item
    def test_polls_menu_no_meeting(self):
        context = bootstrap_and_fixture(self.config)
        request = testing.DummyRequest()
        va = self._va(title="Poll")
        api = self._api(context, request)
        from voteit.core.views.components.meeting_actions import polls_menu

        response = polls_menu(context, request, va, api=api)
        self.assertEqual("", response)
 def _fixture(self):
     from voteit.core.models.meeting import Meeting
     from voteit.core.models.agenda_item import AgendaItem
     from voteit.core.models.user import User
     root = bootstrap_and_fixture(self.config)
     root.users['some_user'] = User()
     root['m'] = Meeting()
     root['m']['ai'] = AgendaItem()
     return root['m']['ai']
Exemple #53
0
 def _make_obj(self):
     from voteit.core.plugins.majority_poll import MajorityPollPlugin
     from voteit.core.models.poll import Poll
     from voteit.core.models.agenda_item import AgendaItem
     self.config.include('arche.testing.catalog')
     self.root = bootstrap_and_fixture(self.config)
     self.root['ai'] = ai = AgendaItem()
     ai['poll'] = self.poll = Poll()
     return MajorityPollPlugin( ai['poll'] )
Exemple #54
0
 def test_resolve_catalog_docid(self):
     register_catalog(self.config)
     self.config.testing_securitypolicy('admin', permissive=True)
     root = bootstrap_and_fixture(self.config)
     from voteit.core.models.meeting import Meeting
     root['m'] = Meeting(title='Hello world')
     request = testing.DummyRequest()
     obj = self._cut(root, request)
     docid = root.catalog.search(title='Hello world')[1][0]
     self.assertEqual(obj.resolve_catalog_docid(docid), root['m'])
Exemple #55
0
 def _fixture(self):
     self.config.include('pyramid_mailer.testing')
     from voteit.core.models.agenda_item import AgendaItem
     from voteit.core.models.meeting import Meeting
     from voteit.core.models.proposal import Proposal
     root = bootstrap_and_fixture(self.config)
     root['users']['admin'].set_field_value('email', '*****@*****.**')
     root['m'] = meeting = Meeting()
     meeting['ai'] = ai = AgendaItem()
     return ai
Exemple #56
0
 def test_get_metadata_for_query(self):
     register_catalog(self.config)
     self.config.testing_securitypolicy('admin', permissive=True)
     root = bootstrap_and_fixture(self.config)
     from voteit.core.models.meeting import Meeting
     root['m'] = Meeting(title='Hello world')
     request = testing.DummyRequest()
     obj = self._cut(root, request)
     brain = obj.get_metadata_for_query(title='Hello world')[0]
     self.assertEqual(brain['title'], 'Hello world')