Testing Collage support for finding file links
==============================================

.. Copyright (C) 2008 Ingeniweb

.. This program is free software; you can redistribute it and/or modify
.. it under the terms of the GNU General Public License as published by
.. the Free Software Foundation; either version 2 of the License, or (at
.. your option) any later version.

.. This program is distributed in the hope that it will be useful, but
.. WITHOUT ANY WARRANTY; without even the implied warranty of
.. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
.. General Public License for more details.

.. You should have received a copy of the GNU General Public License
.. along with this program; see the file LICENSE.txt. If not, write to
.. the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139,
.. USA.

.. $Id: test_collage_linksfinder.txt 36 2008-09-07 09:08:55Z glenfant $

Some inits and setups
---------------------

  >>> from zope.component import getAdapter
  >>> from iw.sitestat.interfaces import IFileLinksFinder
  >>> self.loginAsPortalOwner()
  >>> from iw.sitestat.tests import utils as ns_utils
  >>> self.loginAsPortalOwner()
  >>> foo_col = ns_utils.addCollage(self.portal, 'foo', 'Foo')
  >>> foo_col.title_or_id()
  'Foo'

Let's add a row and a column
----------------------------

  >>> a = foo_col.restrictedTraverse('insert-row')
  >>> a.insertRow()
  >>> foo_col.objectIds()
  ['1']
  >>> row = getattr(foo_col, '1')
  >>> column = getattr(row, '1')
  >>> column
  <CollageColumn at ...>

Let's add a PDF file to that column
-----------------------------------

  >>> bar_file = ns_utils.addFile(column, 'bar', 'Bar')
  >>> bar_file.manage_edit('Bar', 'application/pdf', filedata=ns_utils.LOREM_IPSUM_PDF)
  >>> bar_file
  <ATFile at ...>

Finding appropriate link finder
-------------------------------

  >>> links_finder = getAdapter(foo_col, IFileLinksFinder)
  >>> links_finder
  <iw.sitestat.linksfinders.thirdparty.collage.CollageFileLinksFinder ...>

Getting the file links from that collage
----------------------------------------

  >>> links_finder.fileURLs()
  []
  >>> links_finder.pdfFileURLs()
  ['http://nohost/plone/foo/1/1/bar/at_download/file']

Now with a text/html file
-------------------------

  >>> bar_file.manage_edit('Bar', 'text/html', filedata=ns_utils.LOREM_IPSUM_HTML)
  >>> links_finder = getAdapter(foo_col, IFileLinksFinder)
  >>> links_finder.fileURLs()
  ['http://nohost/plone/foo/1/1/bar/at_download/file']
  >>> links_finder.pdfFileURLs()
  []
