Add equalto Jinja2 test for EL7

CentOS/RHEL 7 install Jinja 2.7.2 by default and this version does not
have some of the newer tests.

Change-Id: Ica892b03ae9573414c0631369ccaa8435c4fe508
This commit is contained in:
Major Hayden 2017-06-30 09:13:16 -05:00
parent f422da8599
commit 5ce112c78b
No known key found for this signature in database
GPG Key ID: 737051E0C1011FB1
1 changed files with 45 additions and 0 deletions

45
test_plugins/el7_tests.py Normal file
View File

@ -0,0 +1,45 @@
# Copyright 2017, Rackspace US, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Additional Jinja2 tests for CentOS/RHEL7."""
# NOTE(mhayden): CentOS and RHEL7 ship with Jinja2 2.7.2 and it doesn't have
# some of the newer tests. This snippet adds those tests so that the tasks that
# use them will work properly.
def test_equalto(value, other):
"""Test to see if two values are the same."""
return value == other
def test_greaterthan(value, other):
"""Check if value is greater than other."""
return value > other
def test_lessthan(value, other):
"""Check if value is less than other."""
return value < other
class TestModule:
"""Main test class from Ansible."""
def tests(self):
"""Add these tests to the list of tests available to Ansible."""
return {
'equalto': test_equalto,
'greaterthan': test_greaterthan,
'lessthan': test_lessthan,
}