diff --git a/.editorconfig b/.editorconfig index 8ae05aa..55bfb6d 100644 --- a/.editorconfig +++ b/.editorconfig @@ -1,5 +1,5 @@ # Generated from: -# https://github.com/plone/meta/tree/master/config/default +# https://github.com/plone/meta/tree/2.x/src/plone/meta/default # See the inline comments on how to expand/tweak this configuration file # # EditorConfig Configuration file, for more details see: @@ -13,7 +13,8 @@ root = true -[*] # For All Files +[*] +# Default settings for all files. # Unix-style newlines with a newline ending every file end_of_line = lf insert_final_newline = true @@ -29,11 +30,12 @@ max_line_length = off # 4 space indentation indent_size = 4 -[*.{yml,zpt,pt,dtml,zcml}] +[*.{yml,zpt,pt,dtml,zcml,html,xml}] # 2 space indentation indent_size = 2 -[*.{json,jsonl,js,jsx,ts,tsx,css,less,scss,html}] # Frontend development +[*.{json,jsonl,js,jsx,ts,tsx,css,less,scss}] +# Frontend development # 2 space indentation indent_size = 2 max_line_length = 80 diff --git a/.flake8 b/.flake8 index 7ef4f64..ff17672 100644 --- a/.flake8 +++ b/.flake8 @@ -1,5 +1,5 @@ # Generated from: -# https://github.com/plone/meta/tree/master/config/default +# https://github.com/plone/meta/tree/2.x/src/plone/meta/default # See the inline comments on how to expand/tweak this configuration file [flake8] doctests = 1 diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..8da3888 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,11 @@ +# Generated from: +# https://github.com/plone/meta/tree/2.x/src/plone/meta/default +# See the inline comments on how to expand/tweak this configuration file +version: 2 +updates: + + - package-ecosystem: "github-actions" + directory: "/" + schedule: + # Check for updates to GitHub Actions every week + interval: "weekly" diff --git a/.github/workflows/meta.yml b/.github/workflows/meta.yml index 40bb5c1..df9c753 100644 --- a/.github/workflows/meta.yml +++ b/.github/workflows/meta.yml @@ -1,16 +1,10 @@ # Generated from: -# https://github.com/plone/meta/tree/master/config/default +# https://github.com/plone/meta/tree/2.x/src/plone/meta/default # See the inline comments on how to expand/tweak this configuration file name: Meta + on: push: - branches: - - master - - main - pull_request: - branches: - - master - - main workflow_dispatch: ## @@ -25,18 +19,21 @@ on: jobs: qa: - uses: plone/meta/.github/workflows/qa.yml@main - test: - uses: plone/meta/.github/workflows/test.yml@main + uses: plone/meta/.github/workflows/qa.yml@2.x + coverage: + uses: plone/meta/.github/workflows/coverage.yml@2.x + dependencies: + uses: plone/meta/.github/workflows/dependencies.yml@2.x release_ready: - uses: plone/meta/.github/workflows/release_ready.yml@main + uses: plone/meta/.github/workflows/release_ready.yml@2.x + circular: + uses: plone/meta/.github/workflows/circular.yml@2.x ## # To modify the list of default jobs being created add in .meta.toml: # [github] # jobs = [ # "qa", -# "test", # "coverage", # "dependencies", # "release_ready", diff --git a/.github/workflows/test-matrix.yml b/.github/workflows/test-matrix.yml new file mode 100644 index 0000000..de94628 --- /dev/null +++ b/.github/workflows/test-matrix.yml @@ -0,0 +1,65 @@ +# Generated from: +# https://github.com/plone/meta/tree/2.x/src/plone/meta/default +# See the inline comments on how to expand/tweak this configuration file +name: Tests + +on: + push: + workflow_dispatch: + +jobs: + build: + permissions: + contents: read + pull-requests: write + strategy: + # We want to see all failures: + fail-fast: false + matrix: + os: + - ["ubuntu", "ubuntu-latest"] + config: + # [Python version, visual name, tox env] + - ["3.14", "6.2 on py3.14", "py314-plone62"] + - ["3.10", "6.2 on py3.10", "py310-plone62"] + + runs-on: ${{ matrix.os[1] }} + if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name + name: ${{ matrix.config[1] }} + steps: + - uses: actions/checkout@v6 + with: + persist-credentials: false + - name: Install uv + caching + uses: astral-sh/setup-uv@v8.0.0 + with: + enable-cache: true + cache-dependency-glob: | + setup.* + tox.ini + pyproject.toml + python-version: ${{ matrix.config[0] }} + +## +# Add extra configuration options in .meta.toml: +# [github] +# extra_lines_after_os_dependencies = """ +# _your own configuration lines_ +# """ +## + - name: Initialize tox + # the bash one-liner below does not work on Windows + if: contains(matrix.os, 'ubuntu') + run: | + if [ `uvx tox list --no-desc -f init|wc -l` = 1 ]; then uvx --with tox-uv tox -e init;else true; fi + - name: Test + run: uvx --with tox-uv tox -e ${{ matrix.config[2] }} + + +## +# Add extra configuration options in .meta.toml: +# [github] +# extra_lines = """ +# _your own configuration lines_ +# """ +## diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml deleted file mode 100644 index bdc21be..0000000 --- a/.github/workflows/test.yml +++ /dev/null @@ -1,40 +0,0 @@ -name: Plone 5.2 tests - -on: - push: - branches: - - master - pull_request: - branches: - - master - -jobs: - build: - strategy: - fail-fast: false - matrix: - config: - # [Python version, tox env] - - ["3.8", "plone52"] - runs-on: ubuntu-20.04 - name: ${{ matrix.config[1] }}-py${{ matrix.config[0] }} - steps: - - uses: actions/checkout@v3 - - name: Set up Python - uses: actions/setup-python@v4 - with: - python-version: ${{ matrix.config[0] }} - - name: Pip cache - uses: actions/cache@v2 - with: - path: ~/.cache/pip - key: ${{ runner.os }}-pip-${{ matrix.config[0] }}-${{ matrix.config[1] }}-${{ hashFiles('setup.*', 'tox.ini') }} - restore-keys: | - ${{ runner.os }}-pip-${{ matrix.config[0] }}- - ${{ runner.os }}-pip- - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install tox - - name: Test - run: tox -e ${{ matrix.config[1] }} diff --git a/.gitignore b/.gitignore index 503e47c..224bcb6 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,5 @@ # Generated from: -# https://github.com/plone/meta/tree/master/config/default +# https://github.com/plone/meta/tree/2.x/src/plone/meta/default # See the inline comments on how to expand/tweak this configuration file # python related *.egg-info @@ -20,6 +20,8 @@ __pycache__/ .tox .vscode/ node_modules/ +forest.dot +forest.json # venv / buildout related bin/ @@ -35,6 +37,8 @@ lib64 parts/ pyvenv.cfg var/ +local.cfg +share/ # mxdev /instance/ diff --git a/.meta.toml b/.meta.toml index 1cce024..10157ea 100644 --- a/.meta.toml +++ b/.meta.toml @@ -1,31 +1,21 @@ # Generated from: -# https://github.com/plone/meta/tree/master/config/default +# https://github.com/plone/meta/tree/2.x/src/plone/meta/default # See the inline comments on how to expand/tweak this configuration file [meta] template = "default" -commit-id = "8c30aa23" - -[tox] -extra_lines = """ -[testenv:plone52] -min_version = 3.28.0 -description = Plone 5.2 tests with buildout -skip_install = true -deps = - -rrequirements_plone52.txt -commands_pre = - {envbindir}/buildout -nc {toxinidir}/test_plone52.cfg buildout:directory={envdir} buildout:develop={toxinidir} -commands = - {envbindir}/code-analysis - {envbindir}/test {posargs} -""" +commit-id = "2.8.0" [github] jobs = [ "qa", - "test", + "coverage", + "dependencies", "release_ready", + "circular" ] +[tox] +test_matrix = {"6.2" = ["*"]} + [pyproject] dependencies_ignores = "['plone.base', 'plone.app.layout']" diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index f13d059..fd9a409 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,5 +1,5 @@ # Generated from: -# https://github.com/plone/meta/tree/master/config/default +# https://github.com/plone/meta/tree/2.x/src/plone/meta/default # See the inline comments on how to expand/tweak this configuration file ci: autofix_prs: false @@ -7,20 +7,20 @@ ci: repos: - repo: https://github.com/asottile/pyupgrade - rev: v3.15.0 + rev: v3.21.2 hooks: - id: pyupgrade - args: [--py38-plus] + args: [--py310-plus] - repo: https://github.com/pycqa/isort - rev: 5.12.0 + rev: 8.0.1 hooks: - id: isort -- repo: https://github.com/psf/black - rev: 23.10.1 +- repo: https://github.com/psf/black-pre-commit-mirror + rev: 26.3.1 hooks: - id: black - repo: https://github.com/collective/zpretty - rev: 3.1.0 + rev: 3.1.1 hooks: - id: zpretty @@ -32,7 +32,7 @@ repos: # """ ## - repo: https://github.com/PyCQA/flake8 - rev: 6.1.0 + rev: 7.3.0 hooks: - id: flake8 @@ -44,7 +44,7 @@ repos: # """ ## - repo: https://github.com/codespell-project/codespell - rev: v2.2.6 + rev: v2.4.2 hooks: - id: codespell additional_dependencies: @@ -58,20 +58,20 @@ repos: # """ ## - repo: https://github.com/mgedmin/check-manifest - rev: "0.49" + rev: "0.51" hooks: - id: check-manifest - repo: https://github.com/regebro/pyroma - rev: "4.2" + rev: "5.0.1" hooks: - id: pyroma - repo: https://github.com/mgedmin/check-python-versions - rev: "0.22.0" + rev: "0.24.0" hooks: - id: check-python-versions - args: ['--only', 'setup.py,pyproject.toml'] + args: ['--only', 'setup.py,tox.ini'] - repo: https://github.com/collective/i18ndude - rev: "6.1.0" + rev: "6.3.0" hooks: - id: i18ndude diff --git a/MANIFEST.in b/MANIFEST.in index c2509f3..532c268 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,12 +1,7 @@ -include *.txt +graft src +graft docs include *.rst - -recursive-include src * -recursive-include docs * - global-exclude *.pyc exclude .coveragerc -exclude base.cfg -exclude buildout.cfg -exclude test_plone52.cfg exclude tox.ini +prune news \ No newline at end of file diff --git a/README.rst b/README.rst index 4b4f9c4..3a2f6f1 100644 --- a/README.rst +++ b/README.rst @@ -13,6 +13,7 @@ Lineage can be used within a large organization to manage multiple microsites, s Version information =================== +- 4.x: Plone 6.2 - Python 3.10+ - PEP 420 native namespace - 3.x: Plone 5.2, 6.0 - Python 3.8+ - 2.x: Plone 5.0, 5.1, 5.2 - Python 2.7 - 1.x: Plone 4.3 diff --git a/base.cfg b/base.cfg deleted file mode 100644 index 6451ef0..0000000 --- a/base.cfg +++ /dev/null @@ -1,106 +0,0 @@ -[buildout] -show-picked-versions = true -extensions = - mr.developer - -index = https://pypi.python.org/simple/ - -parts = - instance - test - code-analysis - coverage - test-coverage - createcoverage - releaser - i18ndude - omelette - robot - plone-helper-scripts -develop = . - - -[instance] -recipe = plone.recipe.zope2instance -user = admin:admin -http-address = 8080 -environment-vars = - zope_i18n_compile_mo_files true -eggs = - Plone - Pillow - collective.lineage [test] - - -[code-analysis] -recipe = plone.recipe.codeanalysis[recommended] -directory = ${buildout:directory}/src/{{{ package.namespace }}} -return-status-codes = False - - -[omelette] -recipe = collective.recipe.omelette -eggs = ${instance:eggs} - - -[test] -recipe = zc.recipe.testrunner -eggs = ${instance:eggs} -initialization = - os.environ['TZ'] = 'UTC' -defaults = ['-s', 'collective.lineage', '--auto-color', '--auto-progress'] - - -[coverage] -recipe = zc.recipe.egg -eggs = coverage - - -[test-coverage] -recipe = collective.recipe.template -input = inline: - #!/bin/bash - export TZ=UTC - ${buildout:directory}/bin/coverage run bin/test $* - ${buildout:directory}/bin/coverage html - ${buildout:directory}/bin/coverage report -m --fail-under=90 - # Fail (exit status 1) if coverage returns exit status 2 (this happens - # when test coverage is below 100%. -output = ${buildout:directory}/bin/test-coverage -mode = 755 - - -[createcoverage] -recipe = zc.recipe.egg -eggs = createcoverage - - -[robot] -recipe = zc.recipe.egg -eggs = - ${test:eggs} - plone.app.robotframework[debug,reload] - - -[releaser] -recipe = zc.recipe.egg -eggs = zest.releaser - - -[i18ndude] -recipe = zc.recipe.egg -eggs = i18ndude - -[plone-helper-scripts] -recipe = zc.recipe.egg -eggs = - Products.CMFPlone - ${instance:eggs} -interpreter = zopepy -scripts = - zopepy - plone-compile-resources - -[versions] -# Don't use a released version of collective.lineage -collective.lineage = diff --git a/buildout.cfg b/buildout.cfg deleted file mode 100644 index 1ff605d..0000000 --- a/buildout.cfg +++ /dev/null @@ -1,6 +0,0 @@ -[buildout] - -# use this extend one of the buildout configuration: -extends = - test_plone52.cfg - test_plone60.cfg diff --git a/constraints.txt b/constraints.txt deleted file mode 100644 index c0e8f2f..0000000 --- a/constraints.txt +++ /dev/null @@ -1 +0,0 @@ --c https://dist.plone.org/release/6.0-dev/constraints.txt diff --git a/constraints_plone52.txt b/constraints_plone52.txt deleted file mode 100644 index 7efc510..0000000 --- a/constraints_plone52.txt +++ /dev/null @@ -1 +0,0 @@ --c https://dist.plone.org/release/5.2-latest/constraints.txt diff --git a/news/.gitkeep b/news/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/news/3928.breaking b/news/3928.breaking new file mode 100644 index 0000000..f2360fa --- /dev/null +++ b/news/3928.breaking @@ -0,0 +1,4 @@ +Replace ``pkg_resources`` namespace with PEP 420 native namespace. +Support only Plone 6.2 and Python 3.10+. +When you use ``collective.lineage`` with other packages in the ``collective`` namespace, and you get a ``ModuleNotFoundError``, you may need to install ``horse-with-no-namespace``, or use ``zc.buildout`` 5. +[szakitibi] \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index 7a4d2d7..3002f6a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,8 +1,46 @@ # Generated from: -# https://github.com/plone/meta/tree/master/config/default +# https://github.com/plone/meta/tree/2.x/src/plone/meta/default # See the inline comments on how to expand/tweak this configuration file [build-system] -requires = ["setuptools>=68.2"] +requires = ["setuptools>=68.2,<83", "wheel"] + + + +[tool.towncrier] +directory = "news/" +filename = "CHANGES.rst" +title_format = "{version} ({project_date})" +underlines = ["-", ""] + +[[tool.towncrier.type]] +directory = "breaking" +name = "Breaking changes:" +showcontent = true + +[[tool.towncrier.type]] +directory = "feature" +name = "New features:" +showcontent = true + +[[tool.towncrier.type]] +directory = "bugfix" +name = "Bug fixes:" +showcontent = true + +[[tool.towncrier.type]] +directory = "internal" +name = "Internal:" +showcontent = true + +[[tool.towncrier.type]] +directory = "documentation" +name = "Documentation:" +showcontent = true + +[[tool.towncrier.type]] +directory = "tests" +name = "Tests:" +showcontent = true ## # Add extra configuration options in .meta.toml: @@ -24,7 +62,7 @@ profile = "plone" ## [tool.black] -target-version = ["py38"] +target-version = ["py310"] ## # Add extra configuration options in .meta.toml: @@ -35,7 +73,7 @@ target-version = ["py38"] ## [tool.codespell] -ignore-words-list = "discreet," +ignore-words-list = "discreet,assertin,thet," skip = "*.po," ## # Add extra configuration options in .meta.toml: @@ -83,6 +121,7 @@ Zope = [ 'Products.CMFCore', 'Products.CMFDynamicViewFTI', ] python-dateutil = ['dateutil'] +pytest-plone = ['pytest', 'zope.pytestlayer', 'plone.testing', 'plone.app.testing'] ignore-packages = ['plone.base', 'plone.app.layout'] ## @@ -98,13 +137,15 @@ ignore-packages = ['plone.base', 'plone.app.layout'] [tool.check-manifest] ignore = [ ".editorconfig", + ".flake8", ".meta.toml", ".pre-commit-config.yaml", - "tox.ini", - ".flake8", + "dependabot.yml", "mx.ini", + "tox.ini", ] + ## # Add extra configuration options in .meta.toml: # [pyproject] @@ -112,6 +153,11 @@ ignore = [ # "*.map.js", # "*.pyc", # """ +# check_manifest_extra_lines = """ +# ignore-bad-ideas = [ +# "some/test/file/PKG-INFO", +# ] +# """ ## diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index cbccb03..0000000 --- a/requirements.txt +++ /dev/null @@ -1,2 +0,0 @@ --c constraints.txt --r https://dist.plone.org/release/6.0-latest/requirements.txt diff --git a/requirements_plone52.txt b/requirements_plone52.txt deleted file mode 100644 index 52f04ce..0000000 --- a/requirements_plone52.txt +++ /dev/null @@ -1,2 +0,0 @@ --c constraints_plone52.txt --r https://dist.plone.org/release/5.2-latest/requirements.txt diff --git a/setup.py b/setup.py index 15de4de..ab1e4d1 100644 --- a/setup.py +++ b/setup.py @@ -1,8 +1,6 @@ from pathlib import Path -from setuptools import find_packages from setuptools import setup - version = "3.0.1.dev0" short_description = "The microsite creation product for Plone" long_description = "\n\n".join( @@ -19,18 +17,18 @@ "Development Status :: 5 - Production/Stable", "Environment :: Web Environment", "Framework :: Plone", - "Framework :: Plone :: 5.2", - "Framework :: Plone :: 6.0", + "Framework :: Plone :: 6.2", "Framework :: Plone :: Addon", "Intended Audience :: End Users/Desktop", "Intended Audience :: System Administrators", "License :: OSI Approved :: GNU General Public License (GPL)", "Operating System :: OS Independent", "Programming Language :: Python", - "Programming Language :: Python :: 3.8", - "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", + "Programming Language :: Python :: 3.14", "Topic :: Software Development :: Libraries :: Python Modules", ], keywords="plone lineage", @@ -38,24 +36,21 @@ author_email="info@sixfeetup.com", url="https://pypi.org/project/collective-lineage", license="GPL", - packages=find_packages("src"), - package_dir={"": "src"}, - namespace_packages=["collective"], include_package_data=True, zip_safe=False, - python_requires=">=3.8", + python_requires=">=3.10", install_requires=[ - "setuptools", + "Zope", "Products.CMFCore", - "Products.CMFPlone", "five.localsitemanager", "plone.browserlayer", - "plone.dexterity", "plone.folder", ], extras_require={ "test": [ "plone.app.testing", + "plone.app.contenttypes", + "plone.dexterity", "plone.testing>=5.0.0", ], }, diff --git a/src/collective/__init__.py b/src/collective/__init__.py deleted file mode 100644 index 5284146..0000000 --- a/src/collective/__init__.py +++ /dev/null @@ -1 +0,0 @@ -__import__("pkg_resources").declare_namespace(__name__) diff --git a/src/collective/lineage/__init__.py b/src/collective/lineage/__init__.py index 0e32ff5..892f5fe 100644 --- a/src/collective/lineage/__init__.py +++ b/src/collective/lineage/__init__.py @@ -1,4 +1,3 @@ import zope.i18nmessageid - MessageFactory = zope.i18nmessageid.MessageFactory("collective.lineage") diff --git a/src/collective/lineage/browser.py b/src/collective/lineage/browser.py index 06796ca..bcd00e6 100644 --- a/src/collective/lineage/browser.py +++ b/src/collective/lineage/browser.py @@ -2,6 +2,7 @@ from collective.lineage.interfaces import IChildSite from collective.lineage.utils import disable_childsite from collective.lineage.utils import enable_childsite +from plone.base.defaultpage import is_default_page from plone.folder.interfaces import IFolder from Products.CMFCore.utils import getToolByName from Products.Five.browser import BrowserView @@ -9,18 +10,6 @@ from zope.component import getMultiAdapter from zope.i18nmessageid import MessageFactory - -try: - from plone.base.defaultpage import is_default_page -except ImportError: - try: - # BBB - from Products.CMFPlone.utils import defaultpage as is_default_page - except ImportError: - # BBB BBB - from Products.CMFPlone.utils import isDefaultPage as is_default_page - - _ = MessageFactory("collective.lineage") diff --git a/src/collective/lineage/configure.zcml b/src/collective/lineage/configure.zcml index 8d00a7b..b7ad732 100644 --- a/src/collective/lineage/configure.zcml +++ b/src/collective/lineage/configure.zcml @@ -12,12 +12,12 @@ mark_layer subscriber will be run before the child site site manager is set up otherwise --> diff --git a/src/collective/lineage/interfaces.py b/src/collective/lineage/interfaces.py index b81db14..e99be5b 100644 --- a/src/collective/lineage/interfaces.py +++ b/src/collective/lineage/interfaces.py @@ -1,14 +1,8 @@ +from plone.base.interfaces import INavigationRoot from zope.component.interfaces import IPossibleSite from zope.i18nmessageid import MessageFactory from zope.interface import Interface - -try: - from plone.base.interfaces import INavigationRoot -except ImportError: - from plone.app.layout.navigation.interfaces import INavigationRoot - - _ = MessageFactory("collective.lineage") diff --git a/src/collective/lineage/testing.py b/src/collective/lineage/testing.py index fd22a4b..ab21d68 100644 --- a/src/collective/lineage/testing.py +++ b/src/collective/lineage/testing.py @@ -2,36 +2,16 @@ Common Lineage test fixtures and cases. """ -try: - # BBB - import unittest2 as unittest -except ImportError: - import unittest - -try: - from plone.testing import zope -except ImportError: - # BBB Plone 5.1 - from plone.testing import z2 as zope -try: - from plone.testing.zope import WSGI_SERVER_FIXTURE as SERVER_FIXTURE -except ImportError: - # BBB Plone 5.1 - from plone.testing.z2 import ZSERVER_FIXTURE as SERVER_FIXTURE - from plone.app import testing as pa_testing from plone.app.testing import applyProfile from plone.app.testing import FunctionalTesting from plone.app.testing import IntegrationTesting from plone.app.testing import PLONE_FIXTURE from plone.app.testing import PloneSandboxLayer +from plone.testing import zope +from plone.testing.zope import WSGI_SERVER_FIXTURE - -try: - from Products.CMFPlone.utils import get_installer -except ImportError: - # BBB for Plone 5.0 and lower. - get_installer = None +import unittest class LineageLayer(PloneSandboxLayer): @@ -39,22 +19,14 @@ class LineageLayer(PloneSandboxLayer): def setUpZope(self, app, configurationContext): import collective.lineage + import plone.app.contenttypes - try: - import plone.app.contenttypes - - self["has_pact"] = True - except ImportError: - self["has_pact"] = False self.loadZCML(package=collective.lineage) - if self["has_pact"]: - self.loadZCML(package=plone.app.contenttypes) - if self["has_pact"]: - zope.installProduct(app, "plone.app.contenttypes") + self.loadZCML(package=plone.app.contenttypes) + zope.installProduct(app, "plone.app.contenttypes") def setUpPloneSite(self, portal): - if self["has_pact"]: - applyProfile(portal, "plone.app.contenttypes:default") + applyProfile(portal, "plone.app.contenttypes:default") applyProfile(portal, "collective.lineage:default") @@ -72,7 +44,8 @@ def setUpPloneSite(self, portal): LINEAGE_SERVER_TESTING = FunctionalTesting( - bases=(LINEAGE_FIXTURE, SERVER_FIXTURE), name="collective.lineage:ServerTesting" + bases=(LINEAGE_FIXTURE, WSGI_SERVER_FIXTURE), + name="collective.lineage:ServerTesting", ) diff --git a/src/collective/lineage/tests/test_adapter.py b/src/collective/lineage/tests/test_adapter.py index 04b25ee..0604215 100644 --- a/src/collective/lineage/tests/test_adapter.py +++ b/src/collective/lineage/tests/test_adapter.py @@ -1,10 +1,8 @@ from .. import testing from plone.dexterity.interfaces import IDexterityFTI -from zope.component import getGlobalSiteManager from zope.component import queryUtility from zope.component.hooks import setSite - PROJECTNAME = "collective.lineage" @@ -13,30 +11,6 @@ class AdapterTestCase(testing.LineageTestCase): Test adapter lookup in a child site. """ - def test_adapter_registered_correctly(self): - """this test is ATCT only""" - if self.layer["has_pact"]: - return - from plone.app.imaging.interfaces import IImagingSchema - - sm = getGlobalSiteManager() - registrations = [ - a for a in sm.registeredAdapters() if a.provided == IImagingSchema - ] - self.assertEqual(len(registrations), 1) - - def test_childsite_is_image_traverser(self): - """this test is ATCT only""" - if self.layer["has_pact"]: - return - from collective.lineage.utils import enable_childsite - from plone.app.imaging.configlet import ImagingControlPanelAdapter - from plone.app.imaging.interfaces import IImagingSchema - - enable_childsite(self.portal.site1) - configuration = IImagingSchema(self.portal.site1) - self.assertIsInstance(configuration, ImagingControlPanelAdapter) - def test_childsite_query_utility(self): from collective.lineage.utils import enable_childsite diff --git a/src/collective/lineage/tests/test_browser.py b/src/collective/lineage/tests/test_browser.py index 154d6f6..f51c0c7 100644 --- a/src/collective/lineage/tests/test_browser.py +++ b/src/collective/lineage/tests/test_browser.py @@ -2,17 +2,12 @@ Test Lineage in the test browser. """ -import transaction - - -try: - from plone.testing import zope -except ImportError: - # BBB Plone 5.1 - from plone.testing import z2 as zope - from .. import testing +from collective.lineage import utils from plone.app import testing as pa_testing +from plone.testing import zope + +import transaction class TestLineageInBrowser(testing.LineageTestCase): @@ -80,3 +75,38 @@ def test_browser_add_content(self): self.childsite.objectIds(), "Document not present in child site after submitting add form", ) + + def test_browser_disable_subsite(self): + """ + Child site can be disabled. + """ + utils.enable_childsite(self.childsite) + transaction.commit() + browser = self.setUpBrowser() + browser.open(self.childsite.absolute_url()) + browser.getLink("Disable Subsite").click() + self.assertIsNotNone(browser.getLink("Enable Subsite")) + + +class TestLinageUtilsView(testing.LineageTestCase): + + def setUp(self): + super().setUp() + utils.enable_childsite(self.childsite) + + def test_on_siteroot(self): + view = self.portal.restrictedTraverse("lineageutils") + self.assertFalse(view.isChildSite()) + self.assertIsNone(view.current_childsite) + + def test_on_childsite(self): + view = self.childsite.restrictedTraverse("lineageutils") + self.assertTrue(view.isChildSite()) + self.assertEqual(view.current_childsite, self.childsite) + + def test_on_childsite_content(self): + doc_id = self.childsite.invokeFactory("Document", "d1", title="Test") + document = self.childsite[doc_id] + view = document.restrictedTraverse("lineageutils") + self.assertTrue(view.isChildSite()) + self.assertEqual(view.current_childsite, self.childsite) diff --git a/src/collective/lineage/tests/test_setup.py b/src/collective/lineage/tests/test_setup.py index 62bef54..7dee54d 100644 --- a/src/collective/lineage/tests/test_setup.py +++ b/src/collective/lineage/tests/test_setup.py @@ -1,21 +1,10 @@ from collective.lineage.testing import LINEAGE_INTEGRATION_TESTING from plone.app.testing import setRoles from plone.app.testing import TEST_USER_ID +from plone.base.utils import get_installer from plone.browserlayer.utils import registered_layers - -try: - # BBB - import unittest2 as unittest -except ImportError: - import unittest - -try: - from Products.CMFPlone.utils import get_installer -except ImportError: - # BBB for Plone 5.0 and lower. - get_installer = None - +import unittest PROJECTNAME = "collective.lineage" diff --git a/src/collective/lineage/tests/test_utils.py b/src/collective/lineage/tests/test_utils.py index dea8745..507da3d 100644 --- a/src/collective/lineage/tests/test_utils.py +++ b/src/collective/lineage/tests/test_utils.py @@ -3,7 +3,9 @@ from plone.browserlayer import utils as layer_utils from zope import component from zope import interface +from zope.site.hooks import site as site_hook +import unittest PROJECTNAME = "collective.lineage" @@ -54,3 +56,14 @@ def test_childsite_browserlayer(self): IChildSiteLayer.providedBy(self.portal.REQUEST), "Child site browser layer not applied to the request", ) + + def test_parent_site_on_siteroot(self): + site = utils.parent_site() + self.assertEqual(site, self.portal) + + @unittest.skip("Currently fails, due to `_find_site` always going for aq_parent.") + def test_parent_site_on_childsite(self): + utils.enable_childsite(self.childsite) + with site_hook(self.childsite): + site = utils.parent_site() + self.assertEqual(site, self.childsite) diff --git a/src/collective/lineage/upgrades.py b/src/collective/lineage/upgrades.py index df87ec7..e9c6f81 100644 --- a/src/collective/lineage/upgrades.py +++ b/src/collective/lineage/upgrades.py @@ -1,6 +1,5 @@ from logging import getLogger - logger = getLogger("collective.lineage.upgrades") diff --git a/src/collective/lineage/utils.py b/src/collective/lineage/utils.py index cea16cf..3b61619 100644 --- a/src/collective/lineage/utils.py +++ b/src/collective/lineage/utils.py @@ -5,7 +5,7 @@ from collective.lineage.events import ChildSiteWillBeRemovedEvent from collective.lineage.interfaces import IChildSite from five.localsitemanager import make_objectmanager_site -from Products.CMFPlone.interfaces import IPloneSiteRoot +from plone.base.interfaces import IPloneSiteRoot from Products.Five.component import disableSite from zope.component.hooks import getSite from zope.component.interfaces import ISite diff --git a/test_plone52.cfg b/test_plone52.cfg deleted file mode 100644 index fbde218..0000000 --- a/test_plone52.cfg +++ /dev/null @@ -1,10 +0,0 @@ -[buildout] - -extends = - https://raw.github.com/collective/buildout.plonetest/master/test-5.2.x.cfg - https://raw.githubusercontent.com/collective/buildout.plonetest/master/qa.cfg - base.cfg - -update-versions-file = test_plone52.cfg - -[versions] diff --git a/tox.ini b/tox.ini index bd13f47..c004078 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ # Generated from: -# https://github.com/plone/meta/tree/master/config/default +# https://github.com/plone/meta/tree/2.x/src/plone/meta/default # See the inline comments on how to expand/tweak this configuration file [tox] # We need 4.4.0 for constrain_package_deps. @@ -7,12 +7,23 @@ min_version = 4.4.0 envlist = lint test + py314-plone62 + py313-plone62 + py312-plone62 + py311-plone62 + py310-plone62 dependencies ## # Add extra configuration options in .meta.toml: +# - to specify a custom testing combination of Plone and python versions, use `test_matrix` +# Use ["*"] to use all supported Python versions for this Plone version. +# - to disable the test matrix entirely, set `use_test_matrix = false` +# - to specify extra custom environments, use `envlist_lines` +# - to specify extra `tox` top-level options, use `config_lines` # [tox] +# test_matrix = {"6.2" = ["3.13", "3.12"], "6.1" = ["*"]} # envlist_lines = """ # my_other_environment # """ @@ -21,32 +32,14 @@ envlist = # """ ## -[testenv] -skip_install = true -allowlist_externals = - echo - false -# Make sure typos like `tox -e formaat` are caught instead of silently doing nothing. -# See https://github.com/tox-dev/tox/issues/2858. -commands = - echo "Unrecognized environment name {envname}" - false - -## -# Add extra configuration options in .meta.toml: -# [tox] -# testenv_options = """ -# basepython = /usr/bin/python3.8 -# """ -## - [testenv:init] description = Prepare environment skip_install = true +allowlist_externals = + echo commands = echo "Initial setup complete" - [testenv:format] description = automatically reformat code skip_install = true @@ -71,9 +64,9 @@ description = check if the package defines all its dependencies skip_install = true deps = build - z3c.dependencychecker==2.11 + z3c.dependencychecker==3.0 commands = - python -m build --sdist + python -m build --wheel dependencychecker [testenv:dependencies-graph] @@ -87,8 +80,19 @@ deps = commands = sh -c 'pipdeptree --exclude setuptools,wheel,pipdeptree,zope.interface,zope.component --graph-output svg > dependencies.svg' -[testenv:test] -description = run the distribution tests + +[test_runner] +deps = zope.testrunner +test = + zope-testrunner --all --test-path={toxinidir}/src -s collective.lineage {posargs} +coverage = + coverage run --branch --source collective.lineage {envbindir}/zope-testrunner --quiet --all --test-path={toxinidir}/src -s collective.lineage {posargs} + coverage report -m --format markdown + coverage xml + coverage html + +[base] +description = shared configuration for tests and coverage use_develop = true skip_install = false constrain_package_deps = true @@ -104,61 +108,81 @@ set_env = # # Set constrain_package_deps .meta.toml: # [tox] -# constrain_package_deps = "false" +# constrain_package_deps = false ## deps = - zope.testrunner - -c https://dist.plone.org/release/6.0-dev/constraints.txt - + {[test_runner]deps} + plone62: -c https://dist.plone.org/release/6.2-dev/constraints.txt + ## # Specify additional deps in .meta.toml: # [tox] -# test_deps_additional = "-esources/plonegovbr.portal_base[test]" +# test_deps_additional = """ +# -esources/plonegovbr.portal_base[test] +# """ # # Specify a custom constraints file in .meta.toml: # [tox] # constraints_file = "https://my-server.com/constraints.txt" ## -commands = - zope-testrunner --all --test-path={toxinidir}/src -s collective.lineage {posargs} extras = test + ## # Add extra configuration options in .meta.toml: # [tox] +# skip_test_extra = true # test_extras = """ # tests # widgets # """ +# +# Add extra configuration options in .meta.toml: +# [tox] +# testenv_options = """ +# basepython = /usr/bin/python3.8 +# """ ## +[testenv:test] +description = run the distribution tests +use_develop = {[base]use_develop} +skip_install = {[base]skip_install} +constrain_package_deps = {[base]constrain_package_deps} +set_env = {[base]set_env} +deps = + {[test_runner]deps} + -c https://dist.plone.org/release/6.2-dev/constraints.txt + +commands = {[test_runner]test} +extras = {[base]extras} + + +[testenv] +description = run the distribution tests (generative environments) +use_develop = {[base]use_develop} +skip_install = {[base]skip_install} +constrain_package_deps = {[base]constrain_package_deps} +set_env = {[base]set_env} +deps = {[base]deps} +commands = {[test_runner]test} +extras = {[base]extras} + + [testenv:coverage] description = get a test coverage report -use_develop = true -skip_install = false -constrain_package_deps = true -set_env = - ROBOT_BROWSER=headlesschrome - -## -# Specify extra test environment variables in .meta.toml: -# [tox] -# test_environment_variables = """ -# PIP_EXTRA_INDEX_URL=https://my-pypi.my-server.com/ -# """ -## +use_develop = {[base]use_develop} +skip_install = {[base]skip_install} +constrain_package_deps = {[base]constrain_package_deps} +set_env = {[base]set_env} deps = + {[test_runner]deps} coverage - zope.testrunner - -c https://dist.plone.org/release/6.0-dev/constraints.txt - -commands = - coverage run --branch --source collective.lineage {envbindir}/zope-testrunner --quiet --all --test-path={toxinidir}/src -s collective.lineage {posargs} - coverage report -m --format markdown - coverage xml -extras = - test + -c https://dist.plone.org/release/6.2-dev/constraints.txt + +commands = {[test_runner]coverage} +extras = {[base]extras} [testenv:release-check] @@ -167,9 +191,13 @@ skip_install = true deps = twine build - -c https://dist.plone.org/release/6.0-dev/constraints.txt - + towncrier + -c https://dist.plone.org/release/6.2-dev/constraints.txt commands = + # fake version to not have to install the package + # we build the change log as news entries might break + # the README that is displayed on PyPI + towncrier build --version=100.0.0 --yes python -m build --sdist twine check dist/* @@ -177,6 +205,9 @@ commands = description = ensure there are no cyclic dependencies use_develop = true skip_install = false +# Here we must always constrain the package deps to what is already installed, +# otherwise we simply get the latest from PyPI, which may not work. +constrain_package_deps = true set_env = ## @@ -191,8 +222,7 @@ allowlist_externals = deps = pipdeptree pipforester - -c https://dist.plone.org/release/6.0-dev/constraints.txt - + -c https://dist.plone.org/release/6.2-dev/constraints.txt commands = # Generate the full dependency tree sh -c 'pipdeptree -j > forest.json' @@ -201,17 +231,6 @@ commands = # Report if there are any circular dependencies, i.e. error if there are any pipforester -i forest.json --check-cycles -o /dev/null -[testenv:plone52] -min_version = 3.28.0 -description = Plone 5.2 tests with buildout -skip_install = true -deps = - -rrequirements_plone52.txt -commands_pre = - {envbindir}/buildout -nc {toxinidir}/test_plone52.cfg buildout:directory={envdir} buildout:develop={toxinidir} -commands = - {envbindir}/code-analysis - {envbindir}/test {posargs} ## # Add extra configuration options in .meta.toml: