Exemplo n.º 1
0
 def test_extract_matching_individual_field(self):
     subset = {'log': {'fields': {'origin': {'fields': {'function': {}}}}}}
     filtered_fields = subset_filter.extract_matching_fields(
         self.schema_log(), subset)
     expected_fields = {
         'log': {
             'schema_details': {
                 'root': False
             },
             'field_details': {
                 'name': 'log',
                 'type': 'group'
             },
             'fields': {
                 'origin': {
                     'field_details': {
                         'name': 'origin',
                         'intermediate': True,
                         'type': 'object'
                     },
                     'fields': {
                         'function': {
                             'field_details': {
                                 'name': 'function',
                                 'type': 'keyword'
                             }
                         },
                     }
                 }
             }
         }
     }
     self.assertEqual(filtered_fields, expected_fields)
Exemplo n.º 2
0
 def test_extract_matching_fields_subfields_only_notation(self):
     subset = {'log': {'fields': {'origin': {}}}}
     filtered_fields = subset_filter.extract_matching_fields(
         self.schema_log(), subset)
     expected_fields = {
         'log': {
             'schema_details': {
                 'root': False
             },
             'field_details': {
                 'name': 'log',
                 'type': 'group'
             },
             'fields': {
                 'origin': {
                     'fields': {
                         'function': {
                             'field_details': {
                                 'name': 'function',
                                 'type': 'keyword'
                             }
                         },
                         'foo': {
                             'field_details': {
                                 'name': 'foo',
                                 'type': 'keyword'
                             }
                         },
                     }
                 }
             }
         }
     }
     self.assertEqual(filtered_fields, expected_fields)
Exemplo n.º 3
0
 def test_extract_field_with_options(self):
     subset = {
         'log': {
             'enabled': False,
             'fields': {
                 'level': {
                     'custom_option': True
                 },
                 'origin': {
                     'custom_option': False,
                     'fields': {
                         'function': {}
                     }
                 }
             }
         }
     }
     filtered_fields = subset_filter.extract_matching_fields(self.schema_log(), subset)
     expected_fields = {
         'log': {
             'schema_details': {'root': False},
             'field_details': {
                 'name': 'log',
                 'type': 'group',
                 'enabled': False
             },
             'fields': {
                 'level': {
                     'field_details': {
                         'name': 'level',
                         'type': 'keyword',
                         'custom_option': True
                     }
                 },
                 'origin': {
                     'field_details': {
                         # This field is changed by the subset_filter from an intermediate field to non-intermediate by adding
                         # a custom option, so the subset_filter is responsible for filling in more field_detail attributes
                         'name': 'origin',
                         'intermediate': False,
                         'custom_option': False,
                         'description': 'Intermediate field included by adding option with subset',
                         'level': 'custom',
                         'type': 'object',
                         'short': 'Intermediate field included by adding option with subset',
                         'normalize': []
                     },
                     'fields': {
                         'function': {
                             'field_details': {
                                 'name': 'function',
                                 'type': 'keyword'
                             }
                         },
                     }
                 }
             }
         }
     }
     self.assertEqual(filtered_fields, expected_fields)
Exemplo n.º 4
0
 def test_extract_matching_fields_explicit_all_fields_notation(self):
     subset = {'log': {'fields': '*'}}
     filtered_fields = subset_filter.extract_matching_fields(
         self.schema_log(), subset)
     self.assertEqual(filtered_fields, self.schema_log())
Exemplo n.º 5
0
 def test_extract_matching_fields_shorthand_notation(self):
     subset = {'log': {}}
     filtered_fields = subset_filter.extract_matching_fields(
         self.schema_log(), subset)
     self.assertEqual(filtered_fields, self.schema_log())