Testing SimpleAlias file link 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_simplealias_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
  >>> from iw.sitestat.tests import utils as ns_utils
  >>> self.loginAsPortalOwner()

Making a File.

  >>> foo_file = ns_utils.addFile(self.portal, 'foo', 'Foo')
  >>> foo_file.title_or_id()
  'Foo'
  >>> foo_file.manage_edit('Foo', 'text/html', filedata=ns_utils.LOREM_IPSUM_HTML)
  >>> file_links_finder = getAdapter(foo_file, IFileLinksFinder)
  >>> file_links_finder
  <iw.sitestat.linksfinders.standard.ATCTFileLinksFinder ...>

And a SimpleAlias.

  >>> foo_alias = ns_utils.addSimpleAlias(self.portal, 'alias', 'Alias')
  >>> foo_alias.title_or_id()
  'Alias not set'

Check when aliasing nothing
---------------------------

We have an adapter specific to SimpleAlias

  >>> alias_links_finder = getAdapter(foo_alias, IFileLinksFinder)
  >>> alias_links_finder
  <iw.sitestat.linksfinders.thirdparty.simplealias.SimpleAliasFileLinksFinder ...>

Of course, we have no files

  >>> alias_links_finder.fileURLs()
  []
  >>> alias_links_finder.pdfFileURLs()
  []


We alias the file
-----------------

  >>> foo_alias.setAlias(foo_file)
  >>> foo_alias.title_or_id()
  'Foo'

The file links finder for the alias finds the same links as the target.

  >>> alias_links_finder = getAdapter(foo_alias, IFileLinksFinder)
  >>> alias_links_finder.fileURLs() == file_links_finder.fileURLs()
  True
  >>> alias_links_finder.pdfFileURLs() == file_links_finder.pdfFileURLs()
  True
