1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Prune legacy tests -- many of these are not part of the official API or documented syntax.

This commit is contained in:
Michael DeHaan 2013-10-11 19:31:26 -04:00
parent e8b043332f
commit 2032489617

View file

@ -15,257 +15,6 @@ class TestUtils(unittest.TestCase):
##################################### #####################################
### varReplace function tests ### varReplace function tests
def test_varReplace_simple(self):
template = 'hello $who'
vars = {
'who': 'world',
}
res = template2.legacy_varReplace(None, template, vars)
assert res == 'hello world'
def test_varReplace_trailing_dollar(self):
template = '$what $who $'
vars = dict(what='hello', who='world')
res = template2.legacy_varReplace(None, template, vars)
assert res == 'hello world $'
def test_varReplace_multiple(self):
template = '$what $who'
vars = {
'what': 'hello',
'who': 'world',
}
res = template2.legacy_varReplace(None, template, vars)
assert res == 'hello world'
def test_varReplace_caps(self):
template = 'hello $whoVar'
vars = {
'whoVar': 'world',
}
res = template2.legacy_varReplace(None, template, vars)
print res
assert res == 'hello world'
def test_varReplace_middle(self):
template = 'hello $who!'
vars = {
'who': 'world',
}
res = template2.legacy_varReplace(None, template, vars)
assert res == 'hello world!'
def test_varReplace_alternative(self):
template = 'hello ${who}'
vars = {
'who': 'world',
}
res = template2.legacy_varReplace(None, template, vars)
assert res == 'hello world'
def test_varReplace_almost_alternative(self):
template = 'hello $who}'
vars = {
'who': 'world',
}
res = template2.legacy_varReplace(None, template, vars)
assert res == 'hello world}'
def test_varReplace_almost_alternative2(self):
template = 'hello ${who'
vars = {
'who': 'world',
}
res = template2.legacy_varReplace(None, template, vars)
assert res == template
def test_varReplace_alternative_greed(self):
template = 'hello ${who} }'
vars = {
'who': 'world',
}
res = template2.legacy_varReplace(None, template, vars)
assert res == 'hello world }'
def test_varReplace_notcomplex(self):
template = 'hello $mydata.who'
vars = {
'data': {
'who': 'world',
},
}
res = template2.legacy_varReplace(None, template, vars)
print res
assert res == template
def test_varReplace_nested(self):
template = 'hello ${data.who}'
vars = {
'data': {
'who': 'world'
},
}
res = template2.legacy_varReplace(None, template, vars)
assert res == 'hello world'
def test_varReplace_nested_int(self):
template = '$what ${data.who}'
vars = {
'data': {
'who': 2
},
'what': 'hello',
}
res = template2.legacy_varReplace(None, template, vars)
assert res == 'hello 2'
def test_varReplace_unicode(self):
template = 'hello $who'
vars = {
'who': u'wórld',
}
res = template2.legacy_varReplace(None, template, vars)
assert res == u'hello wórld'
def test_varReplace_list(self):
template = 'hello ${data[1]}'
vars = {
'data': [ 'no-one', 'world' ]
}
res = template2.legacy_varReplace(None, template, vars)
assert res == 'hello world'
def test_varReplace_invalid_list(self):
template = 'hello ${data[1}'
vars = {
'data': [ 'no-one', 'world' ]
}
res = template2.legacy_varReplace(None, template, vars)
assert res == template
def test_varReplace_list_oob(self):
template = 'hello ${data[2]}'
vars = {
'data': [ 'no-one', 'world' ]
}
res = template2.legacy_varReplace(None, template, vars)
assert res == template
def test_varReplace_list_nolist(self):
template = 'hello ${data[1]}'
vars = {
'data': { 'no-one': 0, 'world': 1 }
}
res = template2.legacy_varReplace(None, template, vars)
assert res == template
def test_varReplace_nested_list(self):
template = 'hello ${data[1].msg[0]}'
vars = {
'data': [ 'no-one', {'msg': [ 'world'] } ]
}
res = template2.legacy_varReplace(None, template, vars)
assert res == 'hello world'
def test_varReplace_consecutive_vars(self):
vars = {
'foo': 'foo',
'bar': 'bar',
}
template = '${foo}${bar}'
res = template2.legacy_varReplace(None, template, vars)
assert res == 'foobar'
def test_varReplace_escape_dot(self):
vars = {
'hostvars': {
'test.example.com': {
'foo': 'bar',
},
},
}
template = '${hostvars.{test.example.com}.foo}'
res = template2.legacy_varReplace(None, template, vars)
assert res == 'bar'
def test_varReplace_list_join(self):
vars = {
'list': [
'foo',
'bar',
'baz',
],
}
template = 'yum pkg=${list} state=installed'
res = template2.legacy_varReplace(None, template, vars, expand_lists=True)
assert res == 'yum pkg=foo,bar,baz state=installed'
def test_varReplace_escaped_var(self):
vars = {
'foo': 'bar',
}
template = 'action \$foo'
res = template2.legacy_varReplace(None, template, vars)
assert res == 'action $foo'
def test_varReplace_var_part(self):
vars = {
'foo': {
'bar': 'result',
},
'key': 'bar',
}
template = 'test ${foo.$key}'
res = template2.legacy_varReplace(None, template, vars)
assert res == 'test result'
def test_varReplace_var_partial_part(self):
vars = {
'foo': {
'barbaz': 'result',
},
'key': 'bar',
}
template = 'test ${foo.${key}baz}'
res = template2.legacy_varReplace(None, template, vars)
assert res == 'test result'
def test_varReplace_var_complex_var(self): def test_varReplace_var_complex_var(self):
vars = { vars = {
'x': '$y', 'x': '$y',
@ -277,20 +26,6 @@ class TestUtils(unittest.TestCase):
res = template2.template(None, template, vars) res = template2.template(None, template, vars)
assert res == 'result' assert res == 'result'
def test_varReplace_include(self):
template = 'hello $FILE(world) $LOOKUP(file, $filename)'
res = template2.template("test", template, {'filename': 'world'}, expand_lists=True)
assert res == u'hello world world'
def test_varReplace_include_script(self):
template = 'hello $PIPE(echo world) $LOOKUP(pipe, echo world)'
res = template2.template("test", template, {}, expand_lists=True)
assert res == u'hello world world'
##################################### #####################################
### template_ds function tests ### template_ds function tests