def test_apply_filter_exclude(self): pattern = r'201|logstash' expected = ['foo', 'bar', 'baz', 'neeble'] self.assertEqual( expected, curator.apply_filter(re_test_indices, pattern=pattern, exclude=True) )
def test_apply_filter_newer_than_negative_value(self): pattern = r'(?P<date>\d{4}.\d{2}.\d{2})' expected = [ '.marvel-2015.12.31', '.marvel-2015.12.30', '.marvel-2015.12.29' ] t = datetime(2014, 12, 1, 2, 34, 56) self.assertEqual(expected, curator.apply_filter( re_test_indices, pattern=pattern, groupname='date', timestring='%Y.%m.%d', time_unit='days', method='newer_than', value=-30, utc_now=t ) )
def test_apply_filter_older_than_date_only(self): pattern = r'(?P<date>\d{4}-\d{2}-\d{2})' expected = [ '2015-01-01', '2015-01-02', '2015-01-03', ] t = datetime(2015, 2, 1, 2, 34, 56) self.assertEqual(expected, curator.apply_filter( re_test_indices, pattern=pattern, groupname='date', timestring='%Y-%m-%d', time_unit='days', method='older_than', value=2, utc_now=t ) )
def test_apply_filter_timestring(self): pattern = r'^.*\d{4}.\d{2}.\d{2}.*$' expected = [ 'logstash-2014.12.31', 'logstash-2014.12.30', 'logstash-2014.12.29', '.marvel-2015.12.31', '.marvel-2015.12.30', '.marvel-2015.12.29', '2014.11.30', '2014.11.29', '2014.12.28', '2014.10.31-buh', '2014.10.30-buh', '2014.10.29-buh', '2015-01-01', '2015-01-02', '2015-01-03', ] self.assertEqual( expected, curator.apply_filter(re_test_indices, pattern=pattern) )
def test_apply_filter_older_than_with_prefix_and_suffix(self): pattern = r'(?P<date>\d{4}.\d{2}.\d{2})' expected = [ 'logstash-2014.12.31', 'logstash-2014.12.30', 'logstash-2014.12.29', '2014.11.30', '2014.11.29', '2014.12.28', '2014.10.31-buh', '2014.10.30-buh', '2014.10.29-buh' ] t = datetime(2015, 2, 1, 2, 34, 56) self.assertEqual(expected, curator.apply_filter( re_test_indices, pattern=pattern, groupname='date', timestring='%Y.%m.%d', time_unit='days', method='older_than', value=2, utc_now=t ) )
def test_apply_filter_suffix(self): pattern = r'^.*foo$' expected = [ 'foo', 'logstash-foo', 'logstashfoo' ] self.assertEqual( expected, curator.apply_filter(re_test_indices, pattern=pattern) )
def test_apply_filter_prefix(self): pattern = r'^foo.*$' expected = [ 'foo', 'foo-logstash', 'foologstash' ] self.assertEqual( expected, curator.apply_filter(re_test_indices, pattern=pattern) )
def test_apply_filter_filter_none(self): pattern = r'.*' self.assertEqual( re_test_indices, curator.apply_filter(re_test_indices, pattern=pattern) )
def test_apply_filter_missing_param_pattern(self): self.assertFalse(curator.apply_filter(re_test_indices))