示例#1
0
    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
示例#2
0
 def test_default_optional_values_boolean(self):
     """ParserBase - Default Optional Type, Boolean"""
     assert_equal(ParserBase.default_optional_values('boolean'), False)
示例#3
0
 def test_default_optional_values_float(self):
     """ParserBase - Default Optional Type, Float"""
     assert_equal(ParserBase.default_optional_values('float'), 0.0)
示例#4
0
 def test_default_optional_values_int(self):
     """ParserBase - Default Optional Type, Int"""
     assert_equal(ParserBase.default_optional_values('integer'), 0)
示例#5
0
 def test_default_optional_values_str(self):
     """ParserBase - Default Optional Type, Str"""
     assert_equal(ParserBase.default_optional_values('string'), '')
示例#6
0
 def test_default_optional_values_dict(self):
     """ParserBase - Default Optional Type, Dictionary"""
     assert_equal(ParserBase.default_optional_values(dict()), {})
示例#7
0
 def test_default_optional_values_list(self):
     """ParserBase - Default Optional Type, List"""
     assert_equal(ParserBase.default_optional_values(list()), [])