def test_parse_multiple_rules(): policy = parser.parse(["keep 7 days", "latest weekly keep 1 month", "latest monthly keep 6 months"]) eq_(policy, RetentionPolicy([ RetentionRule(tagger.SnapshotTagger(), _create_duration(days=7)), RetentionRule(tagger.WeeklyTagger(True), _create_duration(months=1)), RetentionRule(tagger.MonthlyTagger(True), _create_duration(months=6)) ]))
def _run_parse_tag(tag, tagger_cls, latest): policy = parser.parse(["{} {} keep for 7 days".format("latest" if latest else "oldest", tag)]) eq_(policy, RetentionPolicy([RetentionRule(tagger_cls(latest), _create_duration(days=7))]))
def _run_parse_keep_duration(parse_str, duration): policy = parser.parse(["keep for {}".format(parse_str)]) eq_(policy, RetentionPolicy([RetentionRule(tagger.SnapshotTagger(), duration)]))
def test_parse_snapshot(): policy = parser.parse(["keep for 7 days"]) eq_(policy, RetentionPolicy([RetentionRule(tagger.SnapshotTagger(), _create_duration(days=7))]))