def test_substitute_when_template_is_shell(self): tmpl1 = mlabconfig.BracketTemplate('$var1 == {{var1}}') tmpl2 = mlabconfig.BracketTemplate('${var2} == {{var2}}') actual1 = tmpl1.safe_substitute(self.vars) actual2 = tmpl2.safe_substitute(self.vars) self.assertEqual(actual1, '$var1 == Spot') self.assertEqual(actual2, '${var2} == Dog')
def test_substitute_without_value_returns_unchanged_template(self): tmpl = mlabconfig.BracketTemplate('{{evaluated}} {{unevaluated}}') actual = tmpl.safe_substitute({'evaluated': 'okay'}) self.assertEqual(actual, 'okay {{unevaluated}}')
def test_substitute_when_template_is_broken(self): tmpl = mlabconfig.BracketTemplate('var1}} is a {{var2') actual = tmpl.safe_substitute(self.vars) self.assertEqual(actual, 'var1}} is a {{var2')
def test_substitute_when_template_is_correct(self): tmpl = mlabconfig.BracketTemplate('{{var1}} is a {{var2}}') actual = tmpl.safe_substitute(self.vars) self.assertEqual(actual, 'Spot is a Dog')