"""
Tests for generation scripts.
"""

from zope.app.publication.zopepublication import ZopePublication
from zope.app.testing.setup import setUpAnnotations

from schooltool.app.app import SchoolToolApplication


class ContextStub(object):
    """Stub for the context argument passed to evolve scripts.

        >>> from zope.app.generations.utility import getRootFolder
        >>> context = ContextStub()
        >>> getRootFolder(context) is context.root_folder
        True
    """

    class ConnectionStub(object):
        def __init__(self, root_folder):
            self.root_folder = root_folder
        def root(self):
            return {ZopePublication.root_name: self.root_folder}

    def __init__(self):
        self.root_folder = SchoolToolApplication()
        self.connection = self.ConnectionStub(self.root_folder)


def provideAdapters():
    setUpAnnotations()

