def test_list_packages__all_packages(capfd, bucket_and_keys):
    """If no package is provided, all base names should be listed."""

    lister.list_package(bucket_and_keys[0], None)
    out, err = capfd.readouterr()
    assert not err
    assert "error-pkg\npackage-one\npackage-two" in out
def test_list_packages__specific(capfd, bucket_and_keys):
    """Verify the exact release is listed if requested."""

    parsed_pkg = parse_package("package_two==0.0.1")
    with mock.patch.object(lister, "print_versioned") as patched_print:
        lister.list_package(bucket_and_keys[0], parsed_pkg)

    patched_print.assert_called_once_with(
        [
            "package-two-0.0.1-py2.py3-none-any.whl",
            "package_two-0.0.1.tar.gz",
            "package-two-0.0.1-py2.7.egg",
        ],
        parsed_pkg,
    )
def test_list_packages__ranges(capfd, bucket_and_keys):
    """Ensure we can use gt/lt/ge/le type ranges for listing."""

    parsed_pkg = parse_package("package_one < 1.2.4")
    with mock.patch.object(lister, "print_versioned") as patched_print:
        lister.list_package(
            bucket_and_keys[0],
            parsed_pkg,
        )

    patched_print.assert_called_once_with(
        [
            "package-one-1.2.3-alpha1-py2.py3-none-any.whl",
            "package-one-1.2.3-py2.py3-none-any.whl",
        ],
        parsed_pkg,
    )