Testing standard file links finder adapters
===========================================

.. 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_standard_linksfinders.txt 36 2008-09-07 09:08:55Z glenfant $

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

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


HTML file in foo
----------------

  >>> foo_file.manage_edit('Foo', 'text/html', filedata=ns_utils.LOREM_IPSUM_HTML)

Find the best suited adapter for this type.

  >>> links_finder = getAdapter(foo_file, IFileLinksFinder)
  >>> links_finder
  <iw.sitestat.linksfinders.standard.ATCTFileLinksFinder ...>

Does it provide expected file links?

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

Force basic adapter for AT base type.

  >>> links_finder = ATTypeLinksFinder(foo_file)

Does it provide expected links?

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


PDF file in foo
---------------

  >>> foo_file.manage_edit('Foo', 'application/pdf', filedata=ns_utils.LOREM_IPSUM_PDF)

Find the best suited adapter for this type.

  >>> links_finder = getAdapter(foo_file, IFileLinksFinder)
  >>> links_finder
  <iw.sitestat.linksfinders.standard.ATCTFileLinksFinder ...>

Does it provide expected file links?

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

Force basic adapter for AT base type.

  >>> links_finder = ATTypeLinksFinder(foo_file)

Does it provide expected links?

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

End...
