def test_object_without_verified_marker_interface(self): """Corner case: the object does not have the verified marker interface It should add the stop words marker interface without raising any exception. """ self.assertFalse(IStopWordsVerified.providedBy(self.doc)) self.assertFalse(IHasStopWords.providedBy(self.doc)) catalog = api.portal.get_tool('portal_catalog') brain = catalog(id=self.doc.id)[0] verify_brain(brain, new_entries='random') self.assertFalse(IStopWordsVerified.providedBy(self.doc)) self.assertTrue(IHasStopWords.providedBy(self.doc))
def test_remove_interface_on_a_document(self): """Calling @@discard-alert on a document that has the IHasStopWords removes it and adds the IStopWordsVerified marker interface""" alsoProvides(self.document, IHasStopWords) self.assertTrue(IHasStopWords.providedBy(self.document)) discard_view = api.content.get_view( name='discard-alert', context=self.document, request=self.request ) discard_view() self.assertFalse(IHasStopWords.providedBy(self.document)) self.assertTrue(IStopWordsVerified.providedBy(self.document))
def test_stop_word_in_object(self): """Check that the verified marker interface is removed It should be removed if the stop words are found on the object's text. """ alsoProvides(self.doc, IStopWordsVerified) self.doc.reindexObject() catalog = api.portal.get_tool('portal_catalog') brain = catalog(id=self.doc.id)[0] verify_brain(brain, new_entries='random') self.assertFalse(IStopWordsVerified.providedBy(self.doc)) self.assertTrue(IHasStopWords.providedBy(self.doc))
def test_remove_interface_on_a_comment(self): """Calling @@discard-alert on a comment that has the IHasStopWords removes it and adds the IStopWordsVerified marker interface""" comment = createObject('plone.Comment') comment.text = 'something' comment.author_username = '******' comment.author_name = 'Jim' comment.author_email = '*****@*****.**' conversation = IConversation(self.document) conversation.addComment(comment) alsoProvides(comment, IHasStopWords) self.assertTrue(IHasStopWords.providedBy(comment)) discard_view = api.content.get_view( name='discard-alert', context=comment, request=self.request ) discard_view() self.assertFalse(IHasStopWords.providedBy(comment)) self.assertTrue(IStopWordsVerified.providedBy(comment))