def test_archive(self): """Test you can move the source in a folder. The rendering in the document will be broken after, and you will have a message, only in preview. """ factory = self.root.manage_addProduct['OFSP'] factory.manage_addFolder('folder', 'Folder') self.assertFalse(IFolder.providedBy(self.root.folder)) self.assertNotIn('codesource', self.root.folder.objectIds()) self.assertIn('codesource', self.root.objectIds()) token = self.root.manage_cutObjects(['codesource']) self.root.folder.manage_pasteObjects(token) self.assertIn('codesource', self.root.folder.objectIds()) self.assertNotIn('codesource', self.root.objectIds()) controller = self.get_controller() self.assertTrue(verifyObject(IExternalSourceController, controller)) with self.assertRaises(SourceMissingError) as error: controller.render() message = silvaviews.render(error.exception, TestRequest()) self.assertEqual(message.strip(), '') message = silvaviews.render(error.exception, TestRequest(), preview=True) self.assertEqual(message.strip(), '<p>External Source unknow is not available.</p>') # The source is no longer available self.assertItemsEqual([ name_candidate3 for name_candidate3 in availableSources(self.root) if name_candidate3[0] == 'codesource' ], [])
def test_archive(self): """Test you can move the source in a folder. The rendering in the document will be broken after, and you will have a message, only in preview. """ factory = self.root.manage_addProduct['OFSP'] factory.manage_addFolder('folder', 'Folder') self.assertFalse(IFolder.providedBy(self.root.folder)) self.assertNotIn('codesource', self.root.folder.objectIds()) self.assertIn('codesource', self.root.objectIds()) token = self.root.manage_cutObjects(['codesource']) self.root.folder.manage_pasteObjects(token) self.assertIn('codesource', self.root.folder.objectIds()) self.assertNotIn('codesource', self.root.objectIds()) controller = self.get_controller() self.assertTrue(verifyObject(IExternalSourceController, controller)) with self.assertRaises(SourceMissingError) as error: controller.render() message = silvaviews.render(error.exception, TestRequest()) self.assertEqual(message.strip(), '') message = silvaviews.render( error.exception, TestRequest(), preview=True) self.assertEqual( message.strip(), '<p>External Source unknow is not available.</p>') # The source is no longer available self.assertItemsEqual( filter(lambda (name, candidate): name == 'codesource', availableSources(self.root)), [])
def _get_locally_addables(self): container = self.context while IFolder.providedBy(container): addables = container.get_silva_addables_allowed_in_container() if addables is not None: return addables container = aq_parent(container) return None