    1: import os
    1: from Products.Five import zcml
    1: from Products.Five import fiveconfigure
    1: from Testing import ZopeTestCase as ztc
    1: from StringIO import StringIO
    1: from Globals import package_home
    1: from slc.publications.config import product_globals
       
       # Let Zope know about the two products we require above-and-beyond a basic
       # Plone install (PloneTestCase takes care of these).
    1: ztc.installProduct('PloneLanguageTool')
    1: ztc.installProduct('LinguaPlone')
       
       # Import PloneTestCase - this registers more products with Zope as a side effect
    1: from Products.PloneTestCase.PloneTestCase import PloneTestCase
    1: from Products.PloneTestCase.PloneTestCase import FunctionalTestCase
    1: from Products.PloneTestCase.PloneTestCase import setupPloneSite
    1: from Products.PloneTestCase.layer import onsetup, PloneSite
       
    1: @onsetup
       def setup_slc_publications():
           """Set up the additional products required for the Publication Content.
           
           The @onsetup decorator causes the execution of this body to be deferred
           until the setup of the Plone site testing layer.
           """
           
           # Load the ZCML configuration for the slc.publications package.
           # This includes the other products below as well.
           
    1:     fiveconfigure.debug_mode = True
    1:     import slc.publications
    1:     zcml.load_config('configure.zcml', slc.publications)
    1:     fiveconfigure.debug_mode = False
           
           # We need to tell the testing framework that these products
           # should be available. This can't happen until after we have loaded
           # the ZCML.
           
           # It seems that files are automatically blobs, but my test won't run without this. (Plone3.1?)
    1:     ztc.installPackage('plone.app.blob')
    1:     ztc.installPackage('slc.publications')
           
       # The order here is important: We first call the (deferred) function which
       # installs the products we need for the Optilux package. Then, we let 
       # PloneTestCase set up this product on installation.
       
    1: setup_slc_publications()
    1: setupPloneSite(products=['plone.app.blob', 'slc.publications'])
       
    2: class PublicationTestCase(PloneTestCase):
           """Base class for integration tests for the 'Publication' product.
    1:     """
       
    2: class PublicationFunctionalTestCase(FunctionalTestCase):
           """Base class for functional integration tests for the 'Publication' product.
           """
           
    1:     def loadfile(self, rel_filename):
    5:         home = package_home(product_globals)
    5:         filename = os.path.sep.join([home, rel_filename])
    5:         data = StringIO(open(filename, 'r').read())
    5:         data.filename = os.path.basename(rel_filename)
    5:         return data
