Example #1
0
 def test_selector_filter_extraction_fn(self):
     extraction_fn = dimensions.RegexExtraction('([a-b])')
     f = filters.Filter(dimension='dim', value='v',
                        extraction_function=extraction_fn)
     actual = filters.Filter.build_filter(f)
     expected = {'type': 'selector', 'dimension': 'dim', 'value': 'v',
                 'extractionFn': {'type': 'regex', 'expr': '([a-b])'}}
     assert actual == expected
Example #2
0
 def test_bound_filter_with_extraction_function(self):
     f = filters.Bound(
         dimension='d', lower='1', upper='3', upperStrict=True,
         extraction_function=dimensions.RegexExtraction('.*([0-9]+)'))
     actual = filters.Filter.build_filter(f)
     expected = {'type': 'bound', 'dimension': 'd', 'lower': '1',
                 'lowerStrict': False, 'upper': '3', 'upperStrict': True,
                 'ordering': 'lexicographic', 'alphaNumeric': False,
                 'extractionFn': {'type': 'regex', 'expr': '.*([0-9]+)'}}
     assert actual == expected
Example #3
0
 def test_interval_with_extraction_function(self):
     f = filters.Interval(
         dimension='dim', intervals=[
             "2014-10-01T00:00:00.000Z/2014-10-07T00:00:00.000Z"],
         extraction_function=dimensions.RegexExtraction('.*([0-9]+)')
     )
     actual = filters.Filter.build_filter(f)
     expected = {
         'type': 'interval', 'dimension': 'dim',
         'intervals': ["2014-10-01T00:00:00.000Z/2014-10-07T00:00:00.000Z"],
         'extractionFn': {'type': 'regex', 'expr': '.*([0-9]+)'}
     }
     assert actual == expected
Example #4
0
 def test_selector_filter_extraction_fn(self):
     extraction_fn = dimensions.RegexExtraction("([a-b])")
     f = filters.Filter(dimension="dim",
                        value="v",
                        extraction_function=extraction_fn)
     actual = filters.Filter.build_filter(f)
     expected = {
         "type": "selector",
         "dimension": "dim",
         "value": "v",
         "extractionFn": {
             "type": "regex",
             "expr": "([a-b])"
         },
     }
     assert actual == expected
Example #5
0
 def test_interval_with_extraction_function(self):
     f = filters.Interval(
         dimension="dim",
         intervals=["2014-10-01T00:00:00.000Z/2014-10-07T00:00:00.000Z"],
         extraction_function=dimensions.RegexExtraction(".*([0-9]+)"),
     )
     actual = filters.Filter.build_filter(f)
     expected = {
         "type": "interval",
         "dimension": "dim",
         "intervals": ["2014-10-01T00:00:00.000Z/2014-10-07T00:00:00.000Z"],
         "extractionFn": {
             "type": "regex",
             "expr": ".*([0-9]+)"
         },
     }
     assert actual == expected
Example #6
0
 def test_bound_filter_with_extraction_function(self):
     f = filters.Bound(
         dimension="d",
         lower="1",
         upper="3",
         upperStrict=True,
         extraction_function=dimensions.RegexExtraction(".*([0-9]+)"),
     )
     actual = filters.Filter.build_filter(f)
     expected = {
         "type": "bound",
         "dimension": "d",
         "lower": "1",
         "lowerStrict": False,
         "upper": "3",
         "upperStrict": True,
         "ordering": "lexicographic",
         "alphaNumeric": False,
         "extractionFn": {
             "type": "regex",
             "expr": ".*([0-9]+)"
         },
     }
     assert actual == expected