Esempio n. 1
0
    def _apply_defaults(self, config):
        """Apply default values to the given test event"""
        if not self.override_record:
            return

        # The existence of this is checked in the is_valid function
        event_log = config['logs'].get(self.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.items()
        }

        # Overwrite the fields included in the 'override_record' field,
        # and update the test event with a full 'data' key
        default_test_event.update(self.override_record)
        self._event['data'] = default_test_event
Esempio n. 2
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.items()
        }

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