コード例 #1
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]
コード例 #2
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]
コード例 #3
0
def test_purge_old_versions_latest_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")
    purge_old_versions()
    assert sort_versions(Version.query.all()) == [v1, v2]
コード例 #4
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]
コード例 #5
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
コード例 #6
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]
コード例 #7
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
コード例 #8
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]
コード例 #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_add_version_new_str():
    assert Project.query.all() == []
    add_version('FooBar', '1.0')
    p, = Project.query.all()
    assert p.name == 'foobar'
    v, = p.versions
    assert v.name == '1'
    assert v.display_name == '1.0'
    assert v.wheels == []
    assert p.latest_version == v
コード例 #12
0
def test_add_version_new_str():
    assert Project.query.all() == []
    add_version("FooBar", "1.0")
    (p, ) = Project.query.all()
    assert p.name == "foobar"
    (v, ) = p.versions
    assert v.name == "1"
    assert v.display_name == "1.0"
    assert v.wheels == []
    assert p.latest_version == v
コード例 #13
0
def test_get_version_project():
    assert Project.query.all() == []
    p = add_project("FooBar")
    add_version("FooBar", "1.0")
    for version in ["1", "1.0", "1.0.0"]:
        v = get_version(p, version)
        assert v.project == p
        assert v.name == "1"
        assert v.display_name == "1.0"
        assert v.wheels == []
    assert get_version(p, "2.0") is None
コード例 #14
0
def test_add_version_extant():
    assert Project.query.all() == []
    p = add_project('FooBar')
    v = add_version('FooBar', '1.0')
    u = add_version('FooBar', '1.0.0')
    assert v == u
    assert p.versions == [v]
    assert v.name == '1'
    assert v.display_name == '1.0'
    assert v.wheels == []
    assert p.latest_version == v
コード例 #15
0
def test_add_version_extant():
    assert Project.query.all() == []
    p = add_project("FooBar")
    v = add_version("FooBar", "1.0")
    u = add_version("FooBar", "1.0.0")
    assert v == u
    assert p.versions == [v]
    assert v.name == "1"
    assert v.display_name == "1.0"
    assert v.wheels == []
    assert p.latest_version == v
コード例 #16
0
def test_add_version_project():
    assert Project.query.all() == []
    p = add_project("FooBar")
    add_version(p, "1.0")
    (q, ) = Project.query.all()
    assert p == q
    (v, ) = p.versions
    assert v.name == "1"
    assert v.display_name == "1.0"
    assert v.wheels == []
    assert p.latest_version == v
コード例 #17
0
def test_get_version_project():
    assert Project.query.all() == []
    p = add_project('FooBar')
    add_version('FooBar', '1.0')
    for version in ['1', '1.0', '1.0.0']:
        v = get_version(p, version)
        assert v.project == p
        assert v.name == '1'
        assert v.display_name == '1.0'
        assert v.wheels == []
    assert get_version(p, '2.0') is None
コード例 #18
0
def test_add_version_project():
    assert Project.query.all() == []
    p = add_project('FooBar')
    add_version(p, '1.0')
    q, = Project.query.all()
    assert p == q
    v, = p.versions
    assert v.name == '1'
    assert v.display_name == '1.0'
    assert v.wheels == []
    assert p.latest_version == v
コード例 #19
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)]),
    ]
コード例 #20
0
def test_get_version_str():
    assert Project.query.all() == []
    add_project('FooBar')
    add_version('FooBar', '1.0')
    for project in ['foobar', 'FooBar', 'FOOBAR']:
        for version in ['1', '1.0', '1.0.0']:
            v = get_version(project, version)
            assert v.project.name == 'foobar'
            assert v.name == '1'
            assert v.display_name == '1.0'
            assert v.wheels == []
    assert get_version('foobar', '2.0') is None
    assert get_version('quux', '2.0') is None
コード例 #21
0
def test_get_version_str():
    assert Project.query.all() == []
    add_project("FooBar")
    add_version("FooBar", "1.0")
    for project in ["foobar", "FooBar", "FOOBAR"]:
        for version in ["1", "1.0", "1.0.0"]:
            v = get_version(project, version)
            assert v.project.name == "foobar"
            assert v.name == "1"
            assert v.display_name == "1.0"
            assert v.wheels == []
    assert get_version("foobar", "2.0") is None
    assert get_version("quux", "2.0") is None
コード例 #22
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]
コード例 #23
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
コード例 #24
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]
コード例 #25
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"])
コード例 #26
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]
コード例 #27
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]
コード例 #28
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() == []
コード例 #29
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() == []
コード例 #30
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() == []