def test_with_security_policy(self): self._register() registerLayoutProvider() import datetime _NOW = datetime.datetime.now() context = testing.DummyModel(title='title') context.sessions = DummySessions() from karl.content.interfaces import IForum alsoProvides(context, IForum) context['profiles'] = profiles = testing.DummyModel() profiles['dummy'] = DummyProfile() context['comments'] = testing.DummyModel() comment = testing.DummyModel(text='sometext') comment.creator = 'dummy' comment.created = _NOW context['comments']['1'] = comment context['attachments'] = testing.DummyModel() request = testing.DummyRequest() request.environ['repoze.browserid'] = 1 def dummy_byline_info(context, request): return context from karl.content.views.interfaces import IBylineInfo karl.testing.registerAdapter(dummy_byline_info, (Interface, Interface), IBylineInfo) self._register() karl.testing.registerDummySecurityPolicy(permissive=False) renderer = karl.testing.registerDummyRenderer( 'templates/show_forum_topic.pt') self._callFUT(context, request) self.assertEqual(renderer.comments[0]['edit_url'], None)
def test_with_security_policy(self): self._register() registerLayoutProvider() import datetime _NOW = datetime.datetime.now() context = testing.DummyModel(title='title') context.sessions = DummySessions() from karl.content.interfaces import IForum alsoProvides(context, IForum) context['profiles'] = profiles = testing.DummyModel() profiles['dummy'] = DummyProfile() context['comments'] = testing.DummyModel() comment = testing.DummyModel(text='sometext') comment.creator = 'dummy' comment.created = _NOW context['comments']['1'] = comment context['attachments'] = testing.DummyModel() request = testing.DummyRequest() request.layout_manager = mock.Mock() request.layout_manager.layout.head_data = dict(panel_data={}) request.environ['repoze.browserid'] = 1 def dummy_byline_info(context, request): return context from karl.content.views.interfaces import IBylineInfo karl.testing.registerAdapter(dummy_byline_info, (Interface, Interface), IBylineInfo) self._register() karl.testing.registerDummySecurityPolicy(permissive=False) renderer = karl.testing.registerDummyRenderer( 'templates/show_forum_topic.pt') self._callFUT(context, request) self.assertEqual(renderer.comments[0]['edit_url'], None)
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 test_noconfirm(self): from karl.testing import registerLayoutProvider registerLayoutProvider() context = testing.DummyModel() context.title = 'Context' request = testing.DummyRequest() renderer = testing.registerDummyRenderer( 'templates/delete_resource.pt') response = self._callFUT(context, request) self.assertEqual(response.status, '200 OK')
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() 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 sessions = DummySessions() context = testing.DummyModel(sessions=sessions) self.context = context registerLayoutProvider()
def test___call__inactive(self): self.request.form = DummyForm() controller = self._makeOne(self.context, self.request, False) karltesting.registerLayoutProvider() response = controller() self.failUnless('api' in response) self.assertEqual(response['api'].page_title, 'Edit title') self.assertEqual(response.get('form_title'), 'Edit User and Profile Information') self.assertEqual(response.get('include_blurb'), False) self.assertEqual(response.get('admin_edit'), True) self.assertEqual(response.get('is_active'), False)
def test_not_confirmed(self): from karl.testing import registerLayoutProvider registerLayoutProvider() request = testing.DummyRequest() context = testing.DummyModel(title='oldtitle') context.__name__ = 'thename' context.catalog = karltesting.DummyCatalog({}) context.users = karltesting.DummyUsers({}) karltesting.registerDummyRenderer('templates/delete_resource.pt') self._register() response = self._callFUT(context, request) self.assertTrue(isinstance(response, dict))
def test_it(self): registerLayoutProvider() self._registerTagbox() context = self.context request = DummyRequest() renderer = karl.testing.registerDummyRenderer(self.template_fn) self._callFUT(context, request) self.assertEqual(renderer.api.page_title, 'dummytitle') self.assertEqual(len(renderer.actions), 3) self.assertEqual(renderer.actions[0][1], 'edit.html') self.assertEqual(renderer.actions[1][1], 'delete.html')
def test_it(self): registerLayoutProvider() self._registerTagbox() context = self.context request = DummyRequest() renderer = registerDummyRenderer(self.template_fn) self._callFUT(context, request) self.assertEqual(renderer.api.page_title, 'dummytitle') self.assertEqual(len(renderer.actions), 3) self.assertEqual(renderer.actions[0][1], 'edit.html') self.assertEqual(renderer.actions[1][1], 'delete.html')
def test_not_confirmed(self): from karl.testing import registerLayoutProvider registerLayoutProvider() request = testing.DummyRequest() context = testing.DummyModel(title='oldtitle') context.__name__ = 'thename' context.catalog = karltesting.DummyCatalog({}) context.users = karltesting.DummyUsers({}) testing.registerDummyRenderer('templates/delete_resource.pt') self._register() response = self._callFUT(context, request) self.assertEqual(response.status, '200 OK')
def test_not_confirmed(self): from karl.testing import registerLayoutProvider registerLayoutProvider() request = testing.DummyRequest() context = testing.DummyModel(title="oldtitle") context.__name__ = "thename" context.catalog = karltesting.DummyCatalog({}) context.users = karltesting.DummyUsers({}) karltesting.registerDummyRenderer("templates/delete_resource.pt") self._register() response = self._callFUT(context, request) self.assertTrue(isinstance(response, dict))
def test_comment_ordering(self): self._register() registerLayoutProvider() import datetime _NOW = datetime.datetime.now() _BEFORE = _NOW - datetime.timedelta(hours=1) context = testing.DummyModel() context.sessions = DummySessions() context.title = 'title' context['comments'] = testing.DummyModel() comment = testing.DummyModel() comment.creator = 'dummy' comment.created = _NOW comment.text = 'My dog has fleas.' context['comments']['1'] = comment comment2 = testing.DummyModel() comment2.creator = 'dummy' comment2.created = _BEFORE comment2.text = "My cat's breath smells like cat food." context['comments']['2'] = comment2 context['attachments'] = testing.DummyModel() from karl.models.interfaces import ISite from karl.content.interfaces import IForum directlyProvides(context, ISite) alsoProvides(context, IForum) context['profiles'] = profiles = testing.DummyModel() profiles['dummy'] = DummyProfile(title='Dummy Profile') request = testing.DummyRequest() request.layout_manager = mock.Mock() request.layout_manager.layout.head_data = dict(panel_data={}) request.environ['repoze.browserid'] = 1 def dummy_byline_info(context, request): return context from karl.content.views.interfaces import IBylineInfo karl.testing.registerAdapter(dummy_byline_info, (Interface, Interface), IBylineInfo) renderer = karl.testing.registerDummyRenderer( 'templates/show_forum_topic.pt') self._callFUT(context, request) self.assertEqual(len(renderer.comments), 2) self.assertEqual(renderer.comments[0]['text'], "My cat's breath smells like cat food.") self.assertEqual(renderer.comments[1]['text'], 'My dog has fleas.')
def test_it(self): self._register() registerLayoutProvider() from karl.models.interfaces import ICatalogSearch from karl.content.interfaces import IForumsFolder karl.testing.registerAdapter(DummySearchAdapter, (Interface), ICatalogSearch) parent = testing.DummyModel(title='abc') context = testing.DummyModel(title='abc') context.__parent__ = parent alsoProvides(context, IForumsFolder) request = testing.DummyRequest() renderer = karl.testing.registerDummyRenderer( 'templates/show_forum.pt') self._callFUT(context, request) actions = renderer.actions self.assertEqual(actions[0][0], 'Add Forum Topic')
def test_it(self): self._register() registerLayoutProvider() from karl.models.interfaces import ICatalogSearch from karl.content.interfaces import IForumsFolder testing.registerAdapter(DummySearchAdapter, (Interface), ICatalogSearch) context = testing.DummyModel(title='abc') alsoProvides(context, IForumsFolder) from karl.models.interfaces import IIntranets intranets = testing.DummyModel(title='Intranets') directlyProvides(intranets, IIntranets) intranets['forums'] = context request = testing.DummyRequest() renderer = testing.registerDummyRenderer('templates/show_forum.pt') self._callFUT(context, request) actions = renderer.actions self.assertEqual(actions[0][0], 'Add Forum Topic')
def test_no_security_policy(self): self._register() registerLayoutProvider() import datetime _NOW = datetime.datetime.now() context = testing.DummyModel() context.sessions = DummySessions() context.title = 'title' context['comments'] = testing.DummyModel() comment = testing.DummyModel() comment.creator = 'dummy' comment.created = _NOW comment.text = 'sometext' context['comments']['1'] = comment context['attachments'] = testing.DummyModel() from karl.models.interfaces import ISite from karl.content.interfaces import IForum directlyProvides(context, ISite) alsoProvides(context, IForum) context['profiles'] = profiles = testing.DummyModel() profiles['dummy'] = DummyProfile(title='Dummy Profile') request = testing.DummyRequest() request.layout_manager = mock.Mock() request.layout_manager.layout.head_data = dict(panel_data={}) request.environ['repoze.browserid'] = 1 def dummy_byline_info(context, request): return context from karl.content.views.interfaces import IBylineInfo karl.testing.registerAdapter(dummy_byline_info, (Interface, Interface), IBylineInfo) renderer = karl.testing.registerDummyRenderer( 'templates/show_forum_topic.pt') self._callFUT(context, request) self.assertEqual(len(renderer.comments), 1) c0 = renderer.comments[0] self.assertEqual(c0['text'], 'sometext') self.assertEqual(renderer.comments[0]['date'], 'Wednesday, January 28, 2009 08:32 AM') self.assertEqual(c0['author_name'], 'Dummy Profile') self.assertEqual(renderer.comments[0]['edit_url'], 'http://example.com/comments/1/edit.html')
def test_it(self): self._register() registerLayoutProvider() from karl.models.interfaces import ICatalogSearch from karl.content.interfaces import IForumsFolder karl.testing.registerAdapter(DummySearchAdapter, (Interface), ICatalogSearch) context = testing.DummyModel(title='abc') alsoProvides(context, IForumsFolder) from karl.models.interfaces import IIntranets intranets = testing.DummyModel(title='Intranets') directlyProvides(intranets, IIntranets) intranets['forums'] = context request = testing.DummyRequest() request.layout_manager = mock.Mock() renderer = karl.testing.registerDummyRenderer( 'templates/show_forum.pt') self._callFUT(context, request) actions = renderer.actions self.assertEqual(actions[0][0], 'Add Forum Topic')
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()
def setUp(self): cleanUp() karltesting.registerLayoutProvider()
def setUp(self): cleanUp() registerLayoutProvider()
def setUp(self): testing.setUp() registerLayoutProvider()