def _apply_defaults(self, test_event): """Apply default values to the given test event Args: test_event (dict): The loaded test event """ if 'override_record' not in test_event: return event_log = self._config['logs'].get(test_event['log']) configuration = event_log.get('configuration', {}) schema = configuration.get('envelope_keys', event_log['schema']) # Add apply default values based on the declared schema default_test_event = { key: ParserBase.default_optional_values(value) for key, value in schema.iteritems() } # Overwrite the fields included in the 'override_record' field, # and update the test event with a full 'data' key default_test_event.update(test_event['override_record']) test_event['data'] = default_test_event
def test_default_optional_values_boolean(self): """ParserBase - Default Optional Type, Boolean""" assert_equal(ParserBase.default_optional_values('boolean'), False)
def test_default_optional_values_float(self): """ParserBase - Default Optional Type, Float""" assert_equal(ParserBase.default_optional_values('float'), 0.0)
def test_default_optional_values_int(self): """ParserBase - Default Optional Type, Int""" assert_equal(ParserBase.default_optional_values('integer'), 0)
def test_default_optional_values_str(self): """ParserBase - Default Optional Type, Str""" assert_equal(ParserBase.default_optional_values('string'), '')
def test_default_optional_values_dict(self): """ParserBase - Default Optional Type, Dictionary""" assert_equal(ParserBase.default_optional_values(dict()), {})
def test_default_optional_values_list(self): """ParserBase - Default Optional Type, List""" assert_equal(ParserBase.default_optional_values(list()), [])