def test_extract_licenses():
    """Test the function extract_licenses()."""
    # TODO: reduce cyclomatic complexity
    # make sure the LRU cache is clear
    get_license_synonyms.cache.clear()
    get_license_synonyms()

    # text/string mode
    with open("/bayesian/tests/data/licenses/licenses.txt") as fin:
        result = extract_licenses([fin])
        _check_extracted_license(result, "bsd-new")

    # binary mode
    with open("/bayesian/tests/data/licenses/licenses.txt", "rb") as fin:
        result = extract_licenses([fin])
        _check_extracted_license(result, "bsd-new")

    # text/string mode
    with open("/bayesian/tests/data/licenses/licenses2.txt") as fin:
        result = extract_licenses([fin])
        _check_extracted_license(result, "gplv2")

    # binary mode
    with open("/bayesian/tests/data/licenses/licenses2.txt", "rb") as fin:
        result = extract_licenses([fin])
        _check_extracted_license(result, "gplv2")
Beispiel #2
0
def test_extract_licenses(_mocked_object):
    """Test the function extract_licenses()."""
    # TODO: reduce cyclomatic complexity
    # make sure the LRU cache is clear
    get_license_synonyms.cache.clear()
    get_license_synonyms()

    # text/string mode
    with open("/bayesian/tests/data/licenses/licenses.txt") as fin:
        result = extract_licenses([fin])
        assert result
        assert result[1] == "bsd-new"

    # binary mode
    with open("/bayesian/tests/data/licenses/licenses.txt", "rb") as fin:
        result = extract_licenses([fin])
        assert result
        assert result[1] == "bsd-new"

    # text/string mode
    with open("/bayesian/tests/data/licenses/licenses2.txt") as fin:
        result = extract_licenses([fin])
        assert result
        assert result[1] == "gplv2"

    # binary mode
    with open("/bayesian/tests/data/licenses/licenses2.txt", "rb") as fin:
        result = extract_licenses([fin])
        assert result
        assert result[1] == "gplv2"
def test_extract_licenses_wrong_file():
    """Test the function extract_licenses()."""
    # make sure the LRU cache is clear
    get_license_synonyms.cache.clear()
    get_license_synonyms()
    result = extract_licenses(["this-is-not-a-file"])
    assert not result
def test_extract_licenses_no_synonyms(mocked_function):
    """Test the function extract_licenses()."""
    # make sure the LRU cache is clear
    get_license_synonyms.cache.clear()
    result = extract_licenses([])
    assert not result
    assert mocked_function.called