# -*- coding: utf-8 -*-
"""Setup/installation tests for this package."""

from bfa.events.testing import IntegrationTestCase
from plone import api


class TestInstall(IntegrationTestCase):
    """Test installation of bfa.events into Plone."""

    def setUp(self):
        """Custom shared utility setup for tests."""
        self.portal = self.layer['portal']
        self.installer = api.portal.get_tool('portal_quickinstaller')

    def test_product_installed(self):
        """Test if bfa.events is installed with portal_quickinstaller."""
        self.assertTrue(self.installer.isProductInstalled('bfa.events'))

    def test_uninstall(self):
        """Test if bfa.events is cleanly uninstalled."""
        self.installer.uninstallProducts(['bfa.events'])
        self.assertFalse(self.installer.isProductInstalled('bfa.events'))

    # browserlayer.xml
    def test_browserlayer(self):
        """Test that IBfaEventsLayer is registered."""
        from bfa.events.interfaces import IBfaEventsLayer
        from plone.browserlayer import utils
        self.failUnless(IBfaEventsLayer in utils.registered_layers())
