Пример #1
0
def test_fix_broken_snapshot_references(library):
    library.write("cherry", "blob")
    one_day_ago = time.time() - (3600 * 24.) - 10  # make sure we are a few seconds before 24 hours
    with patch('time.time', return_value=one_day_ago):
        library.snapshot("snappy")
    library._snapshots.delete_one({"name": "snappy"})

    mpv.prune_versions(library, ["cherry"], 10)

    assert library._versions.find_one({"symbol": "cherry"}).get("parent", []) == []
Пример #2
0
def test_keep_recent_snapshots(library):
    library.write("cherry", "blob")
    half_a_day_ago = time.time() - (3600 * 12.)
    with patch('time.time', return_value=half_a_day_ago):
        library.snapshot("snappy")
    library._snapshots.delete_one({"name": "snappy"})

    mpv.prune_versions(library, ["cherry"], 10)

    assert len(library._versions.find_one({"symbol": "cherry"}).get("parent", [])) == 1
Пример #3
0
def test_keep_only_one_version(library):
    library.write("cherry", "blob")
    library.write("cherry", "blob")
    one_day_ago = time.time() - (3600 * 24.) - 10  # make sure we are a few seconds before 24 hours
    with patch('time.time', return_value=one_day_ago):
        library.snapshot("snappy")
    library._snapshots.delete_one({"name": "snappy"})

    mpv.prune_versions(library, ["cherry"], 0)

    assert len(list(library._versions.find({"symbol": "cherry"}))) == 1
Пример #4
0
def test_keep_only_one_version(library):
    library.write("cherry", "blob")
    library.write("cherry", "blob")
    one_day_ago = time.time() - (
        3600 * 24.) - 10  # make sure we are a few seconds before 24 hours
    with patch('time.time', return_value=one_day_ago):
        library.snapshot("snappy")
    library._snapshots.delete_one({"name": "snappy"})

    mpv.prune_versions(library, ["cherry"], 0)

    assert len(list(library._versions.find({"symbol": "cherry"}))) == 1
Пример #5
0
def test_fix_broken_snapshot_references(library):
    library.write("cherry", "blob")
    one_day_ago = time.time() - (
        3600 * 24.) - 10  # make sure we are a few seconds before 24 hours
    with patch('time.time', return_value=one_day_ago):
        library.snapshot("snappy")
    library._snapshots.delete_one({"name": "snappy"})

    mpv.prune_versions(library, ["cherry"], 10)

    assert library._versions.find_one({
        "symbol": "cherry"
    }).get("parent", []) == []
Пример #6
0
def test_keep_recent_snapshots(library):
    library.write("cherry", "blob")
    half_a_day_ago = time.time() - (3600 * 12.)
    with patch('time.time', return_value=half_a_day_ago):
        library.snapshot("snappy")
    library._snapshots.delete_one({"name": "snappy"})

    mpv.prune_versions(library, ["cherry"], 10)

    assert len(
        library._versions.find_one({
            "symbol": "cherry"
        }).get("parent", [])) == 1