def setUp(self): 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 test_deleteMembers(self): site = self._makeSite() sm = getSiteManager() mtool = site.portal_membership members = site._setObject( 'Members', PortalFolder('Members') ) acl_users = site._setObject( 'acl_users', DummyUserFolder() ) utool = site._setObject( 'portal_url', DummyTool() ) sm.registerUtility(utool, IURLTool) wtool = site._setObject( 'portal_workflow', DummyTool() ) mdtool = site._setObject( 'portal_memberdata', MemberDataTool() ) sm.registerUtility(mdtool, IMemberDataTool) newSecurityManager(None, acl_users.all_powerful_Oz) self.assertEqual( acl_users.getUserById('user_foo'), acl_users.user_foo ) mtool.createMemberArea('user_foo') self.failUnless( hasattr(members.aq_self, 'user_foo') ) mdtool.registerMemberData('Dummy', 'user_foo') self.failUnless( mdtool._members.has_key('user_foo') ) rval = mtool.deleteMembers( ('user_foo', 'user_baz') ) self.assertEqual( rval, ('user_foo',) ) self.failIf( acl_users.getUserById('user_foo', None) ) self.failIf( mdtool._members.has_key('user_foo') ) self.failIf( hasattr(members.aq_self, 'user_foo') ) cleanUp()
def setUp(self): 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 testing.registerAdapter(DummySearchAdapter, (Interface, Interface), ICatalogSearch) testing.registerAdapter(DummySearchAdapter, (Interface,), ICatalogSearch) root.catalog = catalog = karltesting.DummyModel() catalog['creator'] = DummyCatalogIndex() catalog['modified_by'] = DummyCatalogIndex()
def wrapper(*args, **kw): safe_load_site() value = function(*args, **kw) cleanUp() import Products.Five.zcml as zcml zcml._initialized = 0 return value
def setUp(self): cleanUp() sessions = DummySessions() context = self.context = testing.DummyModel(sessions=sessions) request = self.request = testing.DummyRequest() request.environ['repoze.browserid'] = '1' request.subpath = ('sub', 'path', 'parts')
def tearDown(self): from zope.testing.cleanup import cleanUp cleanUp() from karl.adapters import mailin mailin.datetime = self._save_datetime mailin.ALIAS_REGX = None
def setUp(self): cleanUp() from datetime import datetime site = DummyModel() self.site = site profiles = site['profiles'] = DummyModel() site['bigendians'] = c = DummyModel() c.title = 'Big Endians' c.modified = datetime(2009, 12, 23, 12, 31) c.creator = 'chucknorris' site['littleendians'] = c = DummyModel() c.title = 'Little Endians' c.modified = datetime(2009, 12, 26, 3, 31) c.creator = 'geekbill' p = profiles['chucknorris'] = karltesting.DummyProfile() p.title = 'Chuck Norris' p = profiles['geekbill'] = karltesting.DummyProfile() p.title = 'Bill Haverchuck' from karl.models.interfaces import ICatalogSearch from zope.interface import Interface search = DummyCatalogSearch() def dummy_search_factory(context): return search karltesting.registerAdapter(dummy_search_factory, Interface, ICatalogSearch) self.search = search from karl.views.admin import delete_content_view self.fut = delete_content_view
def setUp(self): cleanUp() from AccessControl.SecurityManagement import noSecurityManager from AccessControl.SecurityManager import setSecurityPolicy from Products.CompositePage.tests.test_tool import PermissiveSecurityPolicy self.old_policy = setSecurityPolicy(PermissiveSecurityPolicy()) noSecurityManager()
def test_deleteMembersUnsupported(self): # Quite a few user folders do not support the deletion API # http://www.zope.org/Collectors/CMF/481 # Make sure we get the right exception site = self._makeSite() sm = getSiteManager() sm.registerUtility(site, ISiteRoot) mtool = site.portal_membership members = site._setObject('Members', PortalFolder('Members')) acl_users = site._setObject('acl_users', DummyUserFolder()) mdtool = MemberDataTool() sm.registerUtility(mdtool, IMemberDataTool) newSecurityManager(None, acl_users.all_powerful_Oz) self.assertEqual(acl_users.getUserById('user_foo'), acl_users.user_foo) mtool.createMemberArea('user_foo') self.assertTrue(hasattr(members.aq_self, 'user_foo')) mdtool.registerMemberData('Dummy', 'user_foo') self.assertTrue('user_foo' in mdtool._members) # Fake an incompatible user folder by deleting the class method deletion_method = DummyUserFolder.userFolderDelUsers del DummyUserFolder.userFolderDelUsers self.assertRaises(NotImplementedError, mtool.deleteMembers, ('user_foo',)) self.assertTrue(acl_users.getUserById('user_foo', None)) self.assertTrue('user_foo' in mdtool._members) self.assertTrue(hasattr(members.aq_self, 'user_foo')) # Cleanup DummyUserFolder.userFolderDelUsers = deletion_method cleanUp()
def safe_load_site(): """Load entire component architecture (w/ debug mode on)""" cleanUp() setDebugMode(1) import Products.Five.zcml as zcml zcml.load_site() setDebugMode(0)
def tearDown(self): self.app.REQUEST.close() noSecurityManager() transaction.abort() self.app._p_jar.close() Skinnable.SKINDATA = self._oldSkindata cleanUp()
def tearDown(self): """Test tearDown based on z3c.form.testing.tearDown minus their globals. """ from zope.testing import cleanup from zope.component import hooks cleanup.cleanUp() hooks.resetHooks() hooks.setSite()
def tearDownReadMe(test): # clean up Zope cleanup.cleanUp() # clean up SQLAlchemy Base = test.globs['Base'] engine = test.globs['engine'] Base.metadata.drop_all(engine)
def tearDown(self): from AccessControl.SecurityManagement import noSecurityManager if self._finally is not None: self._finally() noSecurityManager() cleanUp()
def setUp(self): cleanUp() sessions = DummySessions() context = DummyProfile(sessions=sessions) context.title = 'title' self.context = context request = testing.DummyRequest() request.environ['repoze.browserid'] = '1' self.request = request
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). """ cleanUp() import myproject import zope.configuration.xmlconfig zope.configuration.xmlconfig.file('configure.zcml', package=myproject)
def setUp(self): cleanUp() from karl.content.models import blog self._save_os = blog.os blog.os = self self._utime_called = None self._exists = set() testing.registerSettings(mailin_trace_file='trace_file')
def tearDown(self): from AccessControl.SecurityManagement import noSecurityManager noSecurityManager() ZopeTestCase.tearDown(self) try: from zope.testing.cleanup import cleanUp cleanUp() except ImportError: # BBB: for Zope 2.8 pass
def setUp(self): cleanUp() sessions = self.sessions = DummySessions() context = testing.DummyModel(sessions=sessions) context.title = 'profiles' self.context = context request = testing.DummyRequest() request.environ['repoze.browserid'] = '1' self.request = request karltesting.registerSettings()
def setUp(self): cleanUp() self.root = root = testing.DummyModel() root.users = testing.DummyUsers() root['profiles'] = testing.DummyModel() from repoze.lemonade.testing import registerContentFactory from karl.models.interfaces import IProfile registerContentFactory(testing.DummyProfile, IProfile)
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): cleanUp() from repoze.lemonade.testing import registerContentFactory from karl.content.interfaces import ICommunityFile registerContentFactory(testing.DummyModel, ICommunityFile) from zope.interface import Interface from repoze.workflow.testing import registerDummyWorkflow self.workflow = DummyWorkflow() registerDummyWorkflow('security', self.workflow, Interface)
def setUp(self): cleanUp() self.sessions = sessions = DummySessions() context = DummyProfile(sessions=sessions) context.title = 'title' self.context = context request = testing.DummyRequest() request.environ['repoze.browserid'] = '1' self.request = request # this initializes the available groups karltesting.registerSettings()
def setUp(tc): # clean slate! cleanUp() # init event system from zope.component import event # register components provideHandler(notifyFieldEvent) provideAdapter(at_field_retrieval) provideSubscriptionAdapter(at_field_storage)
def setUp(self): cleanUp() from karl.models.interfaces import ICommunity from zope.interface import directlyProvides from datetime import datetime site = DummyModel() self.site = site profiles = site['profiles'] = DummyModel() site['bigendians'] = c = DummyModel() directlyProvides(c, ICommunity) c.title = 'Big Endians' c.modified = datetime(2009, 12, 23, 12, 31) c.creator = 'chucknorris' blog = c['blog'] = DummyModel() entry = blog['entry1'] = DummyModel() entry.title = 'Blog Post 1' entry.modified = datetime(2009, 12, 23, 12, 31) entry.creator = 'chucknorris' entry = blog['entry2'] = DummyModel() entry.title = 'Blog Post 2' entry.modified = datetime(2009, 12, 23, 13, 31) entry.creator = 'chucknorris' site['littleendians'] = c = DummyModel() directlyProvides(c, ICommunity) c.title = 'Little Endians' c.modified = datetime(2009, 12, 26, 3, 31) c.creator = 'geekbill' c['blog'] = DummyModel() p = profiles['chucknorris'] = karltesting.DummyProfile() p.title = 'Chuck Norris' p = profiles['geekbill'] = karltesting.DummyProfile() p.title = 'Bill Haverchuck' from karl.models.interfaces import ICatalogSearch from zope.interface import Interface search = DummyCatalogSearch() def dummy_search_factory(context): return search karltesting.registerAdapter(dummy_search_factory, Interface, ICatalogSearch) self.search = search from karl.views.admin import move_content_view self.fut = move_content_view
def setUp(self): cleanUp() import tempfile self.tmpdir = tmpdir = tempfile.mkdtemp('karl_test') self.site = testing.DummyModel() from repoze.bfg.interfaces import ISettings settings = karltesting.DummySettings( error_monitor_dir=tmpdir, error_monitor_subsystems=["blonde", "red", "head"], ) testing.registerUtility(settings, ISettings)
def setUp(self): cleanUp() import os import sys here = os.path.abspath(os.path.dirname(sys.modules[__name__].__file__)) from repoze.bfg.interfaces import ISettings self.settings = settings = karltesting.DummySettings( syslog_view=os.path.join(here, 'test.log'), syslog_view_instances=['org1', 'org2'], ) testing.registerUtility(settings, ISettings) from karl.views.admin import syslog_view self.fut = syslog_view
def setUp(self): from zope.testing.cleanup import cleanUp 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): cleanUp() import os import sys here = os.path.abspath(os.path.dirname(sys.modules[__name__].__file__)) from repoze.bfg.interfaces import ISettings self.logs = [os.path.join(here, 'test.log'), os.path.join(here, 'test_admin.py')] settings = karltesting.DummySettings( logs_view=self.logs ) testing.registerUtility(settings, ISettings) from karl.views.admin import logs_view self.fut = logs_view
def setUp(self): cleanUp() batch = [testing.DummyModel(title="A"), testing.DummyModel(title="B")] class DummyBatcher(object): def __call__( self, context, request, creator, community, batch_start, batch_size, sort_index=None, reverse=False ): self.called = (context, request, creator, community, batch_start, batch_size, sort_index, reverse) return dict(entries=batch, batch_start=batch_start, batch_size=batch_size, total=5) self.batcher = DummyBatcher() def dummy_get_info(image, request): return dict(title=image.title) self.make_record = dummy_get_info
def tearDown(self): from AccessControl.SecurityManagement import noSecurityManager from zope.testing.cleanup import cleanUp cleanUp() noSecurityManager()
def tearDown(self): from zope.testing.cleanup import cleanUp cleanUp() SecurityTest.tearDown(self)
def setUp(self): cleanUp()
def cleanUpDoc(args): cleanUp()
def cleanUp(test): from zope.testing import cleanup cleanup.cleanUp()
def cleanUp(test): cleanup.cleanUp()
def tearDown(self): cleanUp() RequestTest.tearDown(self)
def tearDown(self): cleanUp() FSDVTest.tearDown(self) TransactionalTest.tearDown(self)
def tearDown(self): TestCase.tearDown(self) cleanUp()
def tearDown(self): BaseRegistryTests.tearDown(self) cleanUp()
def setUp(self): cleanUp() self.context = testing.DummyModel() from karl.testing import registerCatalogSearch registerCatalogSearch()
def tearDown(self): cleanUp() SecurityRequestTest.tearDown(self)
def setUp(cls): cleanup.cleanUp() zcml.load_site(force=True) component.provideHandler(eventlog.trace, (ITestItem, IObjectEvent)) component.provideHandler(eventlog.trace, (ITestFolder, IObjectEvent))
def tearDown(test): from zope.testing import cleanup from zope.component import hooks cleanup.cleanUp() hooks.resetHooks() hooks.setSite()
def cleanUpZope(test): cleanup.cleanUp()
def setUp(self): from zope.testing.cleanup import cleanUp cleanUp() self._registerAdapters()
def tearDown(self): cleanUp()
def testTearDown(cls): cleanUp()
def tearDown(self): RequestTest.tearDown(self) FSDVTest.tearDown(self) cleanUp()
def tearDown(test): cleanup.cleanUp()
def setUp(self): cleanUp() site = self.site = testing.DummyModel() context = self.context = testing.DummyModel() site['context'] = context
def tearDown(self): cleanUp() SecurityTest.tearDown(self) FSPSMaker.tearDown(self)
def tearDown(self): cleanUp() FSSTXMaker.tearDown(self) _TemplateSwitcher.tearDown(self) SecurityTest.tearDown(self)
def tearDown(cls): cleanUp()
def setUp(self): cleanUp() karltesting.registerLayoutProvider()
def setUp(cls): cleanup.cleanUp() zcml.load_site(force=True) setDeprecatedManageAddDelete(TestItem) setDeprecatedManageAddDelete(TestFolder)
def afterClear(self): cleanup.cleanUp() sys.path[:] = self.saved
def afterSetUp(self): cleanup.cleanUp() zcml.load_site(force=True) self.saved = sys.path[:] sys.path.append(ZopeTestCase.__path__[0])
def tearDown(self): cleanUp() SecurityTest.tearDown(self)
def tearDown(self): from Products.CMFCore.Skinnable import SKINDATA SKINDATA.clear() cleanUp()