def test_poll_creation(self):
        setRoles(self.portal, TEST_USER_ID, ('Manager',))
        workspaces = self.portal.restrictedTraverse("workspaces")
        ws = helpers.create_workspace(workspaces, 'ws1', title=u"Workspace 1")
        p = helpers.create_poll(ws, 'p1', title=u"Poll 1")

        self.assertTrue('p1' in ws)
        self.assertEqual(p, ws['p1'])
    def test_poll_publishing(self):
        setRoles(self.portal, TEST_USER_ID, ('Manager',))
        workspaces = self.portal.restrictedTraverse("workspaces")
        ws = helpers.create_workspace(workspaces, 'ws1', title=u"Workspace 1")
        p = helpers.create_poll(ws, 'p1', title=u"Poll 1")
        fileuploadcapable.publish_post(p)

        # polls are renamed when published:
        self.assertTrue('poll-1' in ws)
        self.assertEqual(p, ws['poll-1'])
    def test_project_featured_poll_creation(self):
        setRoles(self.portal, TEST_USER_ID, ('Manager',))
        workspaces = self.portal.restrictedTraverse("workspaces")
        ws = helpers.create_workspace(workspaces, 'ws1', title=u"Workspace 1")
        helpers.create_poll(ws, 'p3', title=u"Poll 3",
                            description=u"lucky poll",
                            options=["42", "88", "111"],
                            deadline="2016-07-04",
                            project_featured=True,
                            anonymous=False)

        self.assertTrue('p3' in ws)

        newPoll = ws['p3'];
        self.assertEqual(newPoll.id, 'p3');
        self.assertEqual(newPoll.title, u"Poll 3");
        self.assertEqual(newPoll.description, u"lucky poll");
        self.assertEqual(newPoll.options, ["42", "88", "111"]);
        self.assertEqual(newPoll.deadline, "2016-07-04");
        self.assertEqual(newPoll.project_featured, True);
        self.assertEqual(newPoll.anonymous, False);