コード例 #1
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',))
コード例 #2
0
ファイル: test_poll.py プロジェクト: VoteIT/voteit.core
 def test_proposal_in_wrong_state(self):
     register_workflows(self.config)
     request = testing.DummyRequest()
     self.config.begin(request)
     from voteit.core.models.agenda_item import AgendaItem
     from voteit.core.models.proposal import Proposal
     from voteit.core.models.poll import Poll
     self.root['ai'] = ai = AgendaItem()
     ai['prop'] = Proposal()
     ai['poll'] = Poll()
     ai['poll'].proposal_uids = (ai['prop'].uid, )
     self.config.include('voteit.core.subscribers.poll')
     #Set state to something that doesn't have a transition to 'voting'
     ai['prop'].set_workflow_state(request, 'denied')
     self.assertRaises(HTTPForbidden, ai['poll'].set_workflow_state, request, 'upcoming')
コード例 #3
0
ファイル: test_poll.py プロジェクト: VoteIT/voteit.core
 def test_change_states_proposals(self):
     from voteit.core.models.agenda_item import AgendaItem
     from voteit.core.models.proposal import Proposal
     from voteit.core.models.poll import Poll
     register_workflows(self.config)
     request = testing.DummyRequest()
     self.config.begin(request)
     self.root['ai'] = ai = AgendaItem()
     ai['prop1'] = Proposal()
     ai['prop2'] = Proposal()
     ai['poll'] = Poll()
     ai['poll'].proposal_uids = (ai['prop1'].uid, ai['prop2'].uid)
     ai['poll'].set_workflow_state(request, 'upcoming')
     self.assertEqual(ai['prop1'].get_workflow_state(), 'voting')
     self.assertEqual(ai['prop2'].get_workflow_state(), 'voting')
コード例 #4
0
ファイル: test_poll.py プロジェクト: VoteIT/voteit.core
 def test_proposal_in_wrong_state(self):
     register_workflows(self.config)
     request = testing.DummyRequest()
     self.config.begin(request)
     from voteit.core.models.agenda_item import AgendaItem
     from voteit.core.models.proposal import Proposal
     from voteit.core.models.poll import Poll
     self.root['ai'] = ai = AgendaItem()
     ai['prop'] = Proposal()
     ai['poll'] = Poll()
     ai['poll'].proposal_uids = (ai['prop'].uid, )
     self.config.include('voteit.core.subscribers.poll')
     #Set state to something that doesn't have a transition to 'voting'
     ai['prop'].set_workflow_state(request, 'approved')
     self.assertRaises(HTTPForbidden, ai['poll'].set_workflow_state, request, 'upcoming')
コード例 #5
0
ファイル: test_poll.py プロジェクト: VoteIT/voteit.core
 def test_change_states_proposals(self):
     from voteit.core.models.agenda_item import AgendaItem
     from voteit.core.models.proposal import Proposal
     from voteit.core.models.poll import Poll
     register_workflows(self.config)
     request = testing.DummyRequest()
     self.config.begin(request)
     self.root['ai'] = ai = AgendaItem()
     ai['prop1'] = Proposal()
     ai['prop2'] = Proposal()
     ai['poll'] = Poll()
     ai['poll'].proposal_uids = (ai['prop1'].uid, ai['prop2'].uid)
     ai['poll'].set_workflow_state(request, 'upcoming')
     self.assertEqual(ai['prop1'].get_workflow_state(), 'voting')
     self.assertEqual(ai['prop2'].get_workflow_state(), 'voting')
コード例 #6
0
ファイル: test_poll.py プロジェクト: zhangqiang99/voteit.core
    def test_proposal_in_wrong_state(self):
        register_workflows(self.config)
        request = testing.DummyRequest()
        self.config = testing.setUp(registry=self.config.registry,
                                    request=request)

        from voteit.core.models.agenda_item import AgendaItem
        from voteit.core.models.proposal import Proposal
        from voteit.core.models.poll import Poll
        ai = AgendaItem()
        ai['prop'] = Proposal()
        ai['poll'] = Poll()
        ai['poll'].proposal_uids = (ai['prop'].uid, )

        #Set state to something that doesn't have a transition to 'voting'
        ai['prop'].set_workflow_state(request, 'approved')

        self.assertRaises(HTTPForbidden, ai['poll'].set_workflow_state,
                          request, 'upcoming')