From a56bcfc9ca827962b444afea3f0cfffb61863a95 Mon Sep 17 00:00:00 2001 From: Adar Nimrod <nimrod@shore.co.il> Date: Sun, 11 Jun 2017 19:19:38 +0300 Subject: [PATCH] - Removed combine filter from README, was removed from code previously. - Replaced test shell script with Bats tests, update Travis CI and README accordingly. - Removed unused pre-commit hooks. - Bumped patch version. --- .pre-commit-config.yaml | 6 ------ .travis.yml | 3 +++ MANIFEST.in | 1 + README.rst | 9 ++++----- VERSION | 2 +- tests.sh | 17 ----------------- tests/input | 1 + tests/templates.bats | 14 ++++++++++++++ tox.ini | 4 +++- 9 files changed, 27 insertions(+), 30 deletions(-) delete mode 100755 tests.sh create mode 100644 tests/input create mode 100644 tests/templates.bats diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 0de076a..1ca7989 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -2,13 +2,7 @@ sha: v0.7.1 hooks: - id: check-added-large-files - - id: check-json - - id: check-xml - id: check-yaml - id: check-merge-conflict - id: flake8 - id: check-symlinks -- repo: https://www.shore.co.il/git/shell-pre-commit/ - sha: v0.5.3 - hooks: - - id: shell-lint diff --git a/.travis.yml b/.travis.yml index 436187b..784413b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -19,8 +19,11 @@ matrix: - python: "3.2" install: + - git clone --depth 1 https://github.com/sstephenson/bats "$HOME/bats" - pip install tox-travis | cat +env: + PATH: "$PATH:$HOME/bats/bin" script: - tox diff --git a/MANIFEST.in b/MANIFEST.in index e09a28e..30ab898 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,5 +1,6 @@ recursive-include template *.py exclude .pre-commit-config.yaml +exclude *.bats include *.rst include VERSION include *.txt diff --git a/README.rst b/README.rst index d809251..56f25e8 100644 --- a/README.rst +++ b/README.rst @@ -43,21 +43,20 @@ The following Jinja filters were added: - :code:`from_yaml`: Convert from yaml. - :code:`to_json`: Convert to json. - :code:`from_json`: Convert from json. -- :code:`combine`: Combine 2 dictionaries. - :code:`to_toml`: Convert to toml. - :code:`from_toml`: Convert from toml. - :code:`jmespath`: Queries data using the `JMESPath <http://jmespath.org/>`_ query language. -Example usage can be seen in :code:`tests.sh` and for specific filters in the +Example usage can be seen in :code:`tests` and for specific filters in the docstrings in :code:`template/filters.py`. Testing ------- -Tests require Python 2.7, Python 3.3 or later and Tox and are run by running -:code:`tox`. Also, Travis CI is used to test on multiple Python versions for -every push. +Tests require Python 2.7, Python 3.3 or later, Tox and Bats and are run by +running :code:`tox`. Also, Travis CI is used to test on multiple Python +versions for every push. Release ------- diff --git a/VERSION b/VERSION index 70d5b25..b300caa 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.4.3 \ No newline at end of file +0.4.4 \ No newline at end of file diff --git a/tests.sh b/tests.sh deleted file mode 100755 index d329d33..0000000 --- a/tests.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/sh -set -eu - -export infile="$(mktemp)" -export outfile="$(mktemp)" - -echo Basic test. -export name='John' -test "$(echo 'Hello {{ name if name is defined else 'world' }}.' | template)" = "Hello John." - -echo Testing arguments and reading/ writing to file. -echo '{{ name }}' > "$infile" -export name='John' -template --output "$outfile" "$infile" -test "$(cat $outfile)" = "$name" - -rm "$infile" "$outfile" diff --git a/tests/input b/tests/input new file mode 100644 index 0000000..aa2bf89 --- /dev/null +++ b/tests/input @@ -0,0 +1 @@ +{{ name }} diff --git a/tests/templates.bats b/tests/templates.bats new file mode 100644 index 0000000..b5c3dfc --- /dev/null +++ b/tests/templates.bats @@ -0,0 +1,14 @@ +#!/usr/bin/env bats + +export name='John' + +@test "Basic test" { + run sh -c "echo 'Hello {{ name }}.' | template" + [ "$output" = "Hello John." ] +} + +@test "Test arguments and reading and to/ from a file" { + template --output "$BATS_TMPDIR/output" "$BATS_TEST_DIRNAME/input" + run cat "$BATS_TMPDIR/output" + [ "$output" = "John" ] +} diff --git a/tox.ini b/tox.ini index 34b08a6..29539b2 100644 --- a/tox.ini +++ b/tox.ini @@ -19,12 +19,14 @@ deps = readme_renderer flake8 six +whitelist_externals = + bats commands = check-manifest --ignore tox.ini,tests* python setup.py check --metadata --strict flake8 . python -m doctest template/filters.py template/__init__.py - ./tests.sh + bats -t tests [testenv:docs] basepython = python -- GitLab