예제 #1
0
def test_run_cleaner():
    logger.debug(
        os.environ.get('PYTEST_CURRENT_TEST').split(':')[-1].split(' ')[0])
    config = conf().cleaner
    cleaner = Cleaner(config)

    date = datetime.datetime.now() - datetime.timedelta(
        days=config["retention_period"])

    # check that there are no destinations
    cleaner.delete_destination_keys(date)
    assert len(cleaner.get_destinations(date)) == 0

    # first put a few destinations and keys
    prefix = config["dest_path"] + date.strftime(DATE_FORMAT) + "/"
    put_key(config["url"], prefix + "EC1")
    put_key(
        config["url"], config["diss_path"] + "EC1/date=" +
        date.strftime(DATE_FORMAT) + "/aaaa")
    put_key(
        config["url"], config["diss_path"] + "EC1/date=" +
        date.strftime(DATE_FORMAT) + "/bbbb")
    put_key(
        config["url"], config["diss_path"] + "EC1/date=" +
        date.strftime(DATE_FORMAT) + "/cccc")

    # run the whole workflow
    cleaner.run()

    # check that there are no destinations
    assert len(cleaner.get_destinations(date)) == 0
예제 #2
0
def test_get_destinations():
    logger.debug(
        os.environ.get('PYTEST_CURRENT_TEST').split(':')[-1].split(' ')[0])
    config = conf().cleaner
    cleaner = Cleaner(config)

    date = datetime.datetime.now() - datetime.timedelta(days=1)

    # first put a few destinations
    prefix = config["dest_path"] + date.strftime(DATE_FORMAT) + "/"
    put_key(config["url"], prefix + "EC1")
    put_key(config["url"], prefix + "FOO")
    put_key(config["url"], prefix + "FOO2")

    # retrieve destinations
    dests = cleaner.get_destinations(date)
    assert len(dests) == 3