Beispiel #1
0
 def test_single_str_complex2(self):
     sensors = (
         'Sensor1{k1=v1,k2=v2}, that is:.*, opt:value_type:string, '
         'opt:ignore_case, opt:max_data_age:3600, opt:match_any_value'
     )
     sensor_defs = utils.dehumanize_sensors(sensors)
     exp = [
         {
             'filter': {
                 'not_flag': 0,
                 'operator': 'RegexMatch',
                 'value': '.*'
             },
             'name': 'Sensor1',
             'options': {
                 'all_times_flag': 0,
                 'all_values_flag': 0,
                 'ignore_case_flag': 1,
                 'max_age_seconds': '3600',
                 'value_type': 'string'
             },
             'params': {'k1': 'v1', 'k2': 'v2'}
         }
     ]
     self.assertEquals(sensor_defs, exp)
Beispiel #2
0
 def test_multi_list_complex(self):
     sensors = [
         'Computer Name',
         'id:1',
         'Operating System, that contains:Windows',
         ('Sensor1{k1=v1,k2=v2}, that is:.*, opt:value_type:string, '
          'opt:ignore_case, opt:max_data_age:3600, opt:match_any_value'),
     ]
     sensor_defs = utils.dehumanize_sensors(sensors)
     exp = [
         {
             'filter': {},
             'params': {},
             'name': 'Computer Name',
             'options': {}
         },
         {
             'filter': {},
             'params': {},
             'id': '1',
             'options': {}
         },
         {
             'filter': {
                 'operator': 'RegexMatch',
                 'not_flag': 0,
                 'value': '.*Windows.*'
             },
             'params': {},
             'name': 'Operating System',
             'options': {}
         },
         {
             'filter': {
                 'operator': 'RegexMatch',
                 'not_flag': 0,
                 'value': '.*'
             },
             'params': {'k2': 'v2', 'k1': 'v1'},
             'name': 'Sensor1',
             'options': {
                 'all_values_flag': 0,
                 'ignore_case_flag': 1,
                 'max_age_seconds': '3600',
                 'value_type': 'string',
                 'all_times_flag': 0
             }
         }
     ]
     self.assertEquals(sensor_defs, exp)
Beispiel #3
0
 def test_single_str_with_filter(self):
     sensors = 'Sensor1, that is:.*'
     sensor_defs = utils.dehumanize_sensors(sensors)
     exp = [
         {
             'filter': {
                 'operator': 'RegexMatch',
                 'not_flag': 0,
                 'value': '.*'
             },
             'params': {},
             'name': 'Sensor1',
             'options': {}
         }
     ]
     self.assertEquals(sensor_defs, exp)
Beispiel #4
0
 def test_single_str(self):
     sensors = 'Sensor1'
     sensor_defs = utils.dehumanize_sensors(sensors)
     exp = [{'filter': {}, 'params': {}, 'options': {}, 'name': 'Sensor1'}]
     self.assertEquals(sensor_defs, exp)
Beispiel #5
0
 def test_empty_args_dict(self):
     e = "A string or list of strings must be supplied as 'sensors'!"
     with self.assertRaisesRegexp(HumanParserError, e):
         utils.dehumanize_sensors({})
Beispiel #6
0
 def test_valid_simple_list(self):
     sensors = ['Sensor1']
     sensor_defs = utils.dehumanize_sensors(sensors)
     exp = [{'filter': {}, 'params': {}, 'options': {}, 'name': 'Sensor1'}]
     self.assertEquals(sensor_defs, exp)
Beispiel #7
0
 def test_valid_simple_str_hash_selector(self):
     sensors = 'hash:1'
     sensor_defs = utils.dehumanize_sensors(sensors)
     exp = [{'filter': {}, 'params': {}, 'options': {}, 'hash': '1'}]
     self.assertEquals(sensor_defs, exp)