Esempio n. 1
0
 def valid(self, data):
     missing = []
     # Curry check_value with container for missing properties
     curried_check = functools.partial(self.check_value, missing=missing)
     # Walk over the acquired data to check a value is set for each property
     utils.walk_and_apply(data, curried_check)
     # Set the list of missing properties as instance variable
     self.missing = missing
     return missing
Esempio n. 2
0
 def valid(self, data):
     missing = []
     # Curry check_value with container for missing properties
     curried_check = functools.partial(self.check_value, missing=missing)
     # Walk over the acquired data to check a value is set for each property
     utils.walk_and_apply(data, curried_check)
     if missing:
         raise MinimumDataFailure(
             'Properties: {}; have no value'.format(', '.join(missing))
             )
     return missing
Esempio n. 3
0
 def map_to_config(self, source):
     """
     Return dict of values extracted from given source based on self.config
     """
     # Curry the lookup_value function with the source tree
     func = functools.partial(self.lookup_value, source)
     # Apply the curried function to the config dict
     return utils.walk_and_apply(self.config, func)
Esempio n. 4
0
 def compile_config(self, config):
     """
     Walk over configuration and replace values with functions
     """
     return utils.walk_and_apply(config, self.compile_lookups)
Esempio n. 5
0
 def test_walk_dict(self):
     out = utils.walk_and_apply(self.given, self.function)
     self.assertEqual(self.expected, out)