Exemplo n.º 1
0
def test_url_summary(mock_packages):
    """Test the URL summary command."""
    # test url_summary, the internal function that does the work
    (total_urls, correct_names, correct_versions, name_count_dict,
     version_count_dict) = url_summary(None)

    assert (0 < correct_names <= sum(name_count_dict.values()) <= total_urls)
    assert (0 < correct_versions <= sum(version_count_dict.values()) <=
            total_urls)

    # make sure it agrees with the actual command.
    out = url('summary')
    out_total_urls = int(re.search(r'Total URLs found:\s*(\d+)', out).group(1))
    assert out_total_urls == total_urls

    out_correct_names = int(
        re.search(r'Names correctly parsed:\s*(\d+)', out).group(1))
    assert out_correct_names == correct_names

    out_correct_versions = int(
        re.search(r'Versions correctly parsed:\s*(\d+)', out).group(1))
    assert out_correct_versions == correct_versions
Exemplo n.º 2
0
Arquivo: url.py Projeto: LLNL/spack
def test_url_summary():
    """Test the URL summary command."""
    # test url_summary, the internal function that does the work
    (total_urls, correct_names, correct_versions,
     name_count_dict, version_count_dict) = url_summary(None)

    assert (0 < correct_names <=
            sum(name_count_dict.values()) <= total_urls)
    assert (0 < correct_versions <=
            sum(version_count_dict.values()) <= total_urls)

    # make sure it agrees with the actual command.
    out = url('summary')
    out_total_urls = int(
        re.search(r'Total URLs found:\s*(\d+)', out).group(1))
    assert out_total_urls == total_urls

    out_correct_names = int(
        re.search(r'Names correctly parsed:\s*(\d+)', out).group(1))
    assert out_correct_names == correct_names

    out_correct_versions = int(
        re.search(r'Versions correctly parsed:\s*(\d+)', out).group(1))
    assert out_correct_versions == correct_versions