def test_request_approval_published_version(self):
        """ request approval on already publish version must fail with
        exception.
        """
        content = self.root.test
        publisher = IPublicationWorkflow(content)
        publisher.publish()
        with self.assertRaises(VersioningError):
            publisher.request_approval("please approve.")

        self.assertFalse(content.is_approval_requested())
    def test_reject(self):
        """ reject request for approval (normal scenario)
        """
        content = self.root.test
        publisher = IPublicationWorkflow(content)
        publisher.request_approval('please approve')

        self.assertTrue(publisher.reject_request('u made a mistake'))
        self.assertFalse(content.is_approval_requested())

        with self.assertRaises(VersioningError):
            publisher.reject_request('u suck anyway')
    def test_request_approval(self):
        """ request approval on unapproved version (normal scenario)
        """
        content = self.root.test
        message = 'please approve.'
        publisher = IPublicationWorkflow(content)
        publisher.request_approval(message)

        self.assertTrue(content.is_approval_requested())

        with self.assertRaises(VersioningError):
            publisher.request_approval("please approve.")
    def test_reject_published(self):
        """ rejecting a published content must fail.
        """
        content = self.root.test
        publisher = IPublicationWorkflow(content)
        publisher.request_approval('please approve')

        publisher.publish()

        self.assertFalse(content.is_approval_requested())

        with self.assertRaises(VersioningError):
            publisher.reject_request('u suck anyway')
    def test_withdraw(self):
        """ withdraw request for approval (normal scenario)
        """
        content = self.root.test
        message = 'please approve.'
        publisher = IPublicationWorkflow(content)
        publisher.request_approval(message)

        self.assertTrue(publisher.withdraw_request('made a mistake'))
        self.assertFalse(content.is_approval_requested())

        with self.assertRaises(VersioningError):
            publisher.withdraw_request('make an other mistake')