# -*- coding: utf-8 -*-
from interlegis.portalmodelo.theme.testing import INTEGRATION_TESTING
from interlegis.portalmodelo.theme.interfaces import IBrowserLayer
from plone.browserlayer.utils import registered_layers
from zope.site.hooks import setSite

import unittest

PROJECTNAME = 'interlegis.portalmodelo.theme'


class TestBrowserLayer(unittest.TestCase):
    """Ensure browser layer is installed and uninstalled properly."""

    layer = INTEGRATION_TESTING

    def setUp(self):
        portal = self.layer['portal']
        setSite(portal)
        self.portal = portal
        self.qi = getattr(self.portal, 'portal_quickinstaller')

    def test_installed(self):
        self.assertTrue(IBrowserLayer in registered_layers())

    def test_uninstalled(self):
        self.qi.uninstallProducts(products=[PROJECTNAME])
        self.assertTrue(IBrowserLayer not in registered_layers())
