def setUp(self): import datetime from zope.interface import directlyProvides from karl.content.interfaces import IBlogEntry cleanUp() 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") blogentry.created = datetime.datetime(2010, 5, 12, 2, 42) blogentry.creator = 'member' community["blog"]["blogentry"] = blogentry blogentry["attachments"] = testing.DummyModel() blogentry.title = "Blog Entry" blogentry.docid = 0 directlyProvides(blogentry, IBlogEntry) self.blogentry = blogentry blogentry["comments"] = testing.DummyModel() self.comment = self._add_comment(blogentry)
def layer_tearDown(self): """ cleanUp() is required to clear out the application registry between tests """ for s in utils._LAUNCHED_SERVERS: s.tearDown() testing.cleanUp()
def collective_generic_webbuilder_tearDown(self): """ cleanUp() is required to clear out the application registry between tests """ for s in _LAUNCHED_SERVERS: s.tearDown() testing.cleanUp()
def setUp(self): cleanUp() context = testing.DummyModel(sessions=DummySessions()) self.context = context request = testing.DummyRequest() request.environ['repoze.browserid'] = '1' self.request = request
def setUp(self): testing.cleanUp() from karl.models import site self._save_WeightedText = site.WeightedText site.WeightedText = None
def setUp(self): testing.cleanUp() self.root = root = karltesting.DummyModel() root['profiles'] = profiles = karltesting.DummyModel() root.users = karltesting.DummyUsers() root['a'] = a = karltesting.DummyModel(creator='chris') root['b'] = b = karltesting.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 karl.models.interfaces import ICatalogSearch karltesting.registerAdapter(DummySearchAdapter, (Interface, Interface), ICatalogSearch) karltesting.registerAdapter(DummySearchAdapter, (Interface,), ICatalogSearch) root.catalog = catalog = karltesting.DummyModel() catalog['creator'] = DummyCatalogIndex() catalog['modified_by'] = DummyCatalogIndex()
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 karl.testing.registerAdapter(dummy_catalog_search, Interface, ICatalogSearch) # Register atom entry adapter from karl.views.interfaces import IAtomEntry from karl.content.views.atom import CommunityFileAtomEntry karl.testing.registerAdapter( CommunityFileAtomEntry, (Interface, Interface), IAtomEntry) karl.testing.registerDummyRenderer('karl.views:templates/atomfeed.pt')
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 karl.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 karl.testing.registerAdapter(GenericAtomEntry, (IBlogEntry, Interface), IAtomEntry) karl.testing.registerDummyRenderer('karl.views:templates/atomfeed.pt')
def setUp(self): testing.cleanUp() batch = [testing.DummyModel(title="foo"), testing.DummyModel(title="bar")] class DummyGetImagesBatch(object): def __call__(self, context, request, **search_params): self.called = (context, request, search_params) return dict( entries=batch, batch_start=search_params["batch_start"], batch_size=search_params["batch_size"], total=5, ) self.dummy_get_images_batch = DummyGetImagesBatch() def dummy_get_images_info(image, request): return image.title self.dummy_get_images_info = dummy_get_images_info from karl.views.imagedrawer import batch_images def wrapped_batch_images(*arg, **kw): kw["get_image_info"] = self.dummy_get_images_info kw["get_images_batch"] = self.dummy_get_images_batch return batch_images(*arg, **kw) self.dummy_batch_images = wrapped_batch_images
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()
def setUp(self): cleanUp() import os try: # avoid spew from chameleon logger? os.unlink(self._getTemplatePath('minimal.txt.py')) except: pass
def layer_setUp(self): """ cleanUp() is required to clear out the application registry between tests (done in setUp for good measure too) """ testing.cleanUp() config = testing.setUp() config.include('pyramid_zcml') for zcml in CGWG_ZCMLS: config.load_zcml('collective.generic.webbuilder:%s' % zcml)
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()
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
def setUp(self): cleanUp() self._register() context = testing.DummyModel(sessions=DummySessions()) self.context = context request = testing.DummyRequest() request.layout_manager = mock.Mock() request.layout_manager.layout.head_data = dict(panel_data={}) request.environ['repoze.browserid'] = '1' self.request = request
def setUp(self): testing.cleanUp() from karl.content.models import blog self._save_os = blog.os blog.os = self self._utime_called = None self._exists = set() karl.testing.registerSettings(mailin_trace_file='trace_file')
def setUp(self): testing.cleanUp() karl.testing.registerSettings(mailin_trace_file='foo/bar') from karl.content.views import blog self._save_os = blog.os blog.os = self self._exists = False
def setUp(self): cleanUp() import os try: # avoid spew from chameleon logger? os.unlink(self._getTemplatePath('minimal.txt.py')) except: pass from zope.deprecation import __show__ __show__.off()
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 karl.testing.registerDummyRenderer( 'karl.views:forms/templates/snippets.pt')
def setUp(self): testing.cleanUp() from karl.testing import registerSettings registerSettings() site = makeRoot() self.context = site request = testing.DummyRequest() request.environ['repoze.browserid'] = '1' self.request = request karl.testing.registerDummyRenderer( 'karl.views:forms/templates/snippets.pt')
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
def setUp(self): cleanUp() # Register mail utility from repoze.sendmail.interfaces import IMailDelivery from karl.testing import DummyMailer self.mailer = DummyMailer() karl.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 CommentAlert from karl.models.interfaces import ICommentsFolder from karl.utilities.interfaces import IAlert from pyramid.interfaces import IRequest from zope.interface import directlyProvides karl.testing.registerAdapter(CommentAlert, (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 karl.testing.registerAdapter(DummyShowSendalert, (Interface, Interface), IShowSendalert) # Create dummy site skel from karl.testing import DummyCommunity from karl.testing import DummyProfile community = self.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"] blogentry["comments"].__parent__ = blogentry directlyProvides(blogentry["comments"], ICommentsFolder) # Create dummy request request = testing.DummyRequest() request.environ['repoze.browserid'] = '1' self.request = request
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 registerLayoutProvider()
def setUp(self): testing.cleanUp() import os from pyramid.interfaces import ISettings from karl.views.tests import test_admin # get the dir for existing test file for admin views test_dir = os.path.abspath(os.path.dirname(test_admin.__file__)) settings = karltesting.DummySettings( statistics_folder=test_dir, ) karltesting.registerUtility(settings, ISettings)
def setUp(self): cleanUp() 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() self.parent["profiles"] = DummyModel() users = self.parent.users = DummyUsers() users.add("userid", "userid", "password", [])
def setUp(self): testing.cleanUp() from repoze.lemonade.testing import registerContentFactory from karl.content.interfaces import ICommunityFile from karl.content.models.files import CommunityFile registerContentFactory(CommunityFile, ICommunityFile) from zope.interface import Interface from repoze.workflow.testing import registerDummyWorkflow self.workflow = DummyWorkflow() registerDummyWorkflow('security', self.workflow, Interface)
def setUp(self): testing.cleanUp() self.root = root = testing.DummyModel() root.users = karl.testing.DummyUsers() root['profiles'] = testing.DummyModel() from repoze.lemonade.testing import registerContentFactory from karl.models.interfaces import IProfile registerContentFactory(karl.testing.DummyProfile, IProfile) from repoze.workflow.testing import registerDummyWorkflow self.wf = registerDummyWorkflow('security')
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() karl.testing.registerDummyRenderer('karl.views:templates/formfields.pt')
def setUp(self): from zope.interface import directlyProvides from karl.content.interfaces import ICommunityFile config = cleanUp() config.setup_registry() # this is not a unit test 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"
def setUp(self): testing.cleanUp() import datetime from karl.adapters import mailin self._save_datetime = mailin.datetime class DummyDateTime(object): def __init__(self): self.datetime = self def now(self): return datetime.datetime(1975, 7, 7, 7, 30) def __call__(self, *args): return datetime.datetime(*args) mailin.datetime = DummyDateTime()
def setUp(self): testing.cleanUp()
def setUp(self): cleanUp() karltesting.registerDummyRenderer( 'karl.views:templates/generic_layout.pt') karltesting.registerDummyRenderer( 'karl.views:templates/community_layout.pt')
def tearDown(self): testing.cleanUp()
def tearDown(self): testing.cleanUp() from karl.adapters import mailin mailin.datetime = self._save_datetime mailin.ALIAS_REGX = None
def setUp(self): from pyramid.testing import cleanUp cleanUp()
def setUp(self): self.config = testing.cleanUp()
def setUp(self): testing.cleanUp() self._set_NOW(None)
def _callFUT(self, *arg, **kw): from pyramid.testing import cleanUp return cleanUp(*arg, **kw)
def tearDown(self): testing.cleanUp() self._set_NOW(None)
def setUp(self): cleanUp() karl.testing.registerDummyRenderer('karl.views:templates/formfields.pt')
def setUp(self): self.config = cleanUp()
def tearDown(self): testing.cleanUp() import os del os.environ['SUPPRESS_MAIL']
def setUp(self): cleanUp() registerLayoutProvider()
def setUp(self): cleanUp()
def setUp(self): testing.cleanUp() karltesting.registerUtility(DummySpellChecker, iface=ISpellChecker)
def setUp(self): testing.cleanUp() import os os.environ['SUPPRESS_MAIL'] = 'true'
def tearDown(self): from pyramid.testing import cleanUp cleanUp()
def setUp(self): testing.cleanUp() from zope.interface import Interface from karl.models.interfaces import IContainerVersion karl.testing.registerAdapter(DummyAdapter, Interface, IContainerVersion)
def tearDown(self): cleanUp()
def setUp(self): from pyramid.testing import cleanUp cleanUp() karl.testing.registerDummyRenderer( 'karl.content.views:templates/generic_layout.pt')