diff --git a/.travis.yml b/.travis.yml index b34df13..6450c21 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,29 +4,42 @@ sudo: false cache: directories: - eggs + - parts/node env: -- PLONE_VERSION=4.2 -- PLONE_VERSION=4.3 -- PLONE_VERSION=5.0 + matrix: + - PLONE_VERSION=4.2 + # Nos demais pacotes plonegovbr, como não testo as versões além do Plone + # 4.3 (ou seja, por padrão testo só a 4.3), não uso a variável + # PLONE_VERSION, apenas a MASTER e a PENDING_RELEASE. + - PLONE_VERSION=4.3 MASTER=true + - PLONE_VERSION=4.3 PENDING_RELEASE=true + - PLONE_VERSION=5.0 matrix: allow_failures: - - env: PLONE_VERSION=5.0 + - env: PLONE_VERSION=4.2 + - env: PLONE_VERSION=4.3 MASTER=true + - env: PLONE_VERSION=5.0 fast_finish: true install: -- sed -ie "s#test-4.3#test-$PLONE_VERSION#" buildout.cfg -- python bootstrap.py -- bin/buildout annotate -- bin/buildout -Nq + # Remova a linha que aponta para o versions do novo release, por padrão 4.3, + # se o job for o 4.2, 5.0 ou o que tem que pegar do master. + - test "$MASTER" -o "$PLONE_VERSION" = 4.2 -o "$PLONE_VERSION" = 5.0 && sed -ie '/https:\/\/raw\.githubusercontent\.com\/plonegovbr\/portal\.buildout\/master\/buildout\.d\/versions\.cfg/d' buildout.cfg || true + - sed -ie "s#test-4.3#test-$PLONE_VERSION#" buildout.cfg + - python bootstrap.py + - bin/buildout annotate + - bin/buildout before_script: -- export DISPLAY=:99.0 -- sh -e /etc/init.d/xvfb start -- firefox -v + - export DISPLAY=:99.0 + - sh -e /etc/init.d/xvfb start + - firefox -v script: -- bin/code-analysis -- bin/test + - bin/code-analysis + - bin/test after_success: -- bin/createcoverage -t "--layer=!Robot" -- pip install -q coveralls -- coveralls + # barra, no momento, não possui testes do tipo "Robots", ao contrário dos + # demais pacotes em plonegovbr. + - bin/createcoverage -t "--layer=!Robot" + - pip install coveralls + - coveralls notifications: irc: irc.freenode.org#plonegovbr diff --git a/bootstrap.py b/bootstrap.py index a629566..a459921 100644 --- a/bootstrap.py +++ b/bootstrap.py @@ -25,7 +25,10 @@ from optparse import OptionParser -tmpeggs = tempfile.mkdtemp() +__version__ = '2015-07-01' +# See zc.buildout's changelog if this version is up to date. + +tmpeggs = tempfile.mkdtemp(prefix='bootstrap-') usage = '''\ [DESIRED PYTHON FOR BUILDOUT] bootstrap.py [options] @@ -40,8 +43,9 @@ ''' parser = OptionParser(usage=usage) -parser.add_option("-v", "--version", help="use a specific zc.buildout version") - +parser.add_option("--version", + action="store_true", default=False, + help=("Return bootstrap.py version.")) parser.add_option("-t", "--accept-buildout-test-releases", dest='accept_buildout_test_releases', action="store_true", default=False, @@ -59,25 +63,33 @@ parser.add_option("--allow-site-packages", action="store_true", default=False, help=("Let bootstrap.py use existing site packages")) +parser.add_option("--buildout-version", + help="Use a specific zc.buildout version") parser.add_option("--setuptools-version", - help="use a specific setuptools version") - + help="Use a specific setuptools version") +parser.add_option("--setuptools-to-dir", + help=("Allow for re-use of existing directory of " + "setuptools versions")) options, args = parser.parse_args() +if options.version: + print("bootstrap.py version %s" % __version__) + sys.exit(0) + ###################################################################### # load/install setuptools try: - if options.allow_site_packages: - import setuptools - import pkg_resources from urllib.request import urlopen except ImportError: from urllib2 import urlopen ez = {} -exec(urlopen('https://bootstrap.pypa.io/ez_setup.py').read(), ez) +if os.path.exists('ez_setup.py'): + exec(open('ez_setup.py').read(), ez) +else: + exec(urlopen('https://bootstrap.pypa.io/ez_setup.py').read(), ez) if not options.allow_site_packages: # ez_setup imports site, which adds site packages @@ -88,12 +100,19 @@ # We can't remove these reliably if hasattr(site, 'getsitepackages'): for sitepackage_path in site.getsitepackages(): - sys.path[:] = [x for x in sys.path if sitepackage_path not in x] + # Strip all site-packages directories from sys.path that + # are not sys.prefix; this is because on Windows + # sys.prefix is a site-package directory. + if sitepackage_path != sys.prefix: + sys.path[:] = [x for x in sys.path + if sitepackage_path not in x] setup_args = dict(to_dir=tmpeggs, download_delay=0) if options.setuptools_version is not None: setup_args['version'] = options.setuptools_version +if options.setuptools_to_dir is not None: + setup_args['to_dir'] = options.setuptools_to_dir ez['use_setuptools'](**setup_args) import setuptools @@ -110,7 +129,12 @@ ws = pkg_resources.working_set +setuptools_path = ws.find( + pkg_resources.Requirement.parse('setuptools')).location + +# Fix sys.path here as easy_install.pth added before PYTHONPATH cmd = [sys.executable, '-c', + 'import sys; sys.path[0:0] = [%r]; ' % setuptools_path + 'from setuptools.command.easy_install import main; main()', '-mZqNxd', tmpeggs] @@ -123,11 +147,8 @@ if find_links: cmd.extend(['-f', find_links]) -setuptools_path = ws.find( - pkg_resources.Requirement.parse('setuptools')).location - requirement = 'zc.buildout' -version = options.version +version = options.buildout_version if version is None and not options.accept_buildout_test_releases: # Figure out the most recent final version of zc.buildout. import setuptools.package_index @@ -167,7 +188,7 @@ def _final_version(parsed_version): cmd.append(requirement) import subprocess -if subprocess.call(cmd, env=dict(os.environ, PYTHONPATH=setuptools_path)) != 0: +if subprocess.call(cmd) != 0: raise Exception( "Failed to execute command:\n%s" % repr(cmd)[1:-1]) diff --git a/buildout.cfg b/buildout.cfg index c7e1ca5..715138a 100644 --- a/buildout.cfg +++ b/buildout.cfg @@ -2,7 +2,7 @@ extends = https://raw.github.com/collective/buildout.plonetest/master/test-4.3.x.cfg https://raw.github.com/collective/buildout.plonetest/master/qa.cfg - https://raw.github.com/plone/plone.app.robotframework/master/versions.cfg + https://raw.githubusercontent.com/plonegovbr/portal.buildout/master/buildout.d/versions.cfg package-name = brasil.gov.barra package-extras = [test] @@ -11,27 +11,29 @@ eggs += parts += createcoverage - i18ndude node omelette [code-analysis] recipe = plone.recipe.codeanalysis[recommended] directory = ${buildout:directory}/src/brasil/gov/barra -clean-lines = False +clean-lines = True +csslint = True +csslint-bin = bin/csslint +debug-statements = True +deprecated-aliases = True +flake8-ignore = E501,T000 +jshint = True +jshint-bin = bin/jshint multiprocessing = True +return-status-codes = True pre-commit-hook = True +prefer-single-quotes = True return-status-codes = True -flake8 = True -flake8-ignore = D001,E501,P001,Q000,S001 [instance] zcml += iw.debug -[i18ndude] -recipe = zc.recipe.egg -eggs = i18ndude - [omelette] recipe = collective.recipe.omelette eggs = ${test:eggs} diff --git a/src/brasil/gov/barra/browser/configure.zcml b/src/brasil/gov/barra/browser/configure.zcml index 67e69f1..6be0161 100644 --- a/src/brasil/gov/barra/browser/configure.zcml +++ b/src/brasil/gov/barra/browser/configure.zcml @@ -7,7 +7,7 @@ para o viewlet manager plone.app.layout.viewlets.interfaces.IPortalTop apenas se o layer brasil.gov.barra.interfaces.IBarraInstalada - estiver disponivel. + estiver disponivel. --> - + diff --git a/src/brasil/gov/barra/browser/helper.py b/src/brasil/gov/barra/browser/helper.py index 87330d8..fb9a53a 100644 --- a/src/brasil/gov/barra/browser/helper.py +++ b/src/brasil/gov/barra/browser/helper.py @@ -4,14 +4,13 @@ from brasil.gov.barra.interfaces import IBarraHelper from plone import api from Products.Five import BrowserView -from zope.interface import implements +from zope.interface import implementer +@implementer(IBarraHelper) class BarraHelper(BrowserView): """Browser view que retorna as configuracoes da Barra de Identidade""" - implements(IBarraHelper) - def __init__(self, context, request, *args, **kwargs): """Inicializacao da browser view diff --git a/src/brasil/gov/barra/config.py b/src/brasil/gov/barra/config.py index 6d9571d..33030b8 100644 --- a/src/brasil/gov/barra/config.py +++ b/src/brasil/gov/barra/config.py @@ -1,14 +1,14 @@ # -*- coding:utf-8 -*- from Products.CMFPlone import interfaces as plone_interfaces from Products.CMFQuickInstallerTool import interfaces as qi_interfaces -from zope.interface import implements +from zope.interface import implementer -PROJECTNAME = "brasil.gov.barra" +PROJECTNAME = 'brasil.gov.barra' +@implementer(qi_interfaces.INonInstallable) class HiddenProducts(object): """Oculta produtos do QuickInstaller""" - implements(qi_interfaces.INonInstallable) def getNonInstallableProducts(self): return [ @@ -18,9 +18,9 @@ def getNonInstallableProducts(self): ] +@implementer(plone_interfaces.INonInstallable) class HiddenProfiles(object): """Oculta profiles da tela inicial de criacao do site""" - implements(plone_interfaces.INonInstallable) def getNonInstallableProfiles(self): return [ diff --git a/src/brasil/gov/barra/configure.zcml b/src/brasil/gov/barra/configure.zcml index d197b7e..43483d9 100644 --- a/src/brasil/gov/barra/configure.zcml +++ b/src/brasil/gov/barra/configure.zcml @@ -7,7 +7,7 @@ i18n_domain="brasil.gov.barra"> - + @@ -23,7 +23,7 @@ name="brasil.gov.barra" directory="static" /> - + + estiver disponivel. + --> - + - + diff --git a/src/brasil/gov/barra/profiles/default/controlpanel.xml b/src/brasil/gov/barra/profiles/default/controlpanel.xml index fbf4b84..50de578 100644 --- a/src/brasil/gov/barra/profiles/default/controlpanel.xml +++ b/src/brasil/gov/barra/profiles/default/controlpanel.xml @@ -2,15 +2,15 @@ - - brasil.gov.portal: Configurar Barra - + + brasil.gov.portal: Configurar Barra + diff --git a/src/brasil/gov/barra/profiles/default/cssregistry.xml b/src/brasil/gov/barra/profiles/default/cssregistry.xml index 644f016..02180db 100644 --- a/src/brasil/gov/barra/profiles/default/cssregistry.xml +++ b/src/brasil/gov/barra/profiles/default/cssregistry.xml @@ -1,13 +1,13 @@ diff --git a/src/brasil/gov/barra/profiles/default/propertiestool.xml b/src/brasil/gov/barra/profiles/default/propertiestool.xml index 2c01040..6032b13 100644 --- a/src/brasil/gov/barra/profiles/default/propertiestool.xml +++ b/src/brasil/gov/barra/profiles/default/propertiestool.xml @@ -1,6 +1,6 @@ Configurações de sites governamentais - False + False diff --git a/src/brasil/gov/barra/profiles/default/viewlets.xml b/src/brasil/gov/barra/profiles/default/viewlets.xml index b1322bb..39dfbc1 100644 --- a/src/brasil/gov/barra/profiles/default/viewlets.xml +++ b/src/brasil/gov/barra/profiles/default/viewlets.xml @@ -1,6 +1,6 @@ - - - + + + diff --git a/src/brasil/gov/barra/tests/test_controlpanel.py b/src/brasil/gov/barra/tests/test_controlpanel.py index 500ff82..a60dcc7 100644 --- a/src/brasil/gov/barra/tests/test_controlpanel.py +++ b/src/brasil/gov/barra/tests/test_controlpanel.py @@ -26,7 +26,7 @@ def test_controlpanel_view(self): request=self.portal.REQUEST, ) view = view.__of__(self.portal) - self.failUnless(view()) + self.assertTrue(view()) def test_controlpanel_configlet(self): """Acesso a view nao pode ser feito por usuario anonimo""" @@ -36,12 +36,12 @@ def test_controlpanel_configlet(self): # Listamos todas as acoes do painel de controle installed = [a['id'] for a in controlpanel.enumConfiglets(group='Products')] # Validamos que o painel de controle da barra esteja instalado - self.failUnless('barra-config' in installed) + self.assertTrue('barra-config' in installed) # Ao acessar a view como anonimo, a excecao e levantada with api.env.adopt_roles(['Anonymous', ]): # Listamos todas as acoes do painel de controle installed = [a['id'] for a in controlpanel.enumConfiglets(group='Products')] - self.failIf('barra-config' in installed) + self.assertFalse('barra-config' in installed) def test_controlpanel_view_protected(self): """Acesso a view nao pode ser feito por usuario anonimo""" @@ -61,4 +61,4 @@ def test_configlet_install(self): installed = [a.getAction(self)['id'] for a in controlpanel.listActions()] # Validamos que o painel de controle da barra esteja instalado - self.failUnless('barra-config' in installed) + self.assertTrue('barra-config' in installed) diff --git a/src/brasil/gov/barra/tests/test_helper.py b/src/brasil/gov/barra/tests/test_helper.py index 10b187e..729ad38 100644 --- a/src/brasil/gov/barra/tests/test_helper.py +++ b/src/brasil/gov/barra/tests/test_helper.py @@ -27,7 +27,7 @@ def test_helper_view_registration(self): request=self.portal.REQUEST, ) view = view.__of__(self.portal) - self.failUnless(view) + self.assertTrue(view) def test_helper_view_local(self): """Uso do metodo local""" diff --git a/src/brasil/gov/barra/tests/test_setup.py b/src/brasil/gov/barra/tests/test_setup.py index da7f74d..bb769fa 100644 --- a/src/brasil/gov/barra/tests/test_setup.py +++ b/src/brasil/gov/barra/tests/test_setup.py @@ -37,7 +37,7 @@ class TestInstall(BaseTestCase): def test_installed(self): self.assertTrue(self.qi.isProductInstalled(PROJECTNAME), - '%s not installed' % PROJECTNAME) + '{0} not installed'.format(PROJECTNAME)) def test_browserlayer(self): from brasil.gov.barra.interfaces import IBarraInstalada @@ -45,15 +45,15 @@ def test_browserlayer(self): def test_cssregistry(self): portal_css = api.portal.get_tool('portal_css') - css_barra = "++resource++brasil.gov.barra/main.css" + css_barra = '++resource++brasil.gov.barra/main.css' self.assertTrue(css_barra in portal_css.getResourceIds(), - '%s not installed' % css_barra) + '{0} not installed'.format(css_barra)) def test_default_configuration(self): pp = api.portal.get_tool('portal_properties') sheet = getattr(pp, 'brasil_gov', None) self.assertTrue(sheet is not None) - self.assertFalse(sheet.getProperty("local")) + self.assertFalse(sheet.getProperty('local')) class TestUpgrade(BaseTestCase): @@ -105,7 +105,7 @@ def test_to1002_from1010(self): # Listamos todas as acoes do painel de controle installed = [a['id'] for a in controlpanel.enumConfiglets(group='Products')] # Validamos que o painel de controle da barra esteja instalado - self.failUnless('barra-config' in installed) + self.assertTrue('barra-config' in installed) class TestUninstall(BaseTestCase): @@ -124,6 +124,6 @@ def test_browserlayer(self): def test_cssregistry(self): portal_css = self.portal.portal_css - css_barra = "++resource++brasil.gov.barra/main.css" + css_barra = '++resource++brasil.gov.barra/main.css' self.assertTrue(css_barra not in portal_css.getResourceIds(), - '%s installed' % css_barra) + '{0} installed'.format(css_barra)) diff --git a/src/brasil/gov/barra/upgrades/v1000/configure.zcml b/src/brasil/gov/barra/upgrades/v1000/configure.zcml index 2761f19..92e80e9 100644 --- a/src/brasil/gov/barra/upgrades/v1000/configure.zcml +++ b/src/brasil/gov/barra/upgrades/v1000/configure.zcml @@ -4,7 +4,7 @@ xmlns:gs="http://namespaces.zope.org/genericsetup" i18n_domain="brasil.gov.barra"> - + - + - + diff --git a/src/brasil/gov/barra/upgrades/v1010/configure.zcml b/src/brasil/gov/barra/upgrades/v1010/configure.zcml index f8b22a1..03e70ad 100644 --- a/src/brasil/gov/barra/upgrades/v1010/configure.zcml +++ b/src/brasil/gov/barra/upgrades/v1010/configure.zcml @@ -3,7 +3,7 @@ xmlns:i18n="http://namespaces.zope.org/i18n" xmlns:gs="http://namespaces.zope.org/genericsetup" i18n_domain="brasil.gov.barra"> - + - + - - brasil.gov.portal: Configurar Barra - + + brasil.gov.portal: Configurar Barra + diff --git a/travis.cfg b/travis.cfg deleted file mode 100644 index 689ba44..0000000 --- a/travis.cfg +++ /dev/null @@ -1,22 +0,0 @@ -[buildout] -extends = - https://raw.github.com/collective/buildout.plonetest/master/travis-4.x.cfg - https://raw.github.com/collective/buildout.plonetest/master/qa.cfg - -package-name = brasil.gov.barra -package-extras = [test] -package-min-coverage = 56 - -parts += - createcoverage - coverage-sh - -[code-analysis] -recipe = plone.recipe.codeanalysis -directory = ${buildout:directory}/src/brasil/gov/barra -pre-commit-hook = False -flake8-ignore = E501 - -[versions] -# use latest version of setuptools -setuptools =