<commit_before>from zeit.newsletter.newsletter import Newsletter
import gocept.httpserverlayer.wsgi
import gocept.selenium
import plone.testing
import transaction
import zeit.cms.repository.interfaces
import zeit.cms.testing
import zeit.workflow.testing
import zope.app.appsetup.product
import zope.component


product_config = """\
<product-config zeit.newsletter>
    renderer-host file:///dev/null
</product-config>
"""

ZCML_LAYER = zeit.cms.testing.ZCMLLayer('ftesting.zcml', product_config=(
    zeit.cms.testing.cms_product_config
    + zeit.workflow.testing.product_config
    + product_config))


class TestBrowserLayer(plone.testing.Layer):

    defaultBases = (ZCML_LAYER,)

    def setUp(self):
        product_config = zope.app.appsetup.product.getProductConfiguration(
            'zeit.workflow')
        product_config['publish-script'] = 'true'
        product_config['retract-script'] = 'true'

BROWSER_LAYER = TestBrowserLayer()


WSGI_LAYER = zeit.cms.testing.WSGILayer(name='WSGILayer', bases=(ZCML_LAYER,))
HTTP_LAYER = gocept.httpserverlayer.wsgi.Layer(
    name='HTTPLayer', bases=(WSGI_LAYER,))
WD_LAYER = gocept.selenium.WebdriverLayer(
    name='WebdriverLayer', bases=(HTTP_LAYER,))
WEBDRIVER_LAYER = gocept.selenium.WebdriverSeleneseLayer(
    name='WebdriverSeleneseLayer', bases=(WD_LAYER,))


class TestCase(zeit.cms.testing.FunctionalTestCase):

    layer = ZCML_LAYER


class BrowserTestCase(zeit.cms.testing.BrowserTestCase):

    layer = BROWSER_LAYER


class SeleniumTestCase(zeit.cms.testing.SeleniumTestCase):

    layer = WEBDRIVER_LAYER
    skin = 'vivi'

    def setUp(self):
        super(SeleniumTestCase, self).setUp()
        with zeit.cms.testing.site(self.getRootFolder()):
            self.repository['newsletter'] = Newsletter()
        transaction.commit()

    def create_content_and_fill_clipboard(self):
        # XXX copy&paste from zeit.content.cp.testing
        with zeit.cms.testing.site(self.getRootFolder()):
            with zeit.cms.testing.interaction() as principal:
                repository = zope.component.getUtility(
                    zeit.cms.repository.interfaces.IRepository)
                clipboard = zeit.cms.clipboard.interfaces.IClipboard(principal)
                clipboard.addClip('Clip')
                clip = clipboard['Clip']
                for i in range(1, 4):
                    content = (zeit.cms.testcontenttype.testcontenttype.
                               TestContentType())
                    content.teaserTitle = content.shortTeaserTitle = (
                        u'c%s teaser' % i)
                    name = 'c%s' % i
                    repository[name] = content
                    clipboard.addContent(
                        clip, repository[name], name, insert=True)
        transaction.commit()

        s = self.selenium
        s.refresh()
        s.waitForElementPresent('//li[@uniqueid="Clip"]')
        s.click('//li[@uniqueid="Clip"]')
        s.waitForElementPresent('//li[@uniqueid="Clip"][@action="collapse"]')<commit_msg>It seems webdriver requires special click treatment now<commit_after>from zeit.newsletter.newsletter import Newsletter
import gocept.httpserverlayer.wsgi
import gocept.selenium
import plone.testing
import transaction
import zeit.cms.repository.interfaces
import zeit.cms.testing
import zeit.workflow.testing
import zope.app.appsetup.product
import zope.component


product_config = """\
<product-config zeit.newsletter>
    renderer-host file:///dev/null
</product-config>
"""

ZCML_LAYER = zeit.cms.testing.ZCMLLayer('ftesting.zcml', product_config=(
    zeit.cms.testing.cms_product_config
    + zeit.workflow.testing.product_config
    + product_config))


class TestBrowserLayer(plone.testing.Layer):

    defaultBases = (ZCML_LAYER,)

    def setUp(self):
        product_config = zope.app.appsetup.product.getProductConfiguration(
            'zeit.workflow')
        product_config['publish-script'] = 'true'
        product_config['retract-script'] = 'true'

BROWSER_LAYER = TestBrowserLayer()


WSGI_LAYER = zeit.cms.testing.WSGILayer(name='WSGILayer', bases=(ZCML_LAYER,))
HTTP_LAYER = gocept.httpserverlayer.wsgi.Layer(
    name='HTTPLayer', bases=(WSGI_LAYER,))
WD_LAYER = gocept.selenium.WebdriverLayer(
    name='WebdriverLayer', bases=(HTTP_LAYER,))
WEBDRIVER_LAYER = gocept.selenium.WebdriverSeleneseLayer(
    name='WebdriverSeleneseLayer', bases=(WD_LAYER,))


class TestCase(zeit.cms.testing.FunctionalTestCase):

    layer = ZCML_LAYER


class BrowserTestCase(zeit.cms.testing.BrowserTestCase):

    layer = BROWSER_LAYER


class SeleniumTestCase(zeit.cms.testing.SeleniumTestCase):

    layer = WEBDRIVER_LAYER
    skin = 'vivi'

    def setUp(self):
        super(SeleniumTestCase, self).setUp()
        with zeit.cms.testing.site(self.getRootFolder()):
            self.repository['newsletter'] = Newsletter()
        transaction.commit()

    def create_content_and_fill_clipboard(self):
        # XXX copy&paste from zeit.content.cp.testing
        with zeit.cms.testing.site(self.getRootFolder()):
            with zeit.cms.testing.interaction() as principal:
                repository = zope.component.getUtility(
                    zeit.cms.repository.interfaces.IRepository)
                clipboard = zeit.cms.clipboard.interfaces.IClipboard(principal)
                clipboard.addClip('Clip')
                clip = clipboard['Clip']
                for i in range(1, 4):
                    content = (zeit.cms.testcontenttype.testcontenttype.
                               TestContentType())
                    content.teaserTitle = content.shortTeaserTitle = (
                        u'c%s teaser' % i)
                    name = 'c%s' % i
                    repository[name] = content
                    clipboard.addContent(
                        clip, repository[name], name, insert=True)
        transaction.commit()

        s = self.selenium
        s.refresh()
        s.waitForElementPresent('//li[@uniqueid="Clip"]')
        s.clickAt('//li[@uniqueid="Clip"]', '10,10')
        s.waitForElementPresent('//li[@uniqueid="Clip"][@action="collapse"]')
{'fraction_non_alphanumeric': 0.11546592941941779, 'fraction_numerical': 0.0013010245568385104, 'mean_word_length': 2.870358716173694, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '338541', 'n_tokens_mistral': 1961, 'n_tokens_neox': 1842, 'n_words': 281}