<commit_before>from zeit.cms.workflow.interfaces import CAN_PUBLISH_SUCCESS
from zeit.cms.workflow.interfaces import CAN_PUBLISH_ERROR
from zeit.cms.workflow.interfaces import PRIORITY_DEFAULT
from zeit.cms.workflow.interfaces import PRIORITY_LOW
import zeit.cms.interfaces
import zeit.cms.workflow.interfaces
import zope.component
import zope.interface
import zope.testing.cleanup


class MockPublish(object):
    """A mock publisher."""

    zope.component.adapts(zeit.cms.interfaces.ICMSContent)
    zope.interface.implements(zeit.cms.workflow.interfaces.IPublish)

    def __init__(self, context):
        self.context = context

    def publish(self, priority=PRIORITY_DEFAULT, async=True, **kw):
        can_publish = zeit.cms.workflow.interfaces.IPublishInfo(
            self.context).can_publish()
        if can_publish != CAN_PUBLISH_SUCCESS:
            raise zeit.cms.workflow.interfaces.PublishingError(
                "Cannot publish.")
        zope.event.notify(
            zeit.cms.workflow.interfaces.BeforePublishEvent(self.context,
                                                            self.context))
        print "Publishing: %s" % self.context.uniqueId
        _published[self.context.uniqueId] = True
        zope.event.notify(
            zeit.cms.workflow.interfaces.PublishedEvent(self.context,
                                                        self.context))

    def retract(self, priority=PRIORITY_DEFAULT, async=True, **kw):
        zope.event.notify(
            zeit.cms.workflow.interfaces.BeforeRetractEvent(self.context,
                                                            self.context))
        print "Retracting: %s" % self.context.uniqueId
        _published[self.context.uniqueId] = False
        zope.event.notify(
            zeit.cms.workflow.interfaces.RetractedEvent(self.context,
                                                        self.context))

    def publish_multiple(
            self, objects, priority=PRIORITY_LOW, async=True, **kw):
        for obj in objects:
            obj = zeit.cms.interfaces.ICMSContent(obj)
            self.publish(obj, priority, async)


class MockPublishInfo(object):

    zope.component.adapts(zeit.cms.interfaces.ICMSContent)
    zope.interface.implements(zeit.cms.workflow.interfaces.IPublishInfo)

    error_messages = ()
    date_print_published = None
    last_modified_by = u'testuser'
    last_published_by = u'testuser'

    def __init__(self, context):
        self.context = context
<commit_msg>Fix mock multiple_publish<commit_after>from zeit.cms.workflow.interfaces import CAN_PUBLISH_SUCCESS
from zeit.cms.workflow.interfaces import CAN_PUBLISH_ERROR
from zeit.cms.workflow.interfaces import PRIORITY_DEFAULT
from zeit.cms.workflow.interfaces import PRIORITY_LOW
import zeit.cms.interfaces
import zeit.cms.workflow.interfaces
import zope.component
import zope.interface
import zope.testing.cleanup


class MockPublish(object):
    """A mock publisher."""

    zope.component.adapts(zeit.cms.interfaces.ICMSContent)
    zope.interface.implements(zeit.cms.workflow.interfaces.IPublish)

    def __init__(self, context):
        self.context = context

    def publish(self, priority=PRIORITY_DEFAULT, async=True, object=None,  **kw):
        if object:
            self.context = object
        can_publish = zeit.cms.workflow.interfaces.IPublishInfo(
            self.context).can_publish()
        if can_publish != CAN_PUBLISH_SUCCESS:
            raise zeit.cms.workflow.interfaces.PublishingError(
                "Cannot publish.")
        zope.event.notify(
            zeit.cms.workflow.interfaces.BeforePublishEvent(self.context,
                                                            self.context))
        print "Publishing: %s" % self.context.uniqueId
        _published[self.context.uniqueId] = True
        zope.event.notify(
            zeit.cms.workflow.interfaces.PublishedEvent(self.context,
                                                        self.context))

    def retract(self, priority=PRIORITY_DEFAULT, async=True, **kw):
        zope.event.notify(
            zeit.cms.workflow.interfaces.BeforeRetractEvent(self.context,
                                                            self.context))
        print "Retracting: %s" % self.context.uniqueId
        _published[self.context.uniqueId] = False
        zope.event.notify(
            zeit.cms.workflow.interfaces.RetractedEvent(self.context,
                                                        self.context))

    def publish_multiple(
            self, objects, priority=PRIORITY_LOW, async=True, **kw):
        for obj in objects:
            obj = zeit.cms.interfaces.ICMSContent(obj)
            self.publish(priority, async, obj)


class MockPublishInfo(object):

    zope.component.adapts(zeit.cms.interfaces.ICMSContent)
    zope.interface.implements(zeit.cms.workflow.interfaces.IPublishInfo)

    error_messages = ()
    date_print_published = None
    last_modified_by = u'testuser'
    last_published_by = u'testuser'

    def __init__(self, context):
        self.context = context

{'fraction_non_alphanumeric': 0.0913715515554686, 'fraction_numerical': 0.0, 'mean_word_length': 2.30873786407767, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 16, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4528198', 'n_tokens_mistral': 1506, 'n_tokens_neox': 1411, 'n_words': 237}