Ejemplo n.º 1
0
 def test_load_template_vars_from_string(self):
     pairs = [
         "name=John",
         "type=Human",
         "age=12"
     ]
     expected = {
         "name": "John",
         "type": "Human",
         "age": "12"
     }
     self.assertEqual(expected, load_template_vars(template_vars=pairs))
Ejemplo n.º 2
0
 def test_load_template_vars_from_file(self):
     with tempfile.NamedTemporaryFile() as tf:
         tf.write("""
         name=John
         type=Human
         # a comment
         # type=Test
         age=12
         """.encode())
         tf.flush()
         expected = {"name": "John", "type": "Human", "age": "12"}
         self.assertEqual(
             expected,
             load_template_vars(template_vars=None,
                                template_vars_file=tf.name))
Ejemplo n.º 3
0
 def test_load_template_vars_from_string_and_file(self):
     """Text pair variables take precedence over file."""
     pairs = ["name=John", "age=12"]
     with tempfile.NamedTemporaryFile() as tf:
         tf.write("""
         name=Mariah
         type=Human
         # a comment
         # type=Test
         age=70
         """.encode())
         tf.flush()
         expected = {"name": "John", "type": "Human", "age": "12"}
         self.assertEqual(
             expected,
             load_template_vars(template_vars=pairs,
                                template_vars_file=tf.name))
Ejemplo n.º 4
0
 def test_load_template_vars_no_params(self):
     self.assertFalse(load_template_vars())