<commit_before># Copyright (c) <NAME>
# See LICENSE for details.

"""Test the directory monitoring code"""

import os
import shutil
import unittest

from zope import interface
from zope.interface import verify

from ncolony import directory_monitor
from ncolony import interfaces

class EventRecorder(object):

    """An event receiver that just records the events"""

    interface.implements(interfaces.IMonitorEventReceiver)

    def __init__(self):
        """Initialize the event list"""
        self.events = []

    def add(self, name, contents):
        """Get an add event"""
        self.events.append(('ADD', name, contents))

    def remove(self, name):
        """Get a remove event"""
        self.events.append(('REMOVE', name))

    def message(self, contents):
        """Get a new message event"""
        self.events.append(('MESSAGE', contents))

## pylint: disable=too-few-public-methods
class EventRecorderNoAdd(object):

    """Dummy bad implementation of event receiver interface"""

    interface.implements(interfaces.IMonitorEventReceiver)

    def remove(self, name):
        """Dummy remove method"""
        pass

class EventRecorderNoRemove(object):

    """Dummy bad implementation of event receiver interface"""

    interface.implements(interfaces.IMonitorEventReceiver)

    def add(self, name, content):
        """Dummy add method"""
        pass
## pylint: enable=too-few-public-methods


class TestReceiverIface(unittest.TestCase):

    """Test that the right classes implement the interface"""

    def test_recorder_is_good(self):
        """Test our recorder implements the interface"""
        self.assertTrue(verify.verifyObject(interfaces.IMonitorEventReceiver, EventRecorder()))

    def test_no_add_bad(self):
        """Test you need 'add' to implement the interface"""
        with self.assertRaises(verify.BrokenImplementation):
            verify.verifyObject(interfaces.IMonitorEventReceiver, EventRecorderNoAdd())<commit_msg>stuff<commit_after># Copyright (c) <NAME>
# See LICENSE for details.

"""Test the directory monitoring code"""

import os
import shutil
import unittest

from zope import interface
from zope.interface import verify

from ncolony import directory_monitor
from ncolony import interfaces

@interface.implementer(interfaces.IMonitorEventReceiver)
class EventRecorder(object):

    """An event receiver that just records the events"""

    def __init__(self):
        """Initialize the event list"""
        self.events = []

    def add(self, name, contents):
        """Get an add event"""
        self.events.append(('ADD', name, contents))

    def remove(self, name):
        """Get a remove event"""
        self.events.append(('REMOVE', name))

    def message(self, contents):
        """Get a new message event"""
        self.events.append(('MESSAGE', contents))

## pylint: disable=too-few-public-methods
@interface.implementer(interfaces.IMonitorEventReceiver)
class EventRecorderNoAdd(object):

    """Dummy bad implementation of event receiver interface"""

    def remove(self, name):
        """Dummy remove method"""
        pass

@interface.implementer(interfaces.IMonitorEventReceiver)
class EventRecorderNoRemove(object):

    """Dummy bad implementation of event receiver interface"""

    def add(self, name, content):
        """Dummy add method"""
        pass
## pylint: enable=too-few-public-methods


class TestReceiverIface(unittest.TestCase):

    """Test that the right classes implement the interface"""

    def test_recorder_is_good(self):
        """Test our recorder implements the interface"""
        self.assertTrue(verify.verifyObject(interfaces.IMonitorEventReceiver, EventRecorder()))

    def test_no_add_bad(self):
        """Test you need 'add' to implement the interface"""
        with self.assertRaises(verify.BrokenImplementation):
            verify.verifyObject(interfaces.IMonitorEventReceiver, EventRecorderNoAdd())
{'fraction_non_alphanumeric': 0.10992637725310993, 'fraction_numerical': 0.0, 'mean_word_length': 3.852216748768473, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2124937', 'n_tokens_mistral': 1079, 'n_tokens_neox': 1043, 'n_words': 311}