예제 #1
0
 def test_extract_options_missing_value_value_type(self):
     s = 'Sensor1, more:stuff,here, opt:value_type'
     e = (
         "Option 'value_type' is missing a <type 'str'> value of "
         "value_type.*"
     )
     with self.assertRaisesRegexp(HumanParserError, e):
         utils.extract_options(s)
예제 #2
0
 def test_extract_options_missing_value_max_data_age(self):
     s = 'Sensor1, more:stuff,here, opt:max_data_age'
     e = (
         "Option 'max_data_age' is missing a <type 'int'> value of seconds"
         ".*"
     )
     with self.assertRaisesRegexp(HumanParserError, e):
         utils.extract_options(s)
예제 #3
0
 def test_extract_options_many(self):
     s = (
         'Sensor1, more:stuff,here, opt:ignore_case, opt:max_data_age:3600'
         ', opt:match_any_value, opt:value_type:string'
     )
     exp = (
         'Sensor1, more:stuff,here',
         {
             'value_type': 'string',
             'ignore_case_flag': 1,
             'max_age_seconds': '3600',
             'all_values_flag': 0,
             'all_times_flag': 0
         }
     )
     r = utils.extract_options(s)
     self.assertEquals(r, exp)
예제 #4
0
 def test_extract_options_invalid_option(self):
     s = 'Sensor1, more:stuff,here, opt:invalid_option'
     e = "Option 'invalid_option' is not a valid option!"
     with self.assertRaisesRegexp(HumanParserError, e):
         utils.extract_options(s)
예제 #5
0
 def test_extract_options_nooptions(self):
     s = 'Sensor1, more:stuff,here'
     exp = ('Sensor1, more:stuff,here', {})
     r = utils.extract_options(s)
     self.assertEquals(r, exp)
예제 #6
0
 def test_extract_options_single(self):
     s = 'Sensor1, more:stuff,here, opt:ignore_case'
     exp = ('Sensor1, more:stuff,here', {'ignore_case_flag': 1})
     r = utils.extract_options(s)
     self.assertEquals(r, exp)