Skip to content

Commit

Permalink
Merge 879999e into dda461d
Browse files Browse the repository at this point in the history
  • Loading branch information
MrTango committed Jul 25, 2020
2 parents dda461d + 879999e commit 2e850fe
Show file tree
Hide file tree
Showing 32 changed files with 151 additions and 89 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ before_script:
- sleep 3

script:
- PYTEST_ADDOPTS="-s -vv" tox
- PYTEST_ADDOPTS="-s -vv" tox -r

after_success:
- coverage combine
Expand Down
17 changes: 13 additions & 4 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Changelog
=========

5.0.5 (unreleased)
5.1 (unreleased)
------------------

- Create upgrade step profile directory. Fixes #434
Expand All @@ -21,18 +21,27 @@ Changelog
- Update travis setup, use tox for all testing and linting of addon package, not code-analysis.
[MrTango]

- Update default Plone and Python version to 5.2.1 and 3.7 for addon template
- Update default Plone and Python version to 5.2.1 and 3.7 for addon template.
[MrTango]

- Add badges to addon README file
- Add badges to addon README file.
[MrTango]

- Add collective.recipe.vscode to addon base.cfg, activated by default, we have a question to disable it.
[MrTango]

- Fix flake8 missing trailing comma, format call uses missing keyword, provides unused keyword
- Fix flake8 missing trailing comma, format call uses missing keyword, provides unused keyword.
[fulv]

- Improve generated package tox env, also run linting inside skeleton-tests.
[MrTango]

- Improve bobtemplate.plone tox output, it's now easier to read and find the errors.
[MrTango]

- Automatically fix isort issues after using addon template.
[MrTango]


5.0.4 (2019-11-28)
------------------
Expand Down
11 changes: 11 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,13 @@ These templates are meant to be used inside a package which was created by the a

- behavior
- content_type
- indexer
- portlet
- restapi_service
- subscriber
- theme
- theme_barceloneta
- upgrade_step
- view
- viewlet
- vocabulary
Expand All @@ -84,11 +87,19 @@ Full documentation for end users and template developers can be found in the "do

It is also available online at http://docs.plone.org/develop/addons/bobtemplates.plone/docs/


Installation
============

You can install bobtemplates.plone as every other normal Python package with `pip <https://pypi.python.org/pypi/pip>`_ inside a `virtualenv <https://pypi.python.org/pypi/virtualenv>`_ or better with `pipenv <https://pypi.python.org/pypi/pipenv>`_.

Installation with pip global for a user
---------------------------------------

.. code-block:: console
pip install bobtemplates.plone --user
Installion with pipenv
----------------------
Expand Down
2 changes: 2 additions & 0 deletions bobtemplates/plone/addon.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from bobtemplates.plone.base import git_commit
from bobtemplates.plone.base import git_init
from bobtemplates.plone.base import make_path
from bobtemplates.plone.utils import run_isort

import os
import shutil
Expand Down Expand Up @@ -137,6 +138,7 @@ def pre_ask(configurator):

def post_render(configurator):
_cleanup_package(configurator)
run_isort(configurator)
git_init_status = git_init(configurator)
if git_init_status:
git_commit(
Expand Down
2 changes: 1 addition & 1 deletion bobtemplates/plone/addon/constraints.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
-c constraints.txt
-c constraints_plone52.txt
2 changes: 1 addition & 1 deletion bobtemplates/plone/addon/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
-c constraints_plone52.txt
-c constraints.txt
setuptools
zc.buildout
8 changes: 2 additions & 6 deletions bobtemplates/plone/addon/setup.cfg.bob
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,17 @@ ignore =
.gitattributes

[isort]
# for details see
# http://docs.plone.org/develop/styleguide/python.html#grouping-and-sorting
# black compatible isort rules:
force_alphabetical_sort = True
multi_line_output=3
include_trailing_comma=True
force_grid_wrap=0
use_parantheses = True
# force_single_line = True
lines_after_imports = 2
line_length = 88
not_skip =
__init__.py
skip =

[flake8]
# black compatible flake8 rules:
ignore =
W503,
C812,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@
from plone.app.contenttypes.testing import PLONE_APP_CONTENTTYPES_FIXTURE
{{% endif %}}
from plone.app.robotframework.testing import REMOTE_LIBRARY_BUNDLE_FIXTURE
from plone.app.testing import applyProfile
from plone.app.testing import FunctionalTesting
from plone.app.testing import IntegrationTesting
from plone.app.testing import (
applyProfile,
FunctionalTesting,
IntegrationTesting,
{{% if not plone.is_plone5 %}}
from plone.app.testing import PLONE_FIXTURE
PLONE_FIXTURE
{{% endif %}}
from plone.app.testing import PloneSandboxLayer
PloneSandboxLayer,
)
from plone.testing import z2

import {{{ package.dottedname }}}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# -*- coding: utf-8 -*-
"""Setup tests for this package."""
from {{{ package.dottedname }}}.testing import {{{package.uppercasename}}}_INTEGRATION_TESTING # noqa: E501
from plone import api
from plone.app.testing import setRoles
from plone.app.testing import TEST_USER_ID
from {{{package.dottedname}}}.testing import {{{package.uppercasename}}}_INTEGRATION_TESTING # noqa: E501

import unittest

Expand Down
2 changes: 1 addition & 1 deletion bobtemplates/plone/addon/test_plone43.cfg
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[buildout]

extends =
https://raw.github.com/collective/buildout.plonetest/master/test-4.3.x.cfg
https://raw.githubusercontent.com/collective/buildout.plonetest/master/test-4.3.x.cfg
https://raw.githubusercontent.com/collective/buildout.plonetest/master/qa.cfg
base.cfg

Expand Down
2 changes: 1 addition & 1 deletion bobtemplates/plone/addon/test_plone50.cfg
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[buildout]

extends =
https://raw.github.com/collective/buildout.plonetest/master/test-5.0.x.cfg
https://raw.githubusercontent.com/collective/buildout.plonetest/master/test-5.0.x.cfg
https://raw.githubusercontent.com/collective/buildout.plonetest/master/qa.cfg
base.cfg

Expand Down
2 changes: 1 addition & 1 deletion bobtemplates/plone/addon/test_plone51.cfg
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[buildout]

extends =
https://raw.github.com/collective/buildout.plonetest/master/test-5.1.x.cfg
https://raw.githubusercontent.com/collective/buildout.plonetest/master/test-5.1.x.cfg
https://raw.githubusercontent.com/collective/buildout.plonetest/master/qa.cfg
base.cfg

Expand Down
2 changes: 1 addition & 1 deletion bobtemplates/plone/addon/test_plone52.cfg
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[buildout]

extends =
https://raw.github.com/collective/buildout.plonetest/master/test-5.2.x.cfg
https://raw.githubusercontent.com/collective/buildout.plonetest/master/test-5.2.x.cfg
https://raw.githubusercontent.com/collective/buildout.plonetest/master/qa.cfg
base.cfg

Expand Down
19 changes: 12 additions & 7 deletions bobtemplates/plone/addon/tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ envlist =
{py27,py37}-lint,
py{27}-Plone{43,51},
py{27,37}-Plone{52},
build_instance,
# build_instance,
# docs,
# coverage-report,

Expand All @@ -17,9 +17,9 @@ extras =
test

commands =
{envbindir}/buildout -c {toxinidir}/{env:version_file} buildout:directory={envdir} buildout:develop={toxinidir} bootstrap
{envbindir}/buildout -c {toxinidir}/{env:version_file} buildout:directory={envdir} buildout:develop={toxinidir} annotate
{envbindir}/buildout -c {toxinidir}/{env:version_file} buildout:directory={envdir} buildout:develop={toxinidir} install test robot
{envbindir}/buildout -q -c {toxinidir}/{env:version_file} buildout:directory={envdir} buildout:develop={toxinidir} bootstrap
# {envbindir}/buildout -c {toxinidir}/{env:version_file} buildout:directory={envdir} buildout:develop={toxinidir} annotate
{envbindir}/buildout -qq -c {toxinidir}/{env:version_file} buildout:directory={envdir} buildout:develop={toxinidir} install test robot
coverage run {envbindir}/test -v1 --auto-color {posargs}
# coverage run {envbindir}/test -v --all -t robot {posargs}

Expand All @@ -39,6 +39,10 @@ deps =
Plone52: -cconstraints_plone52.txt
coverage

depends =
{py27,py37}-lint,


[testenv:coverage-report]
skip_install = true
usedevelop = True
Expand All @@ -63,7 +67,7 @@ commands =
skip_install = true

deps =
isort
isort<5
flake8
# helper to generate HTML reports:
flake8-html
Expand Down Expand Up @@ -91,20 +95,21 @@ deps =
commands =
mkdir -p {toxinidir}/reports/flake8
- flake8 --format=html --htmldir={toxinidir}/reports/flake8 --doctests src setup.py
flake8 --doctests src tests setup.py
flake8 --doctests src setup.py
isort --check-only --recursive {toxinidir}/src

whitelist_externals =
mkdir

[testenv:isort-apply]
basepython = python3.7
skip_install = true

deps =
isort

commands =
isort --apply --recursive {toxinidir}/src
isort {toxinidir}/src

[testenv:py27-lint]
basepython = python2.7
Expand Down
2 changes: 2 additions & 0 deletions bobtemplates/plone/portlet.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from bobtemplates.plone.base import git_commit
from bobtemplates.plone.base import update_file
from bobtemplates.plone.base import ZCML_NAMESPACES
from bobtemplates.plone.utils import run_isort
from bobtemplates.plone.utils import slugify
from lxml import etree

Expand Down Expand Up @@ -183,6 +184,7 @@ def post_renderer(configurator):
_update_portlets_configure_zcml(configurator)
_update_portlets_xml(configurator)
_delete_unnecessary_files(configurator)
run_isort(configurator)
git_commit(
configurator,
u'Add portlet: {0}'.format(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ from zope.component import getMultiAdapter
from zope.interface import implementer

import json
import six.moves.urllib.request, six.moves.urllib.parse, six.moves.urllib.error
import six.moves.urllib.request, six.moves.urllib.error, six.moves.urllib.parse
import six.moves.urllib.error
import six.moves.urllib.parse
import six.moves.urllib.request


class {{{data_provider_class_name}}}(IPortletDataProvider):
Expand Down
15 changes: 15 additions & 0 deletions bobtemplates/plone/utils.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# -*- coding: utf-8 -*-
from bobtemplates.plone.base import _get_package_root_folder

import re
import six
import subprocess
import unicodedata


Expand Down Expand Up @@ -63,3 +66,15 @@ def slugify(value):
)
value = re.sub(r'[^\w\s-]', '', value).strip().lower()
return re.sub(r'[-\s]+', '-', value)


def run_isort(configurator):
root_folder = _get_package_root_folder(configurator)
try:
test_result = subprocess.check_output(
['tox', '-e', 'isort-apply'],
cwd=root_folder,
)
print(u'\nisort-apply: successful:\n{0}\n'.format(safe_unicode(test_result)))
except subprocess.CalledProcessError as execinfo:
print(u'Error on isort-apply: {0}'.format(safe_unicode(execinfo.output)))
2 changes: 1 addition & 1 deletion constraints.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Pin Versions / Version Ranges if necessary.

setuptools==40.2.0
isort==4.3.4
tox>=3.6
isort>=5
pytest>=4.3.0
coverage<5
5 changes: 4 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,11 @@ norecursedirs = fixures
isort_ignore =

[coverage:run]
parallel = True
branch = True
source = bobtemplates
source =
./bobtemplates

omit =
# Tests are classically not part of source code
# and should not be calculated into coverage sum
Expand Down
30 changes: 18 additions & 12 deletions skeleton-tests/base.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
# -*- coding: utf-8 -*-

# from bobtemplates.plone.utils import safe_encode
from bobtemplates.plone.utils import safe_unicode

import contextlib
import logging
import os
import subprocess


logger = logging.getLogger("skeleton-tests")


@contextlib.contextmanager
def dummy_contextmanager():
yield None
Expand All @@ -24,19 +29,20 @@ def file_exists(base_path, file_path):

def run_skeleton_tox_env(wd, config):
try:
test_result = subprocess.check_output(
returncode = subprocess.check_call(
['tox', '-e', config.skeleton_tox_env],
cwd=wd,
)
print(u'\n{0}\n'.format(safe_unicode(test_result)))
# logger.debug(u'\n{0}\n'.format(safe_unicode(test_result)))
return returncode
except subprocess.CalledProcessError as execinfo:
tox_msg = safe_unicode(
b''.join(bytes(execinfo.output)),
)
print(tox_msg)
tox_summary = safe_unicode(
b''.join(
execinfo.output.partition(b'__ summary __')[1:],
),
)
assert execinfo.returncode == 0, '\n{0}'.format(tox_summary)
logger.debug(u'{0}'.format(safe_unicode(execinfo.output)))
return execinfo.returncode
# tox_msg = safe_unicode(execinfo.output)
# print(tox_msg)
# tox_summary = safe_unicode(
# b''.join(
# execinfo.output.partition(b'__ summary __')[1:],
# ),
# )
# assert execinfo.returncode == 0 #, u'\n{0}'.format(tox_msg)

0 comments on commit 2e850fe

Please sign in to comment.