예제 #1
0
    def test_bundle_sorting(self):
        # 1. non-standard first, then standard
        # 2. sort by title

        self.layer.load_zcml_string('\n'.join(
            ('<configure xmlns:inflator="http://namespaces.zope.org/inflator"'
             '           i18n_domain="my.package">', '    <inflator:bundle',
             '        title="foo-standard"',
             '        profiles="plonetheme.sunburst:default"'
             '        standard="True" />', '    <inflator:bundle',
             '        title="bar"',
             '        profiles="plonetheme.sunburst:default" />',
             '    <inflator:bundle', '        title="foo"',
             '        profiles="plonetheme.sunburst:default" />',
             '    <inflator:bundle', '        title="bar-standard"',
             '        profiles="plonetheme.sunburst:default"'
             '        standard="True" />', '</configure>')))

        bundles = get_bundles()
        self.assertEquals(type(bundles), list)
        self.assertEquals(len(bundles), 4)

        ordered_titles = [bundle.title for bundle in bundles]
        self.assertEqual(ordered_titles,
                         [u'bar', u'foo', u'bar-standard', u'foo-standard'])
예제 #2
0
    def get_bundle_options(self):
        def option(item):
            index, bundle = item
            return {
                'name': bundle.title.encode('utf-8'),
                'title': bundle.title,
                'description': bundle.description,
                'index': index}

        return map(option, enumerate(get_bundles()))
예제 #3
0
파일: views.py 프로젝트: erral/ftw.inflator
    def get_bundle_options(self):
        def option(item):
            index, bundle = item
            return {
                "name": bundle.title.encode("utf-8"),
                "title": bundle.title,
                "description": bundle.description,
                "index": index,
            }

        return map(option, enumerate(get_bundles()))
예제 #4
0
    def get_bundle_options(self):
        def option(item):
            index, bundle = item
            return {
                'name': bundle.title.encode('utf-8'),
                'title': bundle.title,
                'description': bundle.description,
                'index': index
            }

        return map(option, enumerate(get_bundles()))
예제 #5
0
    def test_getting_bundles(self):
        self.layer.load_zcml_string('\n'.join(
            ('<configure xmlns:inflator="http://namespaces.zope.org/inflator"'
             '           i18n_domain="my.package">', '    <inflator:bundle',
             '        title="foo"',
             '        profiles="plonetheme.sunburst:default" />',
             '    <inflator:bundle', '        title="bar"',
             '        profiles="plonetheme.sunburst:default" />',
             '</configure>')))

        bundles = get_bundles()
        self.assertEquals(type(bundles), list)
        self.assertEquals(len(bundles), 2)

        bar, foo = bundles

        self.assertEquals(foo.title, u'foo')
        self.assertEquals(bar.title, u'bar')
예제 #6
0
    def test_bundle_sorting(self):
        # 1. non-standard first, then standard
        # 2. sort by title

        self.layer.load_zcml_string('\n'.join((
                    '<configure xmlns:inflator="http://namespaces.zope.org/inflator"'
                    '           i18n_domain="my.package">',

                    '    <inflator:bundle',
                    '        title="foo-standard"',
                    '        profiles="plonetheme.sunburst:default"'
                    '        standard="True" />',

                    '    <inflator:bundle',
                    '        title="bar"',
                    '        profiles="plonetheme.sunburst:default" />',

                    '    <inflator:bundle',
                    '        title="foo"',
                    '        profiles="plonetheme.sunburst:default" />',

                    '    <inflator:bundle',
                    '        title="bar-standard"',
                    '        profiles="plonetheme.sunburst:default"'
                    '        standard="True" />',

                    '</configure>'
                    )))

        bundles = get_bundles()
        self.assertEquals(type(bundles), list)
        self.assertEquals(len(bundles), 4)

        ordered_titles = [bundle.title for bundle in bundles]
        self.assertEqual(ordered_titles,
                         [u'bar',
                          u'foo',
                          u'bar-standard',
                          u'foo-standard'])
예제 #7
0
    def test_getting_bundles(self):
        self.layer.load_zcml_string('\n'.join((
                    '<configure xmlns:inflator="http://namespaces.zope.org/inflator"'
                    '           i18n_domain="my.package">',

                    '    <inflator:bundle',
                    '        title="foo"',
                    '        profiles="plonetheme.sunburst:default" />',

                    '    <inflator:bundle',
                    '        title="bar"',
                    '        profiles="plonetheme.sunburst:default" />',

                    '</configure>'
                    )))

        bundles = get_bundles()
        self.assertEquals(type(bundles), list)
        self.assertEquals(len(bundles), 2)

        bar, foo = bundles

        self.assertEquals(foo.title, u'foo')
        self.assertEquals(bar.title, u'bar')
예제 #8
0
 def test_getting_bundles_with_no_bundles_registered(self):
     self.assertEquals(get_bundles(), [])
#!/usr/bin/env python
from Testing.makerequest import makerequest
from ftw.inflator.bundle import get_bundles
import transaction


ZOPE_URL = 'http://localhost:8080'
PLONE_URL = '{}/platform'.format(ZOPE_URL)

app=makerequest(app)

bundle = get_bundles()[0]

plone = app.unrestrictedTraverse('platform', None)

if not plone:
    plone = bundle.install(app, 'platform', title='Thor Odinson', language="en")
    transaction.commit()
예제 #10
0
 def test_getting_bundles_with_no_bundles_registered(self):
     self.assertEquals(get_bundles(), [])