Esempio n. 1
0
    def setUp(self):
        cleanUp()

        from zope.interface import directlyProvides
        from karl.content.interfaces import IBlogEntry

        karltesting.registerSettings()

        # Create dummy site skel
        community = karltesting.DummyCommunity()
        site = community.__parent__.__parent__

        profiles = testing.DummyModel()
        site["profiles"] = profiles
        self.profile = profiles["member"] = karltesting.DummyProfile()
        profiles["creator"] = karltesting.DummyProfile()

        community["blog"] = testing.DummyModel()

        blogentry = testing.DummyModel(text="This is a test")
        community["blog"]["blogentry"] = blogentry
        blogentry["attachments"] = testing.DummyModel()
        blogentry.title = "Blog Entry"
        blogentry.docid = 0
        directlyProvides(blogentry, IBlogEntry)
        self.blogentry = blogentry

        blogentry["comments"] = comments = testing.DummyModel()
        self.comment = self._add_comment(blogentry)
Esempio n. 2
0
    def setUp(self):
        cleanUp()

        # Set up a dummy blog
        from karl.content.interfaces import IBlog
        from karl.testing import DummyCommunity
        from karl.testing import DummyProfile
        from zope.interface import directlyProvides

        community = DummyCommunity()
        blog = community["blog"] = testing.DummyModel()
        directlyProvides(blog, IBlog)
        blog.title = "Blog Title"

        site = community.__parent__.__parent__
        profiles = site["profiles"] = testing.DummyModel()
        chris = profiles["chris"] = DummyProfile()
        chris.title = "Chris Rossi"

        self.context = blog

        # Register dummy catalog
        from zope.interface import Interface
        from karl.models.interfaces import ICatalogSearch
        testing.registerAdapter(dummy_catalog_search, Interface,
                                ICatalogSearch)

        # Register blog entry adapter
        from karl.views.interfaces import IAtomEntry
        from karl.content.interfaces import IBlogEntry
        from karl.views.atom import GenericAtomEntry
        testing.registerAdapter(GenericAtomEntry, (IBlogEntry, Interface),
                                IAtomEntry)
        testing.registerDummyRenderer('karl.views:templates/atomfeed.pt')
Esempio n. 3
0
    def setUp(self):
        cleanUp()

        # Set up a dummy community files folder
        from karl.content.interfaces import ICommunityRootFolder
        from karl.testing import DummyCommunity
        from karl.testing import DummyProfile
        from zope.interface import directlyProvides

        community = DummyCommunity()
        files = community["files"] = testing.DummyModel()
        directlyProvides(files, ICommunityRootFolder)

        site = community.__parent__.__parent__
        profiles = site["profiles"] = testing.DummyModel()
        chris = profiles["chris"] = DummyProfile()
        chris.title = "Chris Rossi"

        self.context = files

        # Register dummy catalog
        from zope.interface import Interface
        from karl.models.interfaces import ICatalogSearch
        testing.registerAdapter(dummy_catalog_search, Interface,
                                ICatalogSearch)

        # Register atom entry adapter
        from karl.views.interfaces import IAtomEntry
        from karl.content.views.atom import CommunityFileAtomEntry
        testing.registerAdapter(CommunityFileAtomEntry, (Interface, Interface),
                                IAtomEntry)
        testing.registerDummyRenderer('karl.views:templates/atomfeed.pt')
Esempio n. 4
0
 def setUp(self):
     cleanUp()
     context = testing.DummyModel(sessions=DummySessions())
     self.context = context
     request = testing.DummyRequest()
     request.environ['repoze.browserid'] = '1'
     self.request = request
Esempio n. 5
0
 def setUp(self):
     self.r = Replacer()
     # test values for author info, requiring less setup
     self.r.replace('opencore.views.people.get_author_info',
                    lambda id,request: { 
             'title'  : 'Author title',
             'country' : 'Author country',
             'organization' : 'author org',
             'url' : 'author-url',
             'photo_url' : 'author-photo-url',
             })
     self.r.replace('opencore.views.forms.get_current_request',
                    lambda :self.request)
     self.r.replace('opencore.views.forms.authenticated_userid',
                    lambda request:'auth_user_id')
     
     testing.cleanUp()
     sessions = DummySessions()
     context = DummyProfile(sessions=sessions, **profile_data)
     context.title = 'title'
     context.__name__='admin'
     context.users = DummyUsers()
     context.users.add('admin','admin','password',())
     self.context = context
     request = testing.DummyRequest()
     request.api = get_template_api(context, request)
     request.context = context
     self.request = request
Esempio n. 6
0
    def setUp(self):
        cleanUp()

        from zope.interface import directlyProvides
        from karl.content.interfaces import ICommunityFile

        karltesting.registerSettings()

        # Create dummy site skel
        community = karltesting.DummyCommunity()
        site = community.__parent__.__parent__

        profiles = testing.DummyModel()
        site["profiles"] = profiles
        self.profile = profiles["member"] = karltesting.DummyProfile()
        profiles["creator"] = karltesting.DummyProfile()

        community["files"] = testing.DummyModel()

        f = testing.DummyModel(
            text="This is a test", description="Some description")
        community["files"]["file"] = f
        f.title = "An interesting file"
        f.docid = 0
        directlyProvides(f, ICommunityFile)
        self.f = f
        f.creator = "creator"
Esempio n. 7
0
    def setUp(self):
        cleanUp()

        self.root = root = octesting.DummyModel()
        root['profiles'] = profiles = octesting.DummyModel()
        root.users = octesting.DummyUsers()

        root['a'] = a = octesting.DummyModel(creator='chris')
        root['b'] = b = octesting.DummyModel(modified_by='chris')

        class DummySearchAdapter(object):
            def __init__(self, context):
                pass

            def __call__(self, **kw):
                resolver = lambda x: root.get(x)
                if kw.get('creator') == 'chris':
                    return 1, ['a'], resolver
                if kw.get('modified_by') == 'chris':
                    return 1, ['b'], resolver
                return 0, [], resolver

        from zope.interface import Interface
        from opencore.models.interfaces import ICatalogSearch
        testing.registerAdapter(DummySearchAdapter, (Interface, Interface),
                                ICatalogSearch)
        testing.registerAdapter(DummySearchAdapter, (Interface,),
                                ICatalogSearch)

        root.catalog = catalog = octesting.DummyModel()
        catalog['creator'] =  DummyCatalogIndex()
        catalog['modified_by'] =  DummyCatalogIndex()
Esempio n. 8
0
    def setUp(self):
        cleanUp()

        # Set up a dummy wiki
        from karl.content.interfaces import IWiki
        from karl.testing import DummyCommunity
        from karl.testing import DummyProfile
        from zope.interface import directlyProvides

        community = DummyCommunity()
        wiki = community["wiki"] = testing.DummyModel()
        directlyProvides(wiki, IWiki)
        wiki.title = "Wiki Title"

        site = community.__parent__.__parent__
        profiles = site["profiles"] = testing.DummyModel()
        chris = profiles["chris"] = DummyProfile()
        chris.title = "Chris Rossi"

        self.context = wiki

        # Register dummy catalog
        from zope.interface import Interface
        from karl.models.interfaces import ICatalogSearch

        testing.registerAdapter(dummy_catalog_search, Interface, ICatalogSearch)

        # Register atom entry adapter
        from karl.views.interfaces import IAtomEntry
        from karl.views.atom import GenericAtomEntry

        testing.registerAdapter(GenericAtomEntry, (Interface, Interface), IAtomEntry)
Esempio n. 9
0
    def setUp(self):
        cleanUp()

        # Set up a dummy calendar
        from karl.content.interfaces import ICalendar
        from karl.testing import DummyCommunity
        from karl.testing import DummyProfile
        from zope.interface import directlyProvides

        community = DummyCommunity()
        cal = community["calendar"] = testing.DummyModel()
        directlyProvides(cal, ICalendar)
        cal.title = "Calendar"

        site = community.__parent__.__parent__
        profiles = site["profiles"] = testing.DummyModel()
        chris = profiles["chris"] = DummyProfile()
        chris.title = "Chris Rossi"

        self.context = cal

        # Register dummy catalog
        from zope.interface import Interface
        from karl.models.interfaces import ICatalogSearch

        testing.registerAdapter(dummy_catalog_search, Interface, ICatalogSearch)

        # Register atom entry adapter
        from karl.views.interfaces import IAtomEntry
        from karl.content.views.atom import CalendarEventAtomEntry

        testing.registerAdapter(CalendarEventAtomEntry, (Interface, Interface), IAtomEntry)
Esempio n. 10
0
    def setUp(self):
        cleanUp()

        from karl.content.views import wiki

        self._save_transaction = wiki.transaction
        wiki.transaction = DummyTransactionManager()
Esempio n. 11
0
    def setUp(self):
        testing.cleanUp()

        self.context = context = testing.DummyModel()
        context.catalog = DummyCatalog()
        context['path'] = testing.DummyModel()
        context['path']['to'] = testing.DummyModel()
        context['path']['to']['item'] = testing.DummyModel()
Esempio n. 12
0
 def setUp(self):
     cleanUp()
     self._register()
     context = DummyNewsItem(sessions=DummySessions())
     context.title = 'Foo'
     self.context = context
     request = testing.DummyRequest()
     request.environ['repoze.browserid'] = '1'
     self.request = request
Esempio n. 13
0
 def setUp(self):
     testing.cleanUp()
     request = testing.DummyRequest()
     request.environ['repoze.browserid'] = '1'
     self.request = request
     sessions = DummySessions()
     context = testing.DummyModel(sessions=sessions)
     self.context = context
     registerLayoutProvider()
Esempio n. 14
0
 def setUp(self):
     cleanUp()
     self.parent = DummyModel(title='dummyparent', sessions=DummySessions())
     self.context = DummyModel(title='dummytitle', text='dummytext')
     self.context['attachments'] = DummyModel()
     self.parent['child'] = self.context
     self.parent.catalog = DummyCatalog()
     request = testing.DummyRequest()
     request.environ['repoze.browserid'] = '1'
     self.request = request
Esempio n. 15
0
    def setUp(self):
        cleanUp()

        self.template_fn = "templates/addedit_referencesection.pt"

        self.parent = DummyModel(title="dummyparent")
        self.context = DummyModel(title="dummytitle", description="dummydescription")
        self.context["attachments"] = DummyModel()
        self.parent["child"] = self.context
        self.parent.catalog = DummyCatalog()
Esempio n. 16
0
    def setUp(self):
        testing.cleanUp()

        testing.registerSettings(mailin_trace_file='foo/bar')

        from karl.content.views import blog
        self._save_os = blog.os
        blog.os = self

        self._exists = False
Esempio n. 17
0
 def setUp(self):
     testing.cleanUp()
     from karl.models.interfaces import ISite
     site = testing.DummyModel(sessions=DummySessions())
     directlyProvides(site, ISite)
     self.context = site
     request = testing.DummyRequest()
     request.environ['repoze.browserid'] = '1'
     self.request = request
     testing.registerDummyRenderer('karl.views:forms/templates/snippets.pt')
Esempio n. 18
0
 def setUp(self):
     """ This sets up the application registry with the
     registrations your application declares in its configure.zcml
     (including dependent registrations for repoze.bfg itself).
     """
     testing.cleanUp()
     import bingo
     import zope.configuration.xmlconfig
     zope.configuration.xmlconfig.file('configure.zcml',
                                       package=bingo)
Esempio n. 19
0
 def setUp(self):
     cleanUp()
     container = testing.DummyModel(sessions=DummySessions())
     container['intranets'] = testing.DummyModel()
     context = DummyCommunity('Intranet', 'description', 'text',
                              'creator')
     container['intranet'] = context
     self.context = context
     request = testing.DummyRequest()
     request.environ['repoze.browserid'] = '1'
     self.request = request
Esempio n. 20
0
    def setUp(self):
        cleanUp()

        # When you see:
        #   AttributeError: 'NoneType' object has no attribute 'url'
        # ...it is often because you are pointed at the wrong .pt
        self.template_fn = 'templates/show_page.pt'

        self.parent = DummyModel(title='dummyparent')
        self.context = DummyModel(title='dummytitle', text='dummytext')
        self.context['attachments'] = DummyModel()
        self.parent['child'] = self.context
        self.parent.catalog = DummyCatalog()
Esempio n. 21
0
    def setUp(self):
        cleanUp()

        # When you see:
        #   AttributeError: 'NoneType' object has no attribute 'url'
        # ...it is often because you are pointed at the wrong .pt
        self.template_fn = "templates/show_referencemanual.pt"

        self.parent = DummyModel(title="dummyparent")
        self.context = DummyModel(title="dummytitle", text="dummytext")
        self.context.ordering = DummyOrdering()
        self.parent["child"] = self.context
        self.parent.catalog = DummyCatalog()
Esempio n. 22
0
 def setUp(self):
     testing.cleanUp()
     registerContentFactory(DummyImageFile,ICommunityFile)
     self.cstruct = {
         'fp': StringIO('some image data'),
         'mimetype': 'image/jpeg',
         'filename': u'test.jpg',
         }
     self.context = DummyProfile()
     self.authenticated_userid = Mock()
     self.authenticated_userid.return_value = 'auser'
     self.r = Replacer()
     self.r.replace('opencore.views.utils.authenticated_userid',
                    self.authenticated_userid)
Esempio n. 23
0
    def setUp(self):
        cleanUp()
        # Register mail utility
        from repoze.sendmail.interfaces import IMailDelivery
        from karl.testing import DummyMailer
        self.mailer = DummyMailer()
        testing.registerUtility(self.mailer, IMailDelivery)

        # Register BlogCommentAlert adapter
        from karl.models.interfaces import IProfile
        from karl.models.interfaces import IComment
        from karl.content.views.adapters import BlogCommentAlert
        from karl.utilities.interfaces import IAlert
        from repoze.bfg.interfaces import IRequest
        testing.registerAdapter(BlogCommentAlert,
                                (IComment, IProfile, IRequest),
                                IAlert)

        # Register IShowSendAlert adapter
        self.show_sendalert = True
        from karl.content.views.interfaces import IShowSendalert
        class DummyShowSendalert(object):
            def __init__(myself, context, request):
                myself.show_sendalert = self.show_sendalert

        testing.registerAdapter(DummyShowSendalert, (Interface, Interface),
                                IShowSendalert)

        # Create dummy site skel
        from karl.testing import DummyCommunity
        from karl.testing import DummyProfile
        community = DummyCommunity()
        site = community.__parent__.__parent__
        site.sessions = DummySessions()
        profiles = testing.DummyModel()
        site["profiles"] = profiles
        profiles["a"] = DummyProfile()
        profiles["b"] = DummyProfile()
        profiles["c"] = DummyProfile()
        community.member_names = set(["b", "c",])
        community.moderator_names = set(["a",])
        blog = testing.DummyModel()
        community["blog"] = blog
        blogentry = blog["foo"] = DummyBlogEntry()
        self.context = blogentry["comments"]

        # Create dummy request
        request = testing.DummyRequest()
        request.environ['repoze.browserid'] = '1'
        self.request = request
Esempio n. 24
0
    def setUp(self):
        self.r = Replacer()
        self.r.replace('opencore.views.forms.get_current_request',
                       lambda: self.request)
        self.r.replace('opencore.views.forms.authenticated_userid',
                       lambda request: 'auth_user_id')

        testing.cleanUp()
        context = testing.DummyModel()
        context.title = 'title'
        context.text = 'content text'
        context.__name__ = 'my-page'
        self.context = context
        request = testing.DummyRequest()
        request.api = get_template_api(context, request)
        request.context = context
        self.request = request
Esempio n. 25
0
    def setUp(self):
        cleanUp()

        # Register mail utility
        from repoze.sendmail.interfaces import IMailDelivery
        from karl.testing import DummyMailer
        self.mailer = DummyMailer()
        testing.registerUtility(self.mailer, IMailDelivery)

        # Register BlogCommentAlert adapter
        from karl.models.interfaces import IProfile
        from karl.models.interfaces import IComment
        from karl.content.views.adapters import BlogCommentAlert
        from karl.utilities.interfaces import IAlert
        from repoze.bfg.interfaces import IRequest
        testing.registerAdapter(BlogCommentAlert,
                                (IComment, IProfile, IRequest),
                                IAlert)

        # Create dummy site skel
        from karl.testing import DummyCommunity
        from karl.testing import DummyProfile
        community = DummyCommunity()
        site = community.__parent__.__parent__

        profiles = testing.DummyModel()
        site["profiles"] = profiles
        profiles["a"] = DummyProfile()
        profiles["b"] = DummyProfile()
        profiles["c"] = DummyProfile()

        community.member_names = set(["b", "c",])
        community.moderator_names = set(["a",])

        blog = testing.DummyModel()
        community["blog"] = blog

        blogentry = blog["foo"] = DummyBlogEntry()

        self.context = blogentry["comments"]
Esempio n. 26
0
    def setUp(self):
        cleanUp()

        # Create dummy site skel
        from karl.testing import DummyCommunity
        community = DummyCommunity()
        site = community.__parent__.__parent__
        site.sessions = DummySessions()
        blog = testing.DummyModel()
        community["blog"] = blog
        blogentry = blog["foo"] = DummyBlogEntry()
        container = blogentry["comments"]
        comment = container["99"] = DummyComment('Re: foo', 'text',
                                                 'description',
                                                 'creator')
        self.context = comment

        # Create dummy request
        request = testing.DummyRequest()
        request.environ['repoze.browserid'] = '1'
        self.request = request
        registerLayoutProvider()
Esempio n. 27
0
    def setUp(self):
        cleanUp()

        from zope.interface import directlyProvides
        from karl.content.interfaces import ICalendarEvent

        karltesting.registerSettings()
        karltesting.registerKarlDates()

        # Create dummy site skel
        community = karltesting.DummyCommunity()
        site = community.__parent__.__parent__

        profiles = testing.DummyModel()
        site["profiles"] = profiles
        self.profile = profiles["member"] = karltesting.DummyProfile()
        profiles["creator"] = karltesting.DummyProfile()

        community["calendar"] = testing.DummyModel()

        event = testing.DummyModel(
            text="This is a test",
            description="Some description",
            startDate=datetime(2009, 8, 5, 10, 0),
            endDate=datetime(2009, 8, 5, 11, 0),
            attendees=['alice', 'bob'],
            location='NYC',
            contact_name='Alice W',
            contact_email='*****@*****.**',
            )
        community["calendar"]["event"] = event
        event.title = "An Exciting Event!"
        event.docid = 0
        directlyProvides(event, ICalendarEvent)
        self.event = event
        event.creator = "creator"
Esempio n. 28
0
 def tearDown(self):
     cleanUp()
Esempio n. 29
0
    def setUp(self):
        cleanUp()

        self._registerLayoutProvider()
Esempio n. 30
0
 def setUp(self):
     cleanUp()
Esempio n. 31
0
 def setUp(self):
     cleanUp()
Esempio n. 32
0
 def tearDown(self):
     cleanUp()