coverage for filter/urls.py, including fallback to custom implementations (#68412)
Signed-off-by: Rick Elrod <rick@elrod.me>
This commit is contained in:
parent
01638e0ea2
commit
11e678b1b0
3 changed files with 47 additions and 2 deletions
22
test/integration/targets/filter_urls/runme.sh
Executable file
22
test/integration/targets/filter_urls/runme.sh
Executable file
|
@ -0,0 +1,22 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
set -eux
|
||||
|
||||
export ANSIBLE_ROLES_PATH=../
|
||||
|
||||
ansible-playbook runme.yml "$@"
|
||||
|
||||
source virtualenv.sh
|
||||
|
||||
# This is necessary for installing Jinja 2.6. We need this because Jinja 2.6
|
||||
# won't install with newer setuptools, and because setuptools 45+ won't work
|
||||
# with Python 2.
|
||||
pip install 'setuptools<45'
|
||||
|
||||
# Install Jinja 2.6 since we want to test the fallback to Ansible's custom
|
||||
# urlencode functions. Jinja 2.6 does not have urlencode so we will trigger the
|
||||
# fallback.
|
||||
pip install 'jinja2 >= 2.6, < 2.7'
|
||||
|
||||
# Run the playbook again in the venv with Jinja 2.6
|
||||
ansible-playbook runme.yml "$@"
|
4
test/integration/targets/filter_urls/runme.yml
Normal file
4
test/integration/targets/filter_urls/runme.yml
Normal file
|
@ -0,0 +1,4 @@
|
|||
- hosts: localhost
|
||||
gather_facts: false
|
||||
roles:
|
||||
- { role: filter_urls }
|
|
@ -1,12 +1,31 @@
|
|||
- name: Get Jinja2 version
|
||||
shell: "{{ ansible_python_interpreter }} -c 'import jinja2; print(jinja2.__version__)'"
|
||||
register: jinja2_version
|
||||
|
||||
- name: Print Jinja2 version
|
||||
debug: var=jinja2_version.stdout
|
||||
|
||||
- name: Test urldecode filter
|
||||
set_fact:
|
||||
urldecoded_string: key="@{}é&%£ foo bar '(;\<>""°)
|
||||
|
||||
- name: Test urlencode filter
|
||||
set_fact:
|
||||
urlencoded_string: '{{ urldecoded_string|urlencode }}'
|
||||
urlencoded_string: 'key%3D%22%40%7B%7D%C3%A9%26%25%C2%A3%20foo%20bar%20%27%28%3B%5C%3C%3E%22%22%C2%B0%29'
|
||||
|
||||
- name: Verify urlencode en urldecode
|
||||
- name: Verify urlencode / urldecode isomorphism
|
||||
assert:
|
||||
that:
|
||||
- urldecoded_string == urlencoded_string|urldecode
|
||||
- urlencoded_string == urldecoded_string|urlencode
|
||||
|
||||
- name: Verify urlencode handles dicts properly
|
||||
assert:
|
||||
that:
|
||||
- "{'foo': 'bar'}|urlencode == 'foo=bar'"
|
||||
- "{'foo': 'bar', 'baz': 'buz'}|urlencode == 'foo=bar&baz=buz'"
|
||||
- "()|urlencode == ''"
|
||||
|
||||
# Needed (temporarily) due to coverage reports not including the last task.
|
||||
- assert:
|
||||
that: true
|
||||
|
|
Loading…
Reference in a new issue