def test_invoke_edit_view(self): mapping = PortletAssignmentMapping() request = self.folder.REQUEST mapping['foo'] = personleadimagecollectionportlet.Assignment( header=u"title") editview = getMultiAdapter((mapping['foo'], request), name='edit') self.failUnless( isinstance(editview, personleadimagecollectionportlet.EditForm))
def test_render(self): r = self.renderer( context=self.portal, assignment=personleadimagecollectionportlet.Assignment( header=u"title", target_collection='/Members/test_user_1_/collection')) r = r.__of__(self.folder) r.update() output = r.render() self.failUnless('<img' in output)
def test_image_scales(self): #default scale size is thumb r = self.renderer( context=self.portal, assignment=personleadimagecollectionportlet.Assignment( header=u"title", target_collection='/Members/test_user_1_/collection')) r = r.__of__(self.folder) r.update() output = r.render() self.failUnless('_thumb' in output) r = self.renderer( context=self.portal, assignment=personleadimagecollectionportlet.Assignment( header=u"title", scale='tile', target_collection='/Members/test_user_1_/collection')) r = r.__of__(self.folder) r.update() output = r.render() self.failUnless('_tile' in output)
def test_obtain_renderer(self): context = self.folder request = self.folder.REQUEST view = self.folder.restrictedTraverse('@@plone') manager = getUtility(IPortletManager, name='plone.rightcolumn', context=self.portal) assignment = personleadimagecollectionportlet.Assignment( header=u"title") renderer = getMultiAdapter( (context, request, view, manager, assignment), IPortletRenderer) self.failUnless( isinstance(renderer, personleadimagecollectionportlet.Renderer))
def test_start_dates(self): event1 = self._createType(self.folder, 'Event', 'event_1') start_date = DateTime(2400, 0) event1.startDate = start_date event1.reindexObject() catalog = getToolByName(self.folder, 'portal_catalog') event_brain = catalog(id='event_1')[0] folder_brain = catalog(id='folder_1')[0] r = self.renderer( context=self.portal, assignment=personleadimagecollectionportlet.Assignment( header=u"title", start_dates=True, target_collection='/Members/test_user_1_/collection')) r = r.__of__(self.folder) r.update() shown_date = r.object_date(event_brain) self.assertEqual(start_date, shown_date) shown_date = r.object_date(folder_brain) self.assertEqual(folder_brain.Date, shown_date) r = self.renderer( context=self.portal, assignment=personleadimagecollectionportlet.Assignment( header=u"title", start_dates=False, target_collection='/Members/test_user_1_/collection')) r = r.__of__(self.folder) r.update() shown_date = r.object_date(event_brain) self.assertEqual(event_brain.Date, shown_date) shown_date = r.object_date(folder_brain) self.assertEqual(folder_brain.Date, shown_date)
def test_news_without_image(self): #Create a News Item without a image new1 = self._createType(self.folder, 'News Item', 'new_1') #Change the collection to search only new items crit = self.collection.listCriteria()[0] crit.setValue('News Item') r = self.renderer( context=self.portal, assignment=personleadimagecollectionportlet.Assignment( header=u"title", target_collection='/Members/test_user_1_/collection')) r = r.__of__(self.folder) r.update() output = r.render() self.failIf('<img' in output)
def renderer(self, context=None, request=None, view=None, manager=None, assignment=None): context = context or self.folder request = request or self.folder.REQUEST view = view or self.folder.restrictedTraverse('@@plone') manager = manager or getUtility( IPortletManager, name='plone.rightcolumn', context=self.portal) assignment = assignment or personleadimagecollectionportlet.Assignment( header=u"title") return getMultiAdapter((context, request, view, manager, assignment), IPortletRenderer)
def test_images_on_news(self): #Create a News Item with a image new1 = self._createType(self.folder, 'News Item', 'new_1') test_image = os.path.join(os.path.dirname(__file__), 'test_41x41.jpg') raw_image = open(test_image, 'rb').read() field = new1.getField('image') field.set(new1, raw_image) new1.reindexObject() #Change the collection to search only new items crit = self.collection.listCriteria()[0] crit.setValue('News Item') r = self.renderer( context=self.portal, assignment=personleadimagecollectionportlet.Assignment( header=u"title", target_collection='/Members/test_user_1_/collection')) r = r.__of__(self.folder) r.update() output = r.render() self.failUnless('<img' in output)
def test_interfaces(self): portlet = personleadimagecollectionportlet.Assignment(header=u"title") self.failUnless(IPortletAssignment.providedBy(portlet)) self.failUnless(IPortletDataProvider.providedBy(portlet.data))