From 0970dce0ec2ac413ce73f796899da72e09a7b3cc Mon Sep 17 00:00:00 2001 From: Jonas Geuens Date: Tue, 3 Sep 2024 10:43:55 +0200 Subject: [PATCH 1/4] #306 Migratie pyproject + GH Actions Fixes #306 --- .github/pr-labeler.yml | 3 + .github/workflows/pr-labeler.yml | 22 ++++++ .github/workflows/pyoes.yml | 42 ++++++++++ .travis.yml | 14 ---- README.md | 28 +++++++ check_versions.sh | 2 +- pyproject.toml | 58 ++++++++++++++ requirements-ci.txt | 114 +++++++++++++++++++++++++++ requirements-dev.txt | 128 +++++++++++++++++++++++++++---- requirements.txt | 40 +++++++++- setup.py | 51 ------------ tox.ini | 18 ----- 12 files changed, 415 insertions(+), 105 deletions(-) create mode 100644 .github/pr-labeler.yml create mode 100644 .github/workflows/pr-labeler.yml create mode 100644 .github/workflows/pyoes.yml delete mode 100644 .travis.yml create mode 100644 README.md create mode 100644 pyproject.toml create mode 100644 requirements-ci.txt delete mode 100644 setup.py delete mode 100644 tox.ini diff --git a/.github/pr-labeler.yml b/.github/pr-labeler.yml new file mode 100644 index 00000000..b0f2235f --- /dev/null +++ b/.github/pr-labeler.yml @@ -0,0 +1,3 @@ +feature: ['feature/*', 'feat/*'] +fix: ['bugfix/*', 'fix/*'] +test: test/* \ No newline at end of file diff --git a/.github/workflows/pr-labeler.yml b/.github/workflows/pr-labeler.yml new file mode 100644 index 00000000..cd91bce3 --- /dev/null +++ b/.github/workflows/pr-labeler.yml @@ -0,0 +1,22 @@ +name: PR Labeler +on: + pull_request: + types: [opened] + branches: + - 'develop' + - 'epic' + +permissions: + contents: read + +jobs: + pr-labeler: + permissions: + contents: read # for TimonVS/pr-labeler-action to read config file + pull-requests: write # for TimonVS/pr-labeler-action to add labels in PR + runs-on: ubuntu-latest + steps: + - uses: TimonVS/pr-labeler-action@v4 + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + configuration-path: .github/pr-labeler.yml \ No newline at end of file diff --git a/.github/workflows/pyoes.yml b/.github/workflows/pyoes.yml new file mode 100644 index 00000000..801998c7 --- /dev/null +++ b/.github/workflows/pyoes.yml @@ -0,0 +1,42 @@ +name: pyoes + +on: [push, pull_request] + +env: + PYTHON_VERSION: "3.11" + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: ${{ env.PYTHON_VERSION }} + + - name: Set up Node.js + uses: actions/setup-node@v4 + with: + node-version: '16' + + - name: Install dependencies + env: + HATCH_BUILD_NO_HOOKS: true + run: | + pip install pip-tools + pip-sync requirements-ci.txt + pip install -e . + + - name: Run checks and tests + run: | + ./check_versions.sh + py.test --cov pyoes --cov-report term-missing + + - name: Upload coverage to Coveralls + run: coveralls + env: + COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }} \ No newline at end of file diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 026eccdb..00000000 --- a/.travis.yml +++ /dev/null @@ -1,14 +0,0 @@ -os: linux -dist: focal -language: python -python: - - "3.8" -env: - - LC_ALL=en_US.utf-8 -install: - - pip install -r requirements-dev.txt - - python setup.py develop -script: - - ./check_versions.sh - - py.test --cov pyoes --cov-report term-missing -after_success: coveralls diff --git a/README.md b/README.md new file mode 100644 index 00000000..883bb317 --- /dev/null +++ b/README.md @@ -0,0 +1,28 @@ +pyoes: Pyramid OE style +======================= + +.. image:: https://travis-ci.org/OnroerendErfgoed/pyoes.png + :target: https://travis-ci.org/OnroerendErfgoed/pyoes +.. image:: https://coveralls.io/repos/OnroerendErfgoed/pyoes/badge.png?branch=master + :target: https://coveralls.io/r/OnroerendErfgoed/pyoes + +.. image:: https://readthedocs.org/projects/pyoes/badge/?version=latest + :target: https://readthedocs.org/projects/pyoes/?badge=latest + :alt: Documentation Status +.. image:: https://badge.fury.io/py/pyoes.png + :target: http://badge.fury.io/py/pyoes + +Pyoes helps to share layout between different websites and applications of +Onroerend Erfgoed (Flanders Heritage). + +More information about this library can be found in the docs `folder`. These can +be build using `Sphinx `_. + +.. code-block:: bash + + # activate your virtual env + $ pip install -r requirements-dev.txt + $ cd docs + $ make html + # You can also build a pdf, provided you have the correct latex toolchain installed. + $ make latexpdf diff --git a/check_versions.sh b/check_versions.sh index fa75a764..77cb2984 100755 --- a/check_versions.sh +++ b/check_versions.sh @@ -1,6 +1,6 @@ #!/bin/bash -release_version=`grep version setup.py | cut -d\' -f2` +release_version=`grep 'version' pyproject.toml | grep -oE '[0-9]+\.[0-9]+\.[0-9]+'` versions=( `node -p -e "require('./npm-packages/pyoes/package.json').version"` `node -p -e "require('./pyoes/static/package.json').version"` diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 00000000..8727486d --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,58 @@ +[build-system] +requires = ["hatchling"] +build-backend = "hatchling.build" + +[project] +version = "0.22.0" +name = "pyoes" +readme = "README.md" +authors = [ + { name = "Flanders Heritage Agency", email = "ict@onroerenderfgoed.be" }, +] +description = "pyoes" +requires-python = ">=3.10,<3.12" +keywords = ["pyramid", "sass", "compass", "style", "css", "jinja2", "templates"] +classifiers = [ + "Programming Language :: Python", + "Framework :: Pyramid", +] +dependencies = [ + "Jinja2==3.1.4", + "MarkupSafe==2.1.3", + "python-dateutil==2.8.2", + "pyramid==2.0.2", + "pyramid-jinja2==2.10" +] + +[project.optional-dependencies] + +dev = [ + "coveralls==3.3.1", + "oe-sphinx-theme==0.4.0", + "pep8==1.7.1", + "pytest==7.4.3", + "pytest-cov==4.1.0", + "Sphinx==7.1.2", + "sphinxcontrib-httpdomain==1.8.1", + "sphinx-rtd-theme==2.0.0", + "sphinxcontrib-plantuml==0.27", + "waitress==2.1.2" +] + +[tool.hatch.build.targets.wheel] +# In the wheel we want to have toelatingen_archeologie in the root as a python module. +packages = [ + "/pyoes", +] + +[project.entry-points."paste.app_factory"] +main = "pyoes:main" + +[project.entry-points."pyramid.scaffold"] +pyoes = "pyoes.scaffolds:PyoesTemplate" +pyoesAdmin = "pyoes.scaffolds:PyoesAdminTemplate" +pyoesProces = "pyoes.scaffolds:PyoesProcesTemplate" + +[tool.hatch.metadata] +# This allows us to use github links as dependencies +allow-direct-references = true \ No newline at end of file diff --git a/requirements-ci.txt b/requirements-ci.txt new file mode 100644 index 00000000..b5a8d0ec --- /dev/null +++ b/requirements-ci.txt @@ -0,0 +1,114 @@ +alabaster==0.7.16 + # via sphinx +babel==2.16.0 + # via sphinx +certifi==2024.8.30 + # via requests +charset-normalizer==3.3.2 + # via requests +coverage==6.5.0 + # via + # coveralls + # pytest-cov +coveralls==3.3.1 +docopt==0.6.2 + # via coveralls +docutils==0.20.1 + # via + # sphinx + # sphinx-rtd-theme +hupper==1.12.1 + # via pyramid +idna==3.8 + # via requests +imagesize==1.4.1 + # via sphinx +iniconfig==2.0.0 + # via pytest +jinja2==3.1.4 + # via + # pyramid-jinja2 + # sphinx +markupsafe==2.1.3 + # via + # jinja2 + # pyramid-jinja2 +oe-sphinx-theme==0.4.0 +packaging==24.1 + # via + # pytest + # sphinx +pastedeploy==3.1.0 + # via plaster-pastedeploy +pep8==1.7.1 +plaster==1.1.2 + # via + # plaster-pastedeploy + # pyramid +plaster-pastedeploy==1.0.1 + # via pyramid +pluggy==1.5.0 + # via pytest +pygments==2.18.0 + # via sphinx +pyramid==2.0.2 + # via pyramid-jinja2 +pyramid-jinja2==2.10 +pytest==7.4.3 + # via pytest-cov +pytest-cov==4.1.0 +python-dateutil==2.8.2 +requests==2.32.3 + # via + # coveralls + # sphinx +setuptools==74.1.0 + # via + # pyramid + # zope-deprecation + # zope-interface +six==1.16.0 + # via + # python-dateutil + # sphinxcontrib-httpdomain +snowballstemmer==2.2.0 + # via sphinx +sphinx==7.1.2 + # via + # oe-sphinx-theme + # sphinx-rtd-theme + # sphinxcontrib-httpdomain + # sphinxcontrib-jquery + # sphinxcontrib-plantuml +sphinx-rtd-theme==2.0.0 +sphinxcontrib-applehelp==2.0.0 + # via sphinx +sphinxcontrib-devhelp==2.0.0 + # via sphinx +sphinxcontrib-htmlhelp==2.1.0 + # via sphinx +sphinxcontrib-httpdomain==1.8.1 +sphinxcontrib-jquery==4.1 + # via sphinx-rtd-theme +sphinxcontrib-jsmath==1.0.1 + # via sphinx +sphinxcontrib-plantuml==0.27 +sphinxcontrib-qthelp==2.0.0 + # via sphinx +sphinxcontrib-serializinghtml==2.0.0 + # via sphinx +translationstring==1.4 + # via pyramid +urllib3==2.2.2 + # via requests +venusian==3.1.0 + # via pyramid +waitress==2.1.2 +webob==1.8.8 + # via pyramid +zope-deprecation==5.0 + # via + # pyramid + # pyramid-jinja2 +zope-interface==7.0.3 + # via pyramid diff --git a/requirements-dev.txt b/requirements-dev.txt index 2d72b4c6..b5a8d0ec 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -1,20 +1,114 @@ -# Runtime requirements ---requirement requirements.txt - -# Development server -waitress==2.1.2 - -# Sphinx -Sphinx==7.1.2 -sphinxcontrib-httpdomain==1.8.1 -sphinx-rtd-theme==2.0.0 -sphinxcontrib-plantuml==0.27 +alabaster==0.7.16 + # via sphinx +babel==2.16.0 + # via sphinx +certifi==2024.8.30 + # via requests +charset-normalizer==3.3.2 + # via requests +coverage==6.5.0 + # via + # coveralls + # pytest-cov +coveralls==3.3.1 +docopt==0.6.2 + # via coveralls +docutils==0.20.1 + # via + # sphinx + # sphinx-rtd-theme +hupper==1.12.1 + # via pyramid +idna==3.8 + # via requests +imagesize==1.4.1 + # via sphinx +iniconfig==2.0.0 + # via pytest +jinja2==3.1.4 + # via + # pyramid-jinja2 + # sphinx +markupsafe==2.1.3 + # via + # jinja2 + # pyramid-jinja2 oe-sphinx-theme==0.4.0 - -# Testing +packaging==24.1 + # via + # pytest + # sphinx +pastedeploy==3.1.0 + # via plaster-pastedeploy +pep8==1.7.1 +plaster==1.1.2 + # via + # plaster-pastedeploy + # pyramid +plaster-pastedeploy==1.0.1 + # via pyramid +pluggy==1.5.0 + # via pytest +pygments==2.18.0 + # via sphinx +pyramid==2.0.2 + # via pyramid-jinja2 +pyramid-jinja2==2.10 pytest==7.4.3 + # via pytest-cov pytest-cov==4.1.0 -coveralls==3.3.1 - -# Linting -pep8==1.7.1 +python-dateutil==2.8.2 +requests==2.32.3 + # via + # coveralls + # sphinx +setuptools==74.1.0 + # via + # pyramid + # zope-deprecation + # zope-interface +six==1.16.0 + # via + # python-dateutil + # sphinxcontrib-httpdomain +snowballstemmer==2.2.0 + # via sphinx +sphinx==7.1.2 + # via + # oe-sphinx-theme + # sphinx-rtd-theme + # sphinxcontrib-httpdomain + # sphinxcontrib-jquery + # sphinxcontrib-plantuml +sphinx-rtd-theme==2.0.0 +sphinxcontrib-applehelp==2.0.0 + # via sphinx +sphinxcontrib-devhelp==2.0.0 + # via sphinx +sphinxcontrib-htmlhelp==2.1.0 + # via sphinx +sphinxcontrib-httpdomain==1.8.1 +sphinxcontrib-jquery==4.1 + # via sphinx-rtd-theme +sphinxcontrib-jsmath==1.0.1 + # via sphinx +sphinxcontrib-plantuml==0.27 +sphinxcontrib-qthelp==2.0.0 + # via sphinx +sphinxcontrib-serializinghtml==2.0.0 + # via sphinx +translationstring==1.4 + # via pyramid +urllib3==2.2.2 + # via requests +venusian==3.1.0 + # via pyramid +waitress==2.1.2 +webob==1.8.8 + # via pyramid +zope-deprecation==5.0 + # via + # pyramid + # pyramid-jinja2 +zope-interface==7.0.3 + # via pyramid diff --git a/requirements.txt b/requirements.txt index 4a05cd59..256713d3 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,7 +1,39 @@ -# pyramid +hupper==1.12.1 + # via pyramid +jinja2==3.1.4 + # via pyramid-jinja2 +markupsafe==2.1.3 + # via + # jinja2 + # pyramid-jinja2 +pastedeploy==3.1.0 + # via plaster-pastedeploy +plaster==1.1.2 + # via + # plaster-pastedeploy + # pyramid +plaster-pastedeploy==1.0.1 + # via pyramid pyramid==2.0.2 + # via pyramid-jinja2 pyramid-jinja2==2.10 -MarkupSafe==2.1.3 -Jinja2==3.1.4 - python-dateutil==2.8.2 +setuptools==74.1.0 + # via + # pyramid + # zope-deprecation + # zope-interface +six==1.16.0 + # via python-dateutil +translationstring==1.4 + # via pyramid +venusian==3.1.0 + # via pyramid +webob==1.8.8 + # via pyramid +zope-deprecation==5.0 + # via + # pyramid + # pyramid-jinja2 +zope-interface==7.0.3 + # via pyramid diff --git a/setup.py b/setup.py deleted file mode 100644 index e01a2868..00000000 --- a/setup.py +++ /dev/null @@ -1,51 +0,0 @@ -# -*- coding: utf-8 -*- - -import os - -from setuptools import setup - -here = os.path.abspath(os.path.dirname(__file__)) -README = open(os.path.join(here, 'README.rst')).read() -CHANGES = open(os.path.join(here, 'CHANGES.rst')).read() - -requires = [ - 'pyramid', - 'pyramid_jinja2', - 'python-dateutil', - ] - -setup(name='pyoes', - version='0.22.0', - description='Algemene onroerenderfgoed stijl (gebaseerd op de Vlaamse huisstijl) voor pyramid', - long_description=README + '\n\n' + CHANGES, - classifiers=[ - "Programming Language :: Python", - "Programming Language :: Python :: 3.8", - "Programming Language :: JavaScript", - "Development Status :: 3 - Alpha", - "Environment :: Web Environment", - "Intended Audience :: Developers", - "Framework :: Pyramid", - "Topic :: Internet :: WWW/HTTP", - "Topic :: Internet :: WWW/HTTP :: WSGI :: Application", - "Topic :: Text Processing :: Markup :: HTML" - ], - author='Koen Van Daele', - author_email='koen.vandaele@vlaanderen.be', - url='https://pyoes.readthedocs.org/en/latest/', - keywords='pyramid oe onroerend erfgoed sass compass style css jinja2 templates', - packages=['pyoes'], - include_package_data=True, - zip_safe=False, - install_requires=requires, - tests_require=requires, - test_suite="pyoes", - entry_points="""\ - [paste.app_factory] - main = pyoes:main - [pyramid.scaffold] - pyoes=pyoes.scaffolds:PyoesTemplate - pyoesAdmin=pyoes.scaffolds:PyoesAdminTemplate - pyoesProces=pyoes.scaffolds:PyoesProcesTemplate - """, - ) diff --git a/tox.ini b/tox.ini deleted file mode 100644 index 6b6a320e..00000000 --- a/tox.ini +++ /dev/null @@ -1,18 +0,0 @@ -[tox] -envlist = py27, py33, py34, cover - -[testenv] -commands = - pip install -r requirements-dev.txt - python setup.py develop - py.test -setenv = - LC_ALL = en_US.utf-8 - -[testenv:cover] -basepython = - python2.7 -commands = - pip install -r requirements-dev.txt - python setup.py develop - py.test --cov pyoes --cov-report term-missing From af0262f9698d41baff5476af29bf1b197fd72567 Mon Sep 17 00:00:00 2001 From: Jonas Geuens Date: Tue, 10 Sep 2024 13:03:37 +0200 Subject: [PATCH 2/4] pre-commit en flake8 --- .flake8 | 17 +++ .github/workflows/pyoes.yml | 4 + .pre-commit-config.yaml | 25 +++++ pyoes/__init__.py | 100 ++++++++--------- pyoes/scaffolds/__init__.py | 21 ++-- pyoes/scripts/__init__.py | 2 +- pyoes/static_views.py | 31 +++--- pyoes/utils.py | 28 ++--- pyoes/views.py | 214 +++++++++++++++++++++--------------- tests/test_static_views.py | 9 +- tests/test_utils.py | 114 ++++++++++--------- tests/test_varia.py | 5 +- 12 files changed, 335 insertions(+), 235 deletions(-) create mode 100644 .flake8 create mode 100644 .pre-commit-config.yaml diff --git a/.flake8 b/.flake8 new file mode 100644 index 00000000..aaf93462 --- /dev/null +++ b/.flake8 @@ -0,0 +1,17 @@ +[flake8] +application_import_names = pyoes, tests +exclude = + .venv, + venv, + __pycache__, + npm-packages, + node_modules, + static, + docs, + alembic, + dist, +import-order-style = pycharm +max-line-length = 90 +extend-select = B950 +ignore = W503, E203, E402, E266, E203, E501, E701 +per-file-ignores = diff --git a/.github/workflows/pyoes.yml b/.github/workflows/pyoes.yml index 801998c7..c103c322 100644 --- a/.github/workflows/pyoes.yml +++ b/.github/workflows/pyoes.yml @@ -27,13 +27,17 @@ jobs: env: HATCH_BUILD_NO_HOOKS: true run: | + python3 -m venv venv + source venv/bin/activate pip install pip-tools pip-sync requirements-ci.txt pip install -e . - name: Run checks and tests + working-directory: ./ run: | ./check_versions.sh + source venv/bin/activate py.test --cov pyoes --cov-report term-missing - name: Upload coverage to Coveralls diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 00000000..f08a0e21 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,25 @@ +repos: +- repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.5.0 + hooks: + - id: check-yaml + - id: end-of-file-fixer + types: [python] + - id: trailing-whitespace + types: [python] +- repo: https://github.com/psf/black + rev: 24.3.0 + hooks: + - id: black + types: [python] + args: [--preview] + exclude: docs, tests +- repo: https://github.com/PyCQA/flake8 + rev: 7.0.0 + hooks: + - id: flake8 + additional_dependencies: + - flake8-import-order==0.18.2 + - flake8-bugbear==24.2.6 + types: [python] + exclude: docs diff --git a/pyoes/__init__.py b/pyoes/__init__.py index fd75a869..51d54d75 100644 --- a/pyoes/__init__.py +++ b/pyoes/__init__.py @@ -3,70 +3,70 @@ from pyramid.config import Configurator -def main(global_config, **settings): # pragma: no cover +def main(global_config, **settings): # pragma: no cover """ Returns a pyramid application that can help demo the style. """ config = Configurator(settings=settings) - config.add_static_view('static', 'static', cache_max_age=3600) - config.add_route('home', '/') - config.add_route('burgerprofiel', '/burgerprofiel') - config.add_route('burgerprofiel2', '/burgerprofiel2') - config.add_route('headerlinks', '/headerlinks') - config.add_route('grids', '/grids') - config.add_route('beeldbank', '/beeldbank') - config.add_route('beheersplannen', '/beheersplannen') - config.add_route('beheersplannenres', '/beheersplannen/result') - config.add_route('actorenfront', '/actorenfront') - config.add_route('detail-bedrijf', '/actorenfront/detail-bedrijf') - config.add_route('detail-bedrijfv2', '/actorenfront/detail-bedrijfv2') - config.add_route('detail', '/actorenfront/detail') - config.add_route('actorenzoek', '/actorenzoek') - config.add_route('actorenzoekdetail', '/actorenzoek/detail') - config.add_route('beeldbank-detail', '/beeldbank-detail') - config.add_route('beeldbank-zoeken', '/beeldbank-zoeken') - config.add_route('besluitendatabank', '/besluitendatabank') - config.add_route('inventaris', '/inventaris') - config.add_route('inventaris-article', '/inventaris-article') - config.add_route('inventaris-articleID', '/inventaris-articleID') - config.add_route('inventaris-articleIDv2', '/inventaris-articleIDv2') - config.add_route('inventaris-articleIDfull', '/inventaris-articleIDfull') - config.add_route('inventaris-articleIDfullv2', '/inventaris-articleIDfullv2') - config.add_route('inventaris-articleIDfullv3', '/inventaris-articleIDfullv3') - config.add_route('inventaris-zoekoverzicht', '/inventaris-zoekoverzicht') - config.add_route('postregistratie', '/postregistratie') - config.add_route('postreg-aanmaken', '/postregistratie/aanmaken') - config.add_route('icons', '/icons') - config.add_route('blokken', '/blokken') - config.add_route('typo', '/typo') - config.add_route('navigation', '/navigation') - config.add_route('colors', '/colors') - config.add_route('elements', '/elements') - config.add_route('images', '/images') - config.add_route('article', '/article') - config.add_route('article9-3', '/article9-3') - config.add_route('geoportaal', '/geoportaal') - config.add_route('pinpoints', '/pinpoints') - config.add_route('401', '/401') - config.add_route('403', '/403') - config.add_route('404', '/404') - config.add_route('500', '/500') - config.add_route('atramhasismenu', '/atramhasismenu') + config.add_static_view("static", "static", cache_max_age=3600) + config.add_route("home", "/") + config.add_route("burgerprofiel", "/burgerprofiel") + config.add_route("burgerprofiel2", "/burgerprofiel2") + config.add_route("headerlinks", "/headerlinks") + config.add_route("grids", "/grids") + config.add_route("beeldbank", "/beeldbank") + config.add_route("beheersplannen", "/beheersplannen") + config.add_route("beheersplannenres", "/beheersplannen/result") + config.add_route("actorenfront", "/actorenfront") + config.add_route("detail-bedrijf", "/actorenfront/detail-bedrijf") + config.add_route("detail-bedrijfv2", "/actorenfront/detail-bedrijfv2") + config.add_route("detail", "/actorenfront/detail") + config.add_route("actorenzoek", "/actorenzoek") + config.add_route("actorenzoekdetail", "/actorenzoek/detail") + config.add_route("beeldbank-detail", "/beeldbank-detail") + config.add_route("beeldbank-zoeken", "/beeldbank-zoeken") + config.add_route("besluitendatabank", "/besluitendatabank") + config.add_route("inventaris", "/inventaris") + config.add_route("inventaris-article", "/inventaris-article") + config.add_route("inventaris-articleID", "/inventaris-articleID") + config.add_route("inventaris-articleIDv2", "/inventaris-articleIDv2") + config.add_route("inventaris-articleIDfull", "/inventaris-articleIDfull") + config.add_route("inventaris-articleIDfullv2", "/inventaris-articleIDfullv2") + config.add_route("inventaris-articleIDfullv3", "/inventaris-articleIDfullv3") + config.add_route("inventaris-zoekoverzicht", "/inventaris-zoekoverzicht") + config.add_route("postregistratie", "/postregistratie") + config.add_route("postreg-aanmaken", "/postregistratie/aanmaken") + config.add_route("icons", "/icons") + config.add_route("blokken", "/blokken") + config.add_route("typo", "/typo") + config.add_route("navigation", "/navigation") + config.add_route("colors", "/colors") + config.add_route("elements", "/elements") + config.add_route("images", "/images") + config.add_route("article", "/article") + config.add_route("article9-3", "/article9-3") + config.add_route("geoportaal", "/geoportaal") + config.add_route("pinpoints", "/pinpoints") + config.add_route("401", "/401") + config.add_route("403", "/403") + config.add_route("404", "/404") + config.add_route("500", "/500") + config.add_route("atramhasismenu", "/atramhasismenu") includeme(config) - config.scan('pyoes.views') + config.scan("pyoes.views") return config.make_wsgi_app() def includeme(config): - ''' + """ Include pyoes in a pyramid application. :param pyramid.config.Configurator config: - ''' + """ - config.add_static_view('pyoes_static', 'pyoes:static') - config.scan('pyoes.static_views') + config.add_static_view("pyoes_static", "pyoes:static") + config.scan("pyoes.static_views") return config diff --git a/pyoes/scaffolds/__init__.py b/pyoes/scaffolds/__init__.py index 6d7b64cd..fdbc9ed2 100644 --- a/pyoes/scaffolds/__init__.py +++ b/pyoes/scaffolds/__init__.py @@ -1,18 +1,21 @@ from pyramid.scaffolds import PyramidTemplate + class PyoesTemplate(PyramidTemplate): - _template_dir = 'pyoes_scaffold' - summary = 'Een scaffold om een pyramid project uit te breiden met OE stijl\ - bestanden op basis van sass en compass.' + _template_dir = "pyoes_scaffold" + summary = "Een scaffold om een pyramid project uit te breiden met OE stijl\ + bestanden op basis van sass en compass." class PyoesAdminTemplate(PyramidTemplate): - _template_dir = 'pyoes_admin_scaffold' - summary = 'Een scaffold om een de admin interface van een pyramid project uit te breiden met OE stijl\ - bestanden op basis van sass en compass.' + _template_dir = "pyoes_admin_scaffold" + summary = "Een scaffold om een de admin interface van een\ + pyramid project uit te breiden met OE stijl\ + bestanden op basis van sass en compass." class PyoesProcesTemplate(PyramidTemplate): - _template_dir = 'pyoes_proces_scaffold' - summary = 'Een scaffold om een de proces interface van een pyramid project uit te breiden met OE stijl\ - bestanden op basis van sass en compass.' \ No newline at end of file + _template_dir = "pyoes_proces_scaffold" + summary = "Een scaffold om een de proces interface van een pyramid\ + project uit te breiden met OE stijl\ + bestanden op basis van sass en compass." diff --git a/pyoes/scripts/__init__.py b/pyoes/scripts/__init__.py index d3173e63..5bb534f7 100644 --- a/pyoes/scripts/__init__.py +++ b/pyoes/scripts/__init__.py @@ -1 +1 @@ -#package +# package diff --git a/pyoes/static_views.py b/pyoes/static_views.py index 860228bc..32fe4f8f 100644 --- a/pyoes/static_views.py +++ b/pyoes/static_views.py @@ -1,33 +1,30 @@ -from pyramid.view import ( - view_config -) - import os -from pyramid.response import ( - FileResponse -) +from pyramid.response import FileResponse +from pyramid.view import view_config + class StaticView(object): - ''' + """ Views voor aan de root gebonden static files. - ''' + """ + def __init__(self, request): self.request = request self.here = os.path.dirname(__file__) - @view_config(name='favicon.ico') + @view_config(name="favicon.ico") def faviconico(self): - ''' + """ View om een statische favicon.ico te kunnen serveren - ''' - icon = os.path.join(self.here, 'static', 'favicon.ico') + """ + icon = os.path.join(self.here, "static", "favicon.ico") return FileResponse(icon, request=self.request) - @view_config(name='robots.txt') + @view_config(name="robots.txt") def robotstxt(self): - ''' + """ View om een statische robots.txt te kunnen serveren - ''' - icon = os.path.join(self.here, 'static', 'robots.txt') + """ + icon = os.path.join(self.here, "static", "robots.txt") return FileResponse(icon, request=self.request) diff --git a/pyoes/utils.py b/pyoes/utils.py index f44121e5..966f5637 100644 --- a/pyoes/utils.py +++ b/pyoes/utils.py @@ -15,7 +15,7 @@ def set_attr_filter(target, key, value): return target -def datetime_format_filter(value, format='%d-%m-%Y %H:%M'): +def datetime_format_filter(value, format="%d-%m-%Y %H:%M"): """ Jinja 2 filter to print a datetime object in a template. @@ -30,16 +30,16 @@ def datetime_format_filter(value, format='%d-%m-%Y %H:%M'): try: return value.strftime(format) except AttributeError: - if value[0:4].find('-') == -1 and value[0:4].find('/') == -1: + if value[0:4].find("-") == -1 and value[0:4].find("/") == -1: date = parser.parse(value, yearfirst=True, dayfirst=False) else: date = parser.parse(value, dayfirst=True) return date.strftime(format) else: - return '' + return "" -def fuzzy_date_format_filter(value, format='%d-%m-%Y'): +def fuzzy_date_format_filter(value, format="%d-%m-%Y"): """ Jinja 2 filter to print a fuzzy date object in a template. @@ -54,16 +54,16 @@ def fuzzy_date_format_filter(value, format='%d-%m-%Y'): try: return _fuzzy_date_formatter(value, format) except AttributeError: - if value[0:4].find('-') == -1 and value[0:4].find('/') == -1: + if value[0:4].find("-") == -1 and value[0:4].find("/") == -1: date = parser.parse(value, yearfirst=True, dayfirst=False) else: date = parser.parse(value, dayfirst=True) return _fuzzy_date_formatter(date, format) else: - return '' + return "" -def _fuzzy_date_formatter(date, format='%d-%m-%Y'): +def _fuzzy_date_formatter(date, format="%d-%m-%Y"): """ Dateconverter to convert date or datetime objects to strings in a specific format @@ -73,12 +73,12 @@ def _fuzzy_date_formatter(date, format='%d-%m-%Y'): '%d-%m-%Y' or '%m-%Y' or '%Y' :return: The formatted date, eg. `07-09-2014` """ - if format == '%d-%m-%Y': - return '{0.day:02d}-{0.month:02d}-{0.year:4d}'.format(date) - elif format == '%m-%Y': - return '{0.month:02d}-{0.year:4d}'.format(date) - elif format == '%Y': - return '{0.year:4d}'.format(date) + if format == "%d-%m-%Y": + return "{0.day:02d}-{0.month:02d}-{0.year:4d}".format(date) + elif format == "%m-%Y": + return "{0.month:02d}-{0.year:4d}".format(date) + elif format == "%Y": + return "{0.year:4d}".format(date) else: # Default - return '{0.day:02d}-{0.month:02d}-{0.year:4d}'.format(date) + return "{0.day:02d}-{0.month:02d}-{0.year:4d}".format(date) diff --git a/pyoes/views.py b/pyoes/views.py index ca685c42..6aac9084 100644 --- a/pyoes/views.py +++ b/pyoes/views.py @@ -1,216 +1,258 @@ from pyramid.view import view_config -@view_config(route_name='home', renderer='templates/index.jinja2') +@view_config(route_name="home", renderer="templates/index.jinja2") def home(request): - return {} + return {} -@view_config(route_name='burgerprofiel', renderer='templates/burgerprofiel.jinja2') +@view_config(route_name="burgerprofiel", renderer="templates/burgerprofiel.jinja2") def header_footer(request): - return {} + return {} -@view_config(route_name='burgerprofiel2', renderer='templates/burgerprofiel2.jinja2') +@view_config(route_name="burgerprofiel2", renderer="templates/burgerprofiel2.jinja2") def header_footer2(request): - return {} + return {} -@view_config(route_name='headerlinks', renderer='templates/headerlinks.jinja2') +@view_config(route_name="headerlinks", renderer="templates/headerlinks.jinja2") def headerlinks(request): - return {} + return {} -@view_config(route_name='grids', renderer='templates/grids.jinja2') +@view_config(route_name="grids", renderer="templates/grids.jinja2") def grids(request): - return {} + return {} -@view_config(route_name='beeldbank', renderer='templates/beeldbank/beeldbank.jinja2') +@view_config(route_name="beeldbank", renderer="templates/beeldbank/beeldbank.jinja2") def beeldbank(request): - return {} + return {} -@view_config(route_name='besluitendatabank', renderer='templates/besluitendatabank.jinja2') +@view_config( + route_name="besluitendatabank", renderer="templates/besluitendatabank.jinja2" +) def besluitendatabank(request): - return {} + return {} -@view_config(route_name='beheersplannen', renderer='templates/beheersplannen.jinja2') +@view_config(route_name="beheersplannen", renderer="templates/beheersplannen.jinja2") def beheersplannen(request): - return {} + return {} -@view_config(route_name='beheersplannenres', renderer='templates/beheersplannen/result.jinja2') +@view_config( + route_name="beheersplannenres", renderer="templates/beheersplannen/result.jinja2" +) def beheersplannenres(request): - return {} + return {} -@view_config(route_name='actorenfront', renderer='templates/actorenfront.jinja2') +@view_config(route_name="actorenfront", renderer="templates/actorenfront.jinja2") def actorenfront(request): - return {} + return {} -@view_config(route_name='detail-bedrijf', renderer='templates/actorenfront/detail-bedrijf.jinja2') +@view_config( + route_name="detail-bedrijf", renderer="templates/actorenfront/detail-bedrijf.jinja2" +) def actorenfrontdetailbedrijf(request): - return {} + return {} -@view_config(route_name='detail-bedrijfv2', renderer='templates/actorenfront/detail-bedrijfv2.jinja2') +@view_config( + route_name="detail-bedrijfv2", + renderer="templates/actorenfront/detail-bedrijfv2.jinja2", +) def actorenfrontdetailbedrijfv2(request): - return {} + return {} -@view_config(route_name='detail', renderer='templates/actorenfront/detail.jinja2') +@view_config(route_name="detail", renderer="templates/actorenfront/detail.jinja2") def actorenfrontdetail(request): - return {} + return {} -@view_config(route_name='actorenzoek', renderer='templates/actorenzoek.jinja2') +@view_config(route_name="actorenzoek", renderer="templates/actorenzoek.jinja2") def actorenzoek(request): - return {} + return {} -@view_config(route_name='actorenzoekdetail', renderer='templates/actorenzoek/detail.jinja2') +@view_config( + route_name="actorenzoekdetail", renderer="templates/actorenzoek/detail.jinja2" +) def actorenzoekdetail(request): - return {} + return {} -@view_config(route_name='beeldbank-detail', renderer='templates/beeldbank/beeldbank-detail.jinja2') +@view_config( + route_name="beeldbank-detail", + renderer="templates/beeldbank/beeldbank-detail.jinja2", +) def beeldbank_detail(request): - return {} + return {} -@view_config(route_name='beeldbank-zoeken', renderer='templates/beeldbank/beeldbank-uitgebreid-zoeken.jinja2') +@view_config( + route_name="beeldbank-zoeken", + renderer="templates/beeldbank/beeldbank-uitgebreid-zoeken.jinja2", +) def beeldbank_zoeken(request): - return {} + return {} -@view_config(route_name='inventaris', renderer='templates/inventaris/inventaris.jinja2') +@view_config(route_name="inventaris", renderer="templates/inventaris/inventaris.jinja2") def inventaris(request): - return {} + return {} -@view_config(route_name='inventaris-article', renderer='templates/inventaris/inventaris-article.jinja2') +@view_config( + route_name="inventaris-article", + renderer="templates/inventaris/inventaris-article.jinja2", +) def inventaris_article(request): - return {} + return {} -@view_config(route_name='inventaris-articleID', renderer='templates/inventaris/inventaris-articleID.jinja2') +@view_config( + route_name="inventaris-articleID", + renderer="templates/inventaris/inventaris-articleID.jinja2", +) def inventaris_articleID(request): - return {} + return {} -@view_config(route_name='inventaris-articleIDv2', renderer='templates/inventaris/inventaris-articleIDv2.jinja2') +@view_config( + route_name="inventaris-articleIDv2", + renderer="templates/inventaris/inventaris-articleIDv2.jinja2", +) def inventaris_articleIDv2(request): - return {} + return {} -@view_config(route_name='inventaris-articleIDfull', renderer='templates/inventaris/inventaris-articleIDfull.jinja2') +@view_config( + route_name="inventaris-articleIDfull", + renderer="templates/inventaris/inventaris-articleIDfull.jinja2", +) def inventaris_articleIDfull(request): - return {} + return {} -@view_config(route_name='inventaris-articleIDfullv2', renderer='templates/inventaris/inventaris-articleIDfullv2.jinja2') +@view_config( + route_name="inventaris-articleIDfullv2", + renderer="templates/inventaris/inventaris-articleIDfullv2.jinja2", +) def inventaris_articleIDfullv2(request): - return {} + return {} -@view_config(route_name='inventaris-articleIDfullv3', renderer='templates/inventaris/inventaris-articleIDfullv3.jinja2') +@view_config( + route_name="inventaris-articleIDfullv3", + renderer="templates/inventaris/inventaris-articleIDfullv3.jinja2", +) def inventaris_articleIDfullv3(request): - return {} + return {} -@view_config(route_name='inventaris-zoekoverzicht', renderer='templates/inventaris/inventaris-zoekoverzicht.jinja2') +@view_config( + route_name="inventaris-zoekoverzicht", + renderer="templates/inventaris/inventaris-zoekoverzicht.jinja2", +) def inventaris_zoekoverzicht(request): - return {} + return {} -@view_config(route_name='postregistratie', renderer='templates/postregistratie/index.jinja2') +@view_config( + route_name="postregistratie", renderer="templates/postregistratie/index.jinja2" +) def postregistratie(request): - return {} + return {} -@view_config(route_name='postreg-aanmaken', renderer='templates/postregistratie/aanmaken.jinja2') +@view_config( + route_name="postreg-aanmaken", renderer="templates/postregistratie/aanmaken.jinja2" +) def postreg_aanmaken(request): - return {} + return {} -@view_config(route_name='icons', renderer='templates/icons.jinja2') +@view_config(route_name="icons", renderer="templates/icons.jinja2") def icons(request): - return {} + return {} -@view_config(route_name='blokken', renderer='templates/blokken.jinja2') +@view_config(route_name="blokken", renderer="templates/blokken.jinja2") def blokken(request): - return {} + return {} -@view_config(route_name='typo', renderer='templates/typo.jinja2') +@view_config(route_name="typo", renderer="templates/typo.jinja2") def typo(request): - return {} + return {} -@view_config(route_name='navigation', renderer='templates/navigation.jinja2') +@view_config(route_name="navigation", renderer="templates/navigation.jinja2") def navigation(request): - return {} + return {} -@view_config(route_name='colors', renderer='templates/colors.jinja2') +@view_config(route_name="colors", renderer="templates/colors.jinja2") def colors(request): - return {} + return {} -@view_config(route_name='elements', renderer='templates/elements.jinja2') +@view_config(route_name="elements", renderer="templates/elements.jinja2") def elements(request): - return {} + return {} -@view_config(route_name='images', renderer='templates/images.jinja2') +@view_config(route_name="images", renderer="templates/images.jinja2") def images(request): - return {} + return {} -@view_config(route_name='article', renderer='templates/article.jinja2') +@view_config(route_name="article", renderer="templates/article.jinja2") def article(request): - return {} + return {} -@view_config(route_name='article9-3', renderer='templates/article9-3.jinja2') +@view_config(route_name="article9-3", renderer="templates/article9-3.jinja2") def article93(request): - return {} + return {} -@view_config(route_name='geoportaal', renderer='templates/geoportaal/geoportaal.jinja2') +@view_config(route_name="geoportaal", renderer="templates/geoportaal/geoportaal.jinja2") def geoportaal(request): - return {} + return {} -@view_config(route_name='pinpoints', renderer='templates/pinpoints.jinja2') +@view_config(route_name="pinpoints", renderer="templates/pinpoints.jinja2") def pinpoints(request): - return {} + return {} -@view_config(route_name='401', renderer='templates/401.jinja2') +@view_config(route_name="401", renderer="templates/401.jinja2") def viernuleen(request): - return {} + return {} -@view_config(route_name='403', renderer='templates/403.jinja2') +@view_config(route_name="403", renderer="templates/403.jinja2") def viernuldrie(request): - return {} + return {} -@view_config(route_name='404', renderer='templates/404.jinja2') +@view_config(route_name="404", renderer="templates/404.jinja2") def viernulvier(request): - return {} + return {} -@view_config(route_name='500', renderer='templates/500.jinja2') +@view_config(route_name="500", renderer="templates/500.jinja2") def vijfhonderd(request): - return {} + return {} -@view_config(route_name='atramhasismenu', renderer='templates/atramhasis_menu.jinja2') +@view_config(route_name="atramhasismenu", renderer="templates/atramhasis_menu.jinja2") def atramhasismenu(request): - return {} + return {} diff --git a/tests/test_static_views.py b/tests/test_static_views.py index 2e11b4d8..442c2e00 100644 --- a/tests/test_static_views.py +++ b/tests/test_static_views.py @@ -1,15 +1,14 @@ import unittest from pyramid import testing +from pyramid.response import FileResponse -from pyramid.response import ( - FileResponse -) class StaticViewTests(unittest.TestCase): def _get_static_view(self, request): from pyoes.static_views import StaticView + return StaticView(request) def test_robotstxt(self): @@ -17,11 +16,11 @@ def test_robotstxt(self): sv = self._get_static_view(request) res = sv.robotstxt() self.assertIsInstance(res, FileResponse) - self.assertEqual('text/plain', res.content_type) + self.assertEqual("text/plain", res.content_type) def test_faviconico(self): request = testing.DummyRequest() sv = self._get_static_view(request) res = sv.faviconico() self.assertIsInstance(res, FileResponse) - assert res.content_type in ['image/x-icon', 'image/vnd.microsoft.icon'] + assert res.content_type in ["image/x-icon", "image/vnd.microsoft.icon"] diff --git a/tests/test_utils.py b/tests/test_utils.py index ea463703..bc34cba3 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -2,145 +2,159 @@ import unittest from pyoes.utils import ( - set_attr_filter, + _fuzzy_date_formatter, datetime_format_filter, - fuzzy_date_format_filter, _fuzzy_date_formatter) + fuzzy_date_format_filter, + set_attr_filter, +) class TestSetAttr(unittest.TestCase): def test_set_attr_filter(self): d = {} - d2 = set_attr_filter(d, 'pagina', 1) - self.assertEqual({'pagina': 1}, d2) + d2 = set_attr_filter(d, "pagina", 1) + self.assertEqual({"pagina": 1}, d2) def test_set_attr_filter_overwrites(self): - d = {'pagina': 1} - d2 = set_attr_filter(d, 'pagina', 10) - self.assertEqual({'pagina': 10}, d2) + d = {"pagina": 1} + d2 = set_attr_filter(d, "pagina", 10) + self.assertEqual({"pagina": 10}, d2) class TestDatetimeFormatFilter(unittest.TestCase): def test_datetime_format_filter_default(self): from datetime import datetime + d = datetime(2014, 9, 7, 20, 00) fd = datetime_format_filter(d) - self.assertEqual('07-09-2014 20:00', fd) + self.assertEqual("07-09-2014 20:00", fd) def test_datetime_format_filter_date(self): from datetime import date + d = date(2014, 9, 7) - fd = datetime_format_filter(d, format='%d-%m-%Y') - self.assertEqual('07-09-2014', fd) + fd = datetime_format_filter(d, format="%d-%m-%Y") + self.assertEqual("07-09-2014", fd) def test_datetime_format_filter_custom_format(self): from datetime import datetime + d = datetime(2014, 9, 7, 20, 00) - fd = datetime_format_filter(d, '%d-%m-%Y') - self.assertEqual('07-09-2014', fd) + fd = datetime_format_filter(d, "%d-%m-%Y") + self.assertEqual("07-09-2014", fd) def test_datetime_format_filter_default_parsed(self): - fd = datetime_format_filter('07-09-2014 20:00') - self.assertEqual('07-09-2014 20:00', fd) + fd = datetime_format_filter("07-09-2014 20:00") + self.assertEqual("07-09-2014 20:00", fd) def test_datetime_format_filter_yearfirst(self): - fd = datetime_format_filter('2017-01-26') - self.assertEqual('26-01-2017 00:00', fd) + fd = datetime_format_filter("2017-01-26") + self.assertEqual("26-01-2017 00:00", fd) def test_datetime_format_filter_yearfirst_daylast(self): - fd = datetime_format_filter('2017-11-12') - self.assertEqual('12-11-2017 00:00', fd) + fd = datetime_format_filter("2017-11-12") + self.assertEqual("12-11-2017 00:00", fd) def test_datetime_format_filter_yearfirst_slash(self): - fd = datetime_format_filter('2017/11/12') - self.assertEqual('12-11-2017 00:00', fd) + fd = datetime_format_filter("2017/11/12") + self.assertEqual("12-11-2017 00:00", fd) def test_datetime_format_filter_slash(self): - fd = datetime_format_filter('12/11/12') - self.assertEqual('12-11-2012 00:00', fd) + fd = datetime_format_filter("12/11/12") + self.assertEqual("12-11-2012 00:00", fd) def test_datetime_format_filter_none(self): fd = datetime_format_filter(None) - self.assertEqual('', fd) + self.assertEqual("", fd) class TestFuzzyDateFormatFilter(unittest.TestCase): def test_fuzzy_date_format_filter_default(self): from datetime import datetime + d = datetime(2018, 4, 26, 20, 00) fd = fuzzy_date_format_filter(d) - self.assertEqual('26-04-2018', fd) + self.assertEqual("26-04-2018", fd) def test_fuzzy_date_format_filter_before_1900(self): from datetime import datetime + d = datetime(1782, 4, 26, 20, 00) fd = fuzzy_date_format_filter(d) - self.assertEqual('26-04-1782', fd) + self.assertEqual("26-04-1782", fd) def test_fuzzy_date_format_filter_date(self): from datetime import date + d = date(2018, 4, 26) fd = fuzzy_date_format_filter(d) - self.assertEqual('26-04-2018', fd) + self.assertEqual("26-04-2018", fd) def test_fuzzy_date_format_filter_custom_format(self): from datetime import datetime + d = datetime(2018, 4, 26, 20, 00) - fd = fuzzy_date_format_filter(d, '%m-%Y') - self.assertEqual('04-2018', fd) + fd = fuzzy_date_format_filter(d, "%m-%Y") + self.assertEqual("04-2018", fd) d = datetime(2018, 4, 26, 20, 00) - fd = fuzzy_date_format_filter(d, '%Y') - self.assertEqual('2018', fd) + fd = fuzzy_date_format_filter(d, "%Y") + self.assertEqual("2018", fd) def test_fuzzy_date_format_filter_default_parsed(self): - fd = fuzzy_date_format_filter('26-04-2018 20:00') - self.assertEqual('26-04-2018', fd) + fd = fuzzy_date_format_filter("26-04-2018 20:00") + self.assertEqual("26-04-2018", fd) def test_fuzzy_date_format_filter_yearfirst(self): - fd = fuzzy_date_format_filter('2018-04-26') - self.assertEqual('26-04-2018', fd) + fd = fuzzy_date_format_filter("2018-04-26") + self.assertEqual("26-04-2018", fd) def test_fuzzy_date_format_filter_yearfirst_daylast(self): - fd = fuzzy_date_format_filter('2018-11-12') - self.assertEqual('12-11-2018', fd) + fd = fuzzy_date_format_filter("2018-11-12") + self.assertEqual("12-11-2018", fd) def test_fuzzy_date_format_filter_yearfirst_slash(self): - fd = fuzzy_date_format_filter('2018/11/12') - self.assertEqual('12-11-2018', fd) + fd = fuzzy_date_format_filter("2018/11/12") + self.assertEqual("12-11-2018", fd) def test_fuzzy_date_format_filter_slash(self): - fd = fuzzy_date_format_filter('12/11/12') - self.assertEqual('12-11-2012', fd) + fd = fuzzy_date_format_filter("12/11/12") + self.assertEqual("12-11-2012", fd) def test_fuzzy_date_format_filter_none(self): fd = fuzzy_date_format_filter(None) - self.assertEqual('', fd) + self.assertEqual("", fd) def test_fuzzy_date_formatter_default(self): from datetime import datetime + d = datetime(2018, 4, 26, 20, 00) fd = _fuzzy_date_formatter(d) - self.assertEqual('26-04-2018', fd) + self.assertEqual("26-04-2018", fd) def test_fuzzy_date_formatter_day_month_year(self): from datetime import datetime + d = datetime(2018, 4, 26, 20, 00) - fd = _fuzzy_date_formatter(d, '%d-%m-%Y') - self.assertEqual('26-04-2018', fd) + fd = _fuzzy_date_formatter(d, "%d-%m-%Y") + self.assertEqual("26-04-2018", fd) def test_fuzzy_date_formatter_month_year(self): from datetime import datetime + d = datetime(2018, 4, 26, 20, 00) - fd = _fuzzy_date_formatter(d, '%m-%Y') - self.assertEqual('04-2018', fd) + fd = _fuzzy_date_formatter(d, "%m-%Y") + self.assertEqual("04-2018", fd) def test_fuzzy_date_formatter_year(self): from datetime import datetime + d = datetime(2018, 4, 26, 20, 00) - fd = _fuzzy_date_formatter(d, '%Y') - self.assertEqual('2018', fd) + fd = _fuzzy_date_formatter(d, "%Y") + self.assertEqual("2018", fd) def test_fuzzy_date_formatter_not_defined_formar(self): from datetime import datetime + d = datetime(2018, 4, 26, 20, 00) - fd = _fuzzy_date_formatter(d, '%Y-%d-%m') - self.assertEqual('26-04-2018', fd) + fd = _fuzzy_date_formatter(d, "%Y-%d-%m") + self.assertEqual("26-04-2018", fd) diff --git a/tests/test_varia.py b/tests/test_varia.py index 9fec3e34..f3d74873 100644 --- a/tests/test_varia.py +++ b/tests/test_varia.py @@ -4,9 +4,8 @@ from pyramid import testing -from pyoes import ( - includeme -) +from pyoes import includeme + class TestIncludeMe: From 5c84541d4cb81e0eded03ae3d5647a1b377afbe7 Mon Sep 17 00:00:00 2001 From: Jonas Geuens Date: Tue, 10 Sep 2024 13:05:33 +0200 Subject: [PATCH 3/4] working dir --- .github/workflows/pyoes.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/pyoes.yml b/.github/workflows/pyoes.yml index c103c322..b0e1212b 100644 --- a/.github/workflows/pyoes.yml +++ b/.github/workflows/pyoes.yml @@ -41,6 +41,7 @@ jobs: py.test --cov pyoes --cov-report term-missing - name: Upload coverage to Coveralls + working-directory: ./ run: coveralls env: COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }} \ No newline at end of file From 5142ce658ee9c96cd39be1e1ffed87c44bdb85e0 Mon Sep 17 00:00:00 2001 From: Jonas Geuens Date: Tue, 10 Sep 2024 13:07:56 +0200 Subject: [PATCH 4/4] venv coveralls --- .github/workflows/pyoes.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/pyoes.yml b/.github/workflows/pyoes.yml index b0e1212b..abc54a4d 100644 --- a/.github/workflows/pyoes.yml +++ b/.github/workflows/pyoes.yml @@ -42,6 +42,8 @@ jobs: - name: Upload coverage to Coveralls working-directory: ./ - run: coveralls + run: | + source venv/bin/activate + coveralls env: COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }} \ No newline at end of file