@ -112,27 +112,27 @@ class TestUtils(unittest.TestCase):
# boolean
assert ( ansible . utils . check_conditional (
' jinja2_compare true' , ' / ' , { } ) == True )
' true' , ' / ' , { } ) == True )
assert ( ansible . utils . check_conditional (
' jinja2_compare false' , ' / ' , { } ) == False )
' false' , ' / ' , { } ) == False )
assert ( ansible . utils . check_conditional (
' jinja2_compare True' , ' / ' , { } ) == True )
' True' , ' / ' , { } ) == True )
assert ( ansible . utils . check_conditional (
' jinja2_compare False' , ' / ' , { } ) == False )
' False' , ' / ' , { } ) == False )
# integer
assert ( ansible . utils . check_conditional (
' jinja2_compare 1' , ' / ' , { } ) == True )
' 1' , ' / ' , { } ) == True )
assert ( ansible . utils . check_conditional (
' jinja2_compare 0' , ' / ' , { } ) == False )
' 0' , ' / ' , { } ) == False )
# string, beware, a string is truthy unless empty
assert ( ansible . utils . check_conditional (
' jinja2_compare "yes " ' , ' / ' , { } ) == True )
' "yes " ' , ' / ' , { } ) == True )
assert ( ansible . utils . check_conditional (
' jinja2_compare "no " ' , ' / ' , { } ) == True )
' "no " ' , ' / ' , { } ) == True )
assert ( ansible . utils . check_conditional (
' jinja2_compare "" ' , ' / ' , { } ) == False )
' "" ' , ' / ' , { } ) == False )
def test_check_conditional_jinja2_variable_literals ( self ) :
@ -140,61 +140,61 @@ class TestUtils(unittest.TestCase):
# boolean
assert ( ansible . utils . check_conditional (
' jinja2_compare var' , ' / ' , { ' var ' : ' True ' } ) == True )
' var' , ' / ' , { ' var ' : ' True ' } ) == True )
assert ( ansible . utils . check_conditional (
' jinja2_compare var' , ' / ' , { ' var ' : ' true ' } ) == True )
' var' , ' / ' , { ' var ' : ' true ' } ) == True )
assert ( ansible . utils . check_conditional (
' jinja2_compare var' , ' / ' , { ' var ' : ' False ' } ) == False )
' var' , ' / ' , { ' var ' : ' False ' } ) == False )
assert ( ansible . utils . check_conditional (
' jinja2_compare var' , ' / ' , { ' var ' : ' false ' } ) == False )
' var' , ' / ' , { ' var ' : ' false ' } ) == False )
# integer
assert ( ansible . utils . check_conditional (
' jinja2_compare var' , ' / ' , { ' var ' : ' 1 ' } ) == True )
' var' , ' / ' , { ' var ' : ' 1 ' } ) == True )
assert ( ansible . utils . check_conditional (
' jinja2_compare var' , ' / ' , { ' var ' : 1 } ) == True )
' var' , ' / ' , { ' var ' : 1 } ) == True )
assert ( ansible . utils . check_conditional (
' jinja2_compare var' , ' / ' , { ' var ' : ' 0 ' } ) == False )
' var' , ' / ' , { ' var ' : ' 0 ' } ) == False )
assert ( ansible . utils . check_conditional (
' jinja2_compare var' , ' / ' , { ' var ' : 0 } ) == False )
' var' , ' / ' , { ' var ' : 0 } ) == False )
# string, beware, a string is truthy unless empty
assert ( ansible . utils . check_conditional (
' jinja2_compare var' , ' / ' , { ' var ' : ' " yes " ' } ) == True )
' var' , ' / ' , { ' var ' : ' " yes " ' } ) == True )
assert ( ansible . utils . check_conditional (
' jinja2_compare var' , ' / ' , { ' var ' : ' " no " ' } ) == True )
' var' , ' / ' , { ' var ' : ' " no " ' } ) == True )
assert ( ansible . utils . check_conditional (
' jinja2_compare var' , ' / ' , { ' var ' : ' " " ' } ) == False )
' var' , ' / ' , { ' var ' : ' " " ' } ) == False )
# Python boolean in Jinja2 expression
assert ( ansible . utils . check_conditional (
' jinja2_compare var' , ' / ' , { ' var ' : True } ) == True )
' var' , ' / ' , { ' var ' : True } ) == True )
assert ( ansible . utils . check_conditional (
' jinja2_compare var' , ' / ' , { ' var ' : False } ) == False )
' var' , ' / ' , { ' var ' : False } ) == False )
def test_check_conditional_jinja2_expression ( self ) :
assert ( ansible . utils . check_conditional (
' jinja2_compare 1 == 1' , ' / ' , { } ) == True )
' 1 == 1' , ' / ' , { } ) == True )
assert ( ansible . utils . check_conditional (
' jinja2_compare bar == 42' , ' / ' , { ' bar ' : 42 } ) == True )
' bar == 42' , ' / ' , { ' bar ' : 42 } ) == True )
assert ( ansible . utils . check_conditional (
' jinja2_compare bar != 42' , ' / ' , { ' bar ' : 42 } ) == False )
' bar != 42' , ' / ' , { ' bar ' : 42 } ) == False )
def test_check_conditional_jinja2_expression_in_variable ( self ) :
assert ( ansible . utils . check_conditional (
' jinja2_compare var' , ' / ' , { ' var ' : ' 1 == 1 ' } ) == True )
' var' , ' / ' , { ' var ' : ' 1 == 1 ' } ) == True )
assert ( ansible . utils . check_conditional (
' jinja2_compare var' , ' / ' , { ' var ' : ' bar == 42 ' , ' bar ' : 42 } ) == True )
' var' , ' / ' , { ' var ' : ' bar == 42 ' , ' bar ' : 42 } ) == True )
assert ( ansible . utils . check_conditional (
' jinja2_compare var' , ' / ' , { ' var ' : ' bar != 42 ' , ' bar ' : 42 } ) == False )
' var' , ' / ' , { ' var ' : ' bar != 42 ' , ' bar ' : 42 } ) == False )
def test_check_conditional_jinja2_unicode ( self ) :
assert ( ansible . utils . check_conditional (
u ' jinja2_compare "\u00df " ' , ' / ' , { } ) == True )
u ' "\u00df " ' , ' / ' , { } ) == True )
assert ( ansible . utils . check_conditional (
u ' jinja2_compare var == " \u00df " ' , ' / ' , { ' var ' : u ' \u00df ' } ) == True )
u ' var == " \u00df " ' , ' / ' , { ' var ' : u ' \u00df ' } ) == True )
#####################################