def test_render_poll_state_info(self):
     from voteit.core.models.poll import Poll
     from voteit.core.views.api import APIView
     from voteit.core.testing_helpers import register_workflows
     register_workflows(self.config)
     self.config.include('pyramid_chameleon')
     self.config.registry.settings[
         'default_timezone_name'] = "Europe/Stockholm"
     self.config.include('voteit.core.models.date_time_util')
     self.config.scan('voteit.core.views.components.main')
     #root = active_poll_fixture(self.config)
     #poll = root['meeting']['ai']['poll']
     poll = Poll()
     from voteit.core.models.date_time_util import utcnow
     poll.set_field_value('start_time', utcnow())
     poll.set_field_value('end_time', utcnow())
     request = testing.DummyRequest()
     #obj = self._cut(poll, request)
     api = APIView(poll, request)
     res = render_view_action(poll,
                              request,
                              'main',
                              'poll_state_info',
                              api=api)
     #obj.get_poll_state_info(poll)
     self.assertIn('The poll starts', res)
Exemple #2
0
 def test_poll_state_change(self):
     register_workflows(self.config)
     root = self._fixture()
     meeting = root['m']
     ai = meeting['ai']
     meeting.set_workflow_state(self.request, 'upcoming')
     meeting.set_workflow_state(self.request, 'ongoing')
     ai.set_workflow_state(self.request, 'upcoming')
     ai.set_workflow_state(self.request, 'ongoing')
     from voteit.core.models.proposal import Proposal
     ai['p1'] = p1 = Proposal()
     ai['p2'] = p2 = Proposal()
     self.config.include('voteit.feed')
     from voteit.core.models.poll import Poll
     poll = Poll()
     poll.proposal_uids = (p1.uid, p2.uid)
     self.config.include('voteit.core.plugins.majority_poll')
     poll.set_field_value('poll_plugin', u'majority_poll')
     ai['p'] = poll
     poll.set_workflow_state(self.request, 'upcoming')
     poll.set_workflow_state(self.request, 'ongoing')
     adapter = self.config.registry.queryAdapter(meeting, IFeedHandler)
     self.assertEqual(len(adapter.feed_storage), 1)
     self.assertEqual(adapter.feed_storage[len(adapter.feed_storage)-1].tags, ('poll', 'ongoing',))
     poll.set_workflow_state(self.request, 'closed')
     self.assertEqual(len(adapter.feed_storage), 2)
     self.assertEqual(adapter.feed_storage[len(adapter.feed_storage)-1].tags, ('poll', 'closed',))
    def _make_poll(self):
        from voteit.core.models.poll import Poll
        poll = Poll()

        poll.set_field_value('proposals', set(self._make_proposal().uid))

        return poll
 def _make_poll(self):
     from voteit.core.models.poll import Poll
     poll = Poll()
     
     poll.set_field_value('proposals', set(self._make_proposal().uid))
     
     return poll
Exemple #5
0
 def _make_poll(self):
     from voteit.core.models.poll import Poll
     from voteit.core.models.proposal import Proposal
     self.config.include('voteit.core.plugins.majority_poll')
     poll = Poll()
     poll.set_field_value('poll_plugin', u'majority_poll')
     proposal = Proposal()
     poll.set_field_value('proposals', set(proposal.uid))
     return poll
Exemple #6
0
 def _make_poll(self):
     from voteit.core.models.poll import Poll
     from voteit.core.models.proposal import Proposal
     self.config.include(
         'voteit.core.testing_helpers.register_testing_poll')
     poll = Poll()
     poll.set_field_value('poll_plugin', "testing")
     proposal = Proposal()
     poll.set_field_value('proposals', set(proposal.uid))
     return poll
    def _make_poll(self):
        from voteit.core.models.poll import Poll
        from voteit.core.models.proposal import Proposal

        self.config.include('voteit.core.plugins.majority_poll')

        poll = Poll()
        poll.set_field_value('poll_plugin', u'majority_poll')

        proposal = Proposal()
        poll.set_field_value('proposals', set(proposal.uid))

        return poll
Exemple #8
0
 def _make_obj(self):
     """ Poll object need to be in the context of an Agenda Item to work properly
     """
     root = bootstrap_and_fixture(self.config)
     self.config.include('voteit.core.models.poll')
     from voteit.core.models.poll import Poll
     from voteit.core.models.proposal import Proposal
     from voteit.core.models.agenda_item import AgendaItem
     root['ai'] = ai = AgendaItem()
     poll = Poll()
     ai['prop'] = proposal = Proposal()
     poll.set_field_value('proposals', set(proposal.uid))
     ai['poll'] = poll
     return poll
Exemple #9
0
 def _make_obj(self):
     """ Poll object need to be in the context of an Agenda Item to work properly
     """
     root = bootstrap_and_fixture(self.config)
     self.config.include('voteit.core.models.poll')
     from voteit.core.models.poll import Poll
     from voteit.core.models.proposal import Proposal
     from voteit.core.models.agenda_item import AgendaItem
     root['ai'] = ai = AgendaItem()
     poll = Poll()
     ai['prop'] = proposal = Proposal()
     poll.set_field_value('proposals', set(proposal.uid))
     ai['poll'] = poll
     return poll
Exemple #10
0
    def _make_obj(self):
        """ Poll object need to be in the context of an Agenda Item to work properly
        """
        from voteit.core.models.poll import Poll
        poll = Poll()
        
        from voteit.core.models.proposal import Proposal
        proposal = Proposal()
        poll.set_field_value('proposals', set(proposal.uid))
        
        from voteit.core.models.agenda_item import AgendaItem
        ai = AgendaItem()
        ai['poll'] = poll

        return poll
Exemple #11
0
 def test_render_poll_state_info(self):
     from voteit.core.models.poll import Poll
     from voteit.core.views.api import APIView
     from voteit.core.testing_helpers import register_workflows
     register_workflows(self.config)
     self.config.registry.settings['default_timezone_name'] = "Europe/Stockholm"
     self.config.include('voteit.core.models.date_time_util')
     self.config.scan('voteit.core.views.components.main')
     #root = active_poll_fixture(self.config)
     #poll = root['meeting']['ai']['poll']
     poll = Poll()
     from voteit.core.models.date_time_util import utcnow
     poll.set_field_value('start_time', utcnow())
     poll.set_field_value('end_time', utcnow())
     request = testing.DummyRequest()
     #obj = self._cut(poll, request)
     api = APIView(poll, request)
     res = render_view_action(poll, request, 'main', 'poll_state_info', api = api)
     #obj.get_poll_state_info(poll)
     self.assertIn('The poll starts', res)