Example #1
0
 def test_write_values(self):
     schema = config_helper.Schema.load_yaml("""
     properties:
       propertyInt:
         type: int
       propertyStr:
         type: string
       propertyNum:
         type: number
     """)
     values = {'propertyInt': 4, 'propertyStr': 'Value', 'propertyNum': 1.0}
     with tempfile.NamedTemporaryFile('w') as tf:
         expand_config.write_values(values, tf.name)
         actual = config_helper.load_values(tf.name, '/non/existent/dir',
                                            'utf_8', schema)
         self.assertEqual(values, actual)
    def test_load_yaml_file(self):
        schema = config_helper.Schema.load_yaml("""
        properties:
          propertyInt:
            type: int
          propertyString:
            type: string
        """)
        with tempfile.NamedTemporaryFile('w') as f:
            f.write("""
              propertyInt: 3
              propertyString: abc
              """.encode('utf_8'))
            f.flush()

            values = config_helper.load_values(f.name, '/non/existence/dir',
                                               schema)
            self.assertEqual({
                'propertyInt': 3,
                'propertyString': 'abc'
            }, values)
Example #3
0
def load_values(parsed_args):
  return config_helper.load_values(parsed_args.values_file,
                                   parsed_args.values_dir,
                                   parsed_args.values_dir_encoding,
                                   load_schema(parsed_args))
Example #4
0
def load_values(parsed_args):
    values_file = VALUES_FILE[parsed_args.values_mode]
    values_dir = VALUES_DIR[parsed_args.values_mode]
    return config_helper.load_values(values_file, values_dir,
                                     load_schema(parsed_args))