Esempio n. 1
0
def test_generate_file_report_file_bad_license(fake_repository):
    """Simple generate test with a bad license."""
    (fake_repository / "foo.py").write_text("SPDX"
                                            "-License-Identifier: fakelicense")
    project = Project(fake_repository)
    result = FileReport.generate(project, "foo.py")

    assert result.file_report.spdxfile.copyright == ""
    assert result.bad_licenses == {"fakelicense"}
    assert not result.missing_licenses
Esempio n. 2
0
def test_generate_file_report_file_from_different_cwd(fake_repository):
    """Another simple generate test, but from a different CWD."""
    os.chdir("/")
    project = Project(fake_repository)
    result = FileReport.generate(project,
                                 fake_repository / "src/source_code.py")
    assert result.spdxfile.licenses_in_file == ["GPL-3.0-or-later"]
    assert result.spdxfile.copyright == "SPDX-FileCopyrightText: 2017 Mary Sue"
    assert not result.bad_licenses
    assert not result.missing_licenses
Esempio n. 3
0
def test_generate_file_report_file_simple(fake_repository):
    """An extremely simple generate test, just to see if the function doesn't
    crash.
    """
    project = Project(fake_repository)
    result = FileReport.generate(project, "src/source_code.py")
    assert result.spdxfile.licenses_in_file == ["GPL-3.0-or-later"]
    assert result.spdxfile.copyright == "SPDX-FileCopyrightText: 2017 Mary Sue"
    assert not result.bad_licenses
    assert not result.missing_licenses
Esempio n. 4
0
def test_generate_file_report_exception(fake_repository):
    """Simple generate test to test if the exception is detected."""
    project = Project(fake_repository)
    result = FileReport.generate(project, "src/exception.py")
    assert set(result.file_report.spdxfile.licenses_in_file) == {
        License.from_identifier("GPL-3.0-or-later"),
        License.from_identifier("Autoconf-exception-3.0"),
    }
    assert result.file_report.spdxfile.copyright == "2017 Mary Sue"
    assert not result.bad_licenses
    assert not result.missing_licenses
Esempio n. 5
0
def test_generate_file_report_exception(fake_repository):
    """Simple generate test to test if the exception is detected."""
    project = Project(fake_repository)
    result = FileReport.generate(project, "src/exception.py")
    assert set(result.spdxfile.licenses_in_file) == {
        "GPL-3.0-or-later",
        "Autoconf-exception-3.0",
    }
    assert result.spdxfile.copyright == "SPDX-FileCopyrightText: 2017 Jane Doe"
    assert not result.bad_licenses
    assert not result.missing_licenses
Esempio n. 6
0
def test_generate_file_report_license_contains_plus(fake_repository):
    """Given a license expression akin to Apache-1.0+, LICENSES/Apache-1.0.txt
    should be an appropriate license file.
    """
    (fake_repository / "foo.py").write_text("SPDX"
                                            "-License-Identifier: Apache-1.0+")
    (fake_repository / "LICENSES/Apache-1.0.txt").touch()
    project = Project(fake_repository)
    result = FileReport.generate(project, "foo.py")

    assert result.spdxfile.copyright == ""
    assert not result.bad_licenses
    assert not result.missing_licenses