コード例 #1
0
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
コード例 #2
0
ファイル: tests.py プロジェクト: VoteIT/voteit.stv
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
コード例 #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)
コード例 #4
0
 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'
     })
コード例 #5
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
コード例 #6
0
ファイル: test_unread.py プロジェクト: tobsan/voteit.core
 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']
コード例 #7
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
コード例 #8
0
ファイル: test_api.py プロジェクト: tobsan/voteit.core
 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)
コード例 #9
0
ファイル: test_api.py プロジェクト: tobsan/voteit.core
 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')
コード例 #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
コード例 #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
コード例 #12
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
コード例 #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
コード例 #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
コード例 #15
0
ファイル: tests.py プロジェクト: VoteIT/voteit.schulze
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
コード例 #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
コード例 #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
コード例 #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')
コード例 #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
コード例 #20
0
ファイル: test_navigation.py プロジェクト: VoteIT/voteit.core
 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)
コード例 #21
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']
コード例 #22
0
ファイル: tests.py プロジェクト: VoteIT/voteit.liquid
 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']
コード例 #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/')
コード例 #24
0
ファイル: test_helpers.py プロジェクト: tobsan/voteit.core
 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
コード例 #25
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', email='*****@*****.**')
     root.users['dummy3'].set_password('dummy1234')
     return root.users
コード例 #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
コード例 #27
0
ファイル: test_user_info.py プロジェクト: waytai/voteit.core
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
コード例 #28
0
ファイル: test_users.py プロジェクト: VoteIT/voteit.core
 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')
コード例 #29
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)
コード例 #30
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)
コード例 #31
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['users']['admin'].email = '*****@*****.**'
     root['m'] = meeting = Meeting()
     meeting['ai'] = ai = AgendaItem()
     return ai
コード例 #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)
コード例 #33
0
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
コード例 #34
0
ファイル: test_api.py プロジェクト: tobsan/voteit.core
 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/')
コード例 #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')
コード例 #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
コード例 #37
0
ファイル: test_api.py プロジェクト: tobsan/voteit.core
 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')
コード例 #38
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'].about_me = u"The story of an administrator"
    root['m'] = Meeting()
    return root
コード例 #39
0
 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']
コード例 #40
0
ファイル: test_meeting.py プロジェクト: tobsan/voteit.core
 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'))
コード例 #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
コード例 #42
0
 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
コード例 #43
0
ファイル: test_site.py プロジェクト: zhangqiang99/voteit.core
 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
コード例 #44
0
 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
コード例 #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'])
コード例 #46
0
ファイル: test_api.py プロジェクト: tobsan/voteit.core
 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'])
コード例 #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')
コード例 #48
0
ファイル: test_site.py プロジェクト: tobsan/voteit.core
 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
コード例 #49
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'))
コード例 #50
0
ファイル: test_poll.py プロジェクト: VoteIT/voteit.core
 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
コード例 #51
0
    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)
コード例 #52
0
 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']
コード例 #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'] )
コード例 #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'])
コード例 #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
コード例 #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')