コード例 #1
0
def test_iterqueue_multiwheel_version():
    assert iterqueue() == []
    p = add_project("FooBar")
    v1 = add_version(p, "1.0")
    whl1 = add_wheel(version=v1, **FOOBAR_1_WHEEL)
    whl1b = add_wheel(version=v1, **FOOBAR_1_WHEEL2)
    assert sort_wheels(iterqueue()) == [whl1b, whl1]
コード例 #2
0
def test_purge_old_versions_latest_has_wheel_plus_wheel():
    v1 = add_version("foobar", "1.0")
    add_wheel(version=v1, **FOOBAR_1_WHEEL)
    v2 = add_version("foobar", "2.0")
    add_wheel(version=v2, **FOOBAR_2_WHEEL)
    purge_old_versions()
    assert Version.query.all() == [v2]
コード例 #3
0
def test_add_wheel_extant():
    """
    Add two wheels with the same project, version, & filename and assert that
    only the first one exists
    """
    assert Wheel.query.all() == []
    p = add_project("FooBar")
    v1 = add_version(p, "1.0")
    whl1 = add_wheel(version=v1, **FOOBAR_1_WHEEL)
    assert Wheel.query.all() == [whl1]
    add_wheel(
        version=v1,
        filename="FooBar-1.0-py3-none-any.whl",
        url="http://example.org/FooBar-1.0-py3-none-any.whl",
        size=69105,
        md5="1234567890abcdef1234567890abcdef",
        sha256=
        "1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef",
        uploaded="2018-09-26T15:14:33.987654Z",
    )
    (whl, ) = Wheel.query.all()
    assert v1.wheels == [whl1]
    assert whl.url == FOOBAR_1_WHEEL["url"]
    assert whl.size == FOOBAR_1_WHEEL["size"]
    assert whl.md5 == FOOBAR_1_WHEEL["md5"]
    assert whl.sha256 == FOOBAR_1_WHEEL["sha256"]
    assert whl.uploaded == parse_timestamp(FOOBAR_1_WHEEL["uploaded"])
コード例 #4
0
def test_purge_old_versions_latest_plus_wheel_plus_mid():
    v1 = add_version('foobar', '1.0')
    add_wheel(version=v1, **FOOBAR_1_WHEEL)
    add_version('foobar', '1.5')
    v2 = add_version('foobar', '2.0')
    purge_old_versions()
    assert sort_versions(Version.query.all()) == [v1, v2]
コード例 #5
0
def test_purge_old_versions_latest_plus_wheel_plus_mid():
    v1 = add_version("foobar", "1.0")
    add_wheel(version=v1, **FOOBAR_1_WHEEL)
    add_version("foobar", "1.5")
    v2 = add_version("foobar", "2.0")
    purge_old_versions()
    assert sort_versions(Version.query.all()) == [v1, v2]
コード例 #6
0
def test_iterqueue_multiwheel_version_some_error():
    assert iterqueue() == []
    p = add_project("FooBar")
    v1 = add_version(p, "1.0")
    whl1 = add_wheel(version=v1, **FOOBAR_1_WHEEL)
    whl1.add_error("Testing")
    whl1b = add_wheel(version=v1, **FOOBAR_1_WHEEL2)
    assert iterqueue() == [whl1b]
コード例 #7
0
def test_iterqueue_multiwheel_version_some_data():
    assert iterqueue() == []
    p = add_project("FooBar")
    v1 = add_version(p, "1.0")
    whl1 = add_wheel(version=v1, **FOOBAR_1_WHEEL)
    whl1.set_data(FOOBAR_1_DATA)
    whl1b = add_wheel(version=v1, **FOOBAR_1_WHEEL2)
    assert iterqueue() == [whl1b]
コード例 #8
0
def test_preferred_wheel_two_wheels_nodata():
    p = add_project("FooBar")
    v1 = add_version(p, "1.0")
    add_wheel(version=v1, **FOOBAR_1_WHEEL)
    v2 = add_version(p, "2.0")
    whl2 = add_wheel(version=v2, **FOOBAR_2_WHEEL)
    assert p.preferred_wheel is None
    assert p.best_wheel == whl2
コード例 #9
0
def test_preferred_wheel_higher_data():
    p = add_project("FooBar")
    v1 = add_version(p, "1.0")
    add_wheel(version=v1, **FOOBAR_1_WHEEL)
    v2 = add_version(p, "2.0")
    whl2 = add_wheel(version=v2, **FOOBAR_2_WHEEL)
    whl2.set_data(FOOBAR_2_DATA)
    assert p.preferred_wheel == whl2
    assert p.best_wheel == whl2
コード例 #10
0
def test_iterqueue_skip_non_latest():
    assert iterqueue() == []
    p = add_project("FooBar")
    v1 = add_version(p, "1.0")
    whl1 = add_wheel(version=v1, **FOOBAR_1_WHEEL)
    assert iterqueue() == [whl1]
    v2 = add_version(p, "2.0")
    whl2 = add_wheel(version=v2, **FOOBAR_2_WHEEL)
    assert iterqueue() == [whl2]
コード例 #11
0
def test_iterqueue_multiwheel_version_some_data_other_error():
    assert iterqueue() == []
    p = add_project('FooBar')
    v1 = add_version(p, '1.0')
    whl1 = add_wheel(version=v1, **FOOBAR_1_WHEEL)
    whl1.set_data(FOOBAR_1_DATA)
    whl1b = add_wheel(version=v1, **FOOBAR_1_WHEEL2)
    whl1b.add_error('Testing')
    assert iterqueue() == []
コード例 #12
0
def test_preferred_wheel_lower_data():
    p = add_project('FooBar')
    v1 = add_version(p, '1.0')
    whl1 = add_wheel(version=v1, **FOOBAR_1_WHEEL)
    whl1.set_data(FOOBAR_1_DATA)
    v2 = add_version(p, '2.0')
    add_wheel(version=v2, **FOOBAR_2_WHEEL)
    assert p.preferred_wheel == whl1
    assert p.best_wheel == whl1
コード例 #13
0
def test_purge_old_versions_latest_plus_wheel_plus_data():
    v1 = add_version('foobar', '1.0')
    whl1 = add_wheel(version=v1, **FOOBAR_1_WHEEL)
    whl1.set_data(FOOBAR_1_DATA)
    v2 = add_version('foobar', '2.0')
    add_wheel(version=v2, **FOOBAR_2_WHEEL)
    v3 = add_version('foobar', '3.0')
    purge_old_versions()
    assert sort_versions(Version.query.all()) == [v1, v2, v3]
コード例 #14
0
def test_purge_old_versions_latest_has_data_plus_data():
    v1 = add_version("foobar", "1.0")
    whl1 = add_wheel(version=v1, **FOOBAR_1_WHEEL)
    whl1.set_data(FOOBAR_1_DATA)
    v2 = add_version("foobar", "2.0")
    whl2 = add_wheel(version=v2, **FOOBAR_2_WHEEL)
    whl2.set_data(FOOBAR_2_DATA)
    purge_old_versions()
    assert sort_versions(Version.query.all()) == [v2]
コード例 #15
0
def test_iterqueue_skip_large():
    assert iterqueue() == []
    p = add_project("FooBar")
    v1 = add_version(p, "1.0")
    whl1 = add_wheel(version=v1, **FOOBAR_1_WHEEL)
    whl1b = add_wheel(version=v1, **FOOBAR_1_WHEEL2)
    if whl1.size < whl1b.size:
        assert iterqueue(max_wheel_size=whl1.size) == [whl1]
    else:
        assert iterqueue(max_wheel_size=whl1b.size) == [whl1b]
コード例 #16
0
def test_purge_old_versions_latest_plus_wheel_plus_data_plus_mid():
    v1 = add_version("foobar", "1.0")
    whl1 = add_wheel(version=v1, **FOOBAR_1_WHEEL)
    whl1.set_data(FOOBAR_1_DATA)
    add_version("foobar", "1.5")
    v2 = add_version("foobar", "2.0")
    add_wheel(version=v2, **FOOBAR_2_WHEEL)
    add_version("foobar", "2.5")
    v3 = add_version("foobar", "3.0")
    purge_old_versions()
    assert sort_versions(Version.query.all()) == [v1, v2, v3]
コード例 #17
0
def test_versions_wheels_grid():
    p = add_project("FooBar")
    v1 = add_version(p, "1.0")
    whl1 = add_wheel(version=v1, **FOOBAR_1_WHEEL)
    whl1.set_data(FOOBAR_1_DATA)
    whl1b = add_wheel(version=v1, **FOOBAR_1_WHEEL2)
    v2 = add_version(p, "2.0")
    whl2 = add_wheel(version=v2, **FOOBAR_2_WHEEL)
    assert p.versions_wheels_grid() == [
        ("2.0", [(whl2, False)]),
        ("1.0", [(whl1, True), (whl1b, False)]),
    ]
コード例 #18
0
def test_remove_version():
    assert Project.query.all() == []
    p = add_project("FooBar")
    v1 = add_version(p, "1.0")
    whl1 = add_wheel(version=v1, **FOOBAR_1_WHEEL)
    v2 = add_version(p, "2.0")
    add_wheel(version=v2, **FOOBAR_2_WHEEL)
    remove_version("FooBar", "2.0")
    assert Project.query.all() == [p]
    assert get_version("foobar", "1.0") is not None
    assert get_version("foobar", "2.0") is None
    assert Version.query.all() == [v1]
    assert p.latest_version == v1
    assert Wheel.query.all() == [whl1]
    assert p.has_wheels
コード例 #19
0
def test_add_wheel():
    assert Wheel.query.all() == []
    p = add_project("FooBar")
    assert not p.has_wheels
    v1 = add_version(p, "1.0")
    whl1 = add_wheel(version=v1, **FOOBAR_1_WHEEL)
    assert Wheel.query.all() == [whl1]
    assert p.has_wheels
    v2 = add_version(p, "2.0")
    whl2 = add_wheel(version=v2, **FOOBAR_2_WHEEL)
    assert sort_wheels(Wheel.query.all()) == [whl1, whl2]
    assert v1.wheels == [whl1]
    assert v2.wheels == [whl2]
    assert get_version(p, "1.0").wheels == [whl1]
    assert get_version(p, "2.0").wheels == [whl2]
コード例 #20
0
def test_iterqueue_skip_error():
    assert iterqueue() == []
    p = add_project('FooBar')
    v1 = add_version(p, '1.0')
    whl1 = add_wheel(version=v1, **FOOBAR_1_WHEEL)
    assert iterqueue() == [whl1]
    whl1.add_error('Testing')
    assert iterqueue() == []
コード例 #21
0
def test_iterqueue_ignore_empty_latest():
    assert iterqueue() == []
    p = add_project("FooBar")
    v1 = add_version(p, "1.0")
    whl1 = add_wheel(version=v1, **FOOBAR_1_WHEEL)
    assert iterqueue() == [whl1]
    add_version(p, "2.0")
    assert iterqueue() == [whl1]
コード例 #22
0
def test_iterqueue_skip_error():
    assert iterqueue() == []
    p = add_project("FooBar")
    v1 = add_version(p, "1.0")
    whl1 = add_wheel(version=v1, **FOOBAR_1_WHEEL)
    assert iterqueue() == [whl1]
    whl1.add_error("Testing")
    assert iterqueue() == []
コード例 #23
0
def test_iterqueue_skip_data():
    assert iterqueue() == []
    p = add_project("FooBar")
    v1 = add_version(p, "1.0")
    whl1 = add_wheel(version=v1, **FOOBAR_1_WHEEL)
    assert iterqueue() == [whl1]
    whl1.set_data(FOOBAR_1_DATA)
    assert iterqueue() == []
コード例 #24
0
def test_remove_wheel():
    assert Wheel.query.all() == []
    p = add_project("FooBar")
    v1 = add_version(p, "1.0")
    whl1 = add_wheel(version=v1, **FOOBAR_1_WHEEL)
    assert Wheel.query.all() == [whl1]
    remove_wheel("FooBar-1.0-py3-none-any.whl")
    assert Wheel.query.all() == []
    assert not p.has_wheels
コード例 #25
0
def test_remove_project():
    assert Project.query.all() == []
    p = add_project("FooBar")
    v1 = add_version(p, "1.0")
    add_wheel(version=v1, **FOOBAR_1_WHEEL)
    v2 = add_version(p, "2.0")
    add_wheel(version=v2, **FOOBAR_2_WHEEL)
    q = add_project("quux")
    v3 = add_version(q, "1.5")
    whl3 = add_wheel(version=v3, **QUUX_1_5_WHEEL)
    remove_project("FooBar")
    assert Project.query.all() in ([p, q], [q, p])
    assert Version.query.all() == [v3]
    assert get_version("foobar", "1.0") is None
    assert get_version("foobar", "2.0") is None
    assert Wheel.query.all() == [whl3]
    assert p.latest_version is None
    assert not p.has_wheels
コード例 #26
0
def test_remove_project():
    assert Project.query.all() == []
    p = add_project('FooBar')
    v1 = add_version(p, '1.0')
    add_wheel(version=v1, **FOOBAR_1_WHEEL)
    v2 = add_version(p, '2.0')
    add_wheel(version=v2, **FOOBAR_2_WHEEL)
    q = add_project('quux')
    v3 = add_version(q, '1.5')
    whl3 = add_wheel(version=v3, **QUUX_1_5_WHEEL)
    remove_project('FooBar')
    assert Project.query.all() in ([p, q], [q, p])
    assert Version.query.all() == [v3]
    assert get_version('foobar', '1.0') is None
    assert get_version('foobar', '2.0') is None
    assert Wheel.query.all() == [whl3]
    assert p.latest_version is None
    assert not p.has_wheels
コード例 #27
0
def test_set_data_with_dependency():
    v1 = add_version("foobar", "1.0")
    whl1 = add_wheel(version=v1, **FOOBAR_1_WHEEL)
    whl1.set_data({
        "project": "FooBar",
        "version": "1.0",
        "valid": True,
        "dist_info": {},
        "derived": {
            "dependencies": ["glarch"],
            "keywords": [],
            "modules": [],
        },
    })
    p = get_project("glarch")
    assert whl1.data.dependencies == [p]
コード例 #28
0
def test_purge_old_versions_latest_has_wheel_plus_one():
    add_version('foobar', '1.0')
    v2 = add_version('foobar', '2.0')
    add_wheel(version=v2, **FOOBAR_2_WHEEL)
    purge_old_versions()
    assert Version.query.all() == [v2]
コード例 #29
0
def test_purge_old_versions_latest_has_data():
    v1 = add_version('foobar', '1.0')
    whl1 = add_wheel(version=v1, **FOOBAR_1_WHEEL)
    whl1.set_data(FOOBAR_1_DATA)
    purge_old_versions()
    assert sort_versions(Version.query.all()) == [v1]