Skip to content

Commit

Permalink
[review] replace string values with references to fixture values
Browse files Browse the repository at this point in the history
Signed-off-by: Meret Behrens <meret.behrens@tngtech.com>
  • Loading branch information
meretp committed Apr 6, 2023
1 parent b2d0a0b commit 3cf8389
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 53 deletions.
8 changes: 4 additions & 4 deletions tests/spdx/writer/tagvalue/test_annotation_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ def test_annotation_writer():
handle = mock()
handle.write.assert_has_calls(
[
call("Annotator: Person: annotatorName (some@mail.com)\n"),
call(f"Annotator: Person: {annotation.annotator.name} ({annotation.annotator.email})\n"),
call("AnnotationDate: 2022-12-01T00:00:00Z\n"),
call("AnnotationType: REVIEW\n"),
call("SPDXREF: SPDXRef-File\n"),
call("AnnotationComment: annotationComment\n"),
call(f"AnnotationType: {annotation.annotation_type.name}\n"),
call(f"SPDXREF: {annotation.spdx_id}\n"),
call(f"AnnotationComment: {annotation.annotation_comment}\n"),
]
)
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ def test_extracted_licensing_info_writer():
handle = mock()
handle.write.assert_has_calls(
[
call("LicenseID: LicenseRef-1\n"),
call("ExtractedText: extractedText\n"),
call("LicenseName: licenseName\n"),
call("LicenseCrossReference: https://see.also\n"),
call("LicenseComment: licenseComment\n"),
call(f"LicenseID: {extracted_licensing_info.license_id}\n"),
call(f"ExtractedText: {extracted_licensing_info.extracted_text}\n"),
call(f"LicenseName: {extracted_licensing_info.license_name}\n"),
call(f"LicenseCrossReference: {extracted_licensing_info.cross_references[0]}\n"),
call(f"LicenseComment: {extracted_licensing_info.comment}\n"),
]
)
18 changes: 9 additions & 9 deletions tests/spdx/writer/tagvalue/test_file_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,19 @@ def test_file_writer():
handle.write.assert_has_calls(
[
call("## File Information\n"),
call("FileName: ./fileName.py\n"),
call("SPDXID: SPDXRef-File\n"),
call("FileType: TEXT\n"),
call(f"FileName: {spdx_file.name}\n"),
call(f"SPDXID: {spdx_file.spdx_id}\n"),
call(f"FileType: {spdx_file.file_types[0].name}\n"),
call("FileChecksum: SHA1: 71c4025dd9897b364f3ebbb42c484ff43d00791c\n"),
call("LicenseConcluded: MIT AND GPL-2.0-only\n"),
call("LicenseInfoInFile: MIT\n"),
call("LicenseInfoInFile: GPL-2.0-only\n"),
call("LicenseInfoInFile: NOASSERTION\n"),
call("LicenseComments: licenseComment\n"),
call("FileCopyrightText: copyrightText\n"),
call("FileComment: fileComment\n"),
call("FileNotice: fileNotice\n"),
call("FileContributor: fileContributor\n"),
call("FileAttributionText: fileAttributionText\n"),
call(f"LicenseComments: {spdx_file.license_comment}\n"),
call(f"FileCopyrightText: {spdx_file.copyright_text}\n"),
call(f"FileComment: {spdx_file.comment}\n"),
call(f"FileNotice: {spdx_file.notice}\n"),
call(f"FileContributor: {spdx_file.contributors[0]}\n"),
call(f"FileAttributionText: {spdx_file.attribution_texts[0]}\n"),
]
)
51 changes: 27 additions & 24 deletions tests/spdx/writer/tagvalue/test_package_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,32 +20,35 @@ def test_package_writer():
handle.write.assert_has_calls(
[
call("## Package Information\n"),
call("PackageName: packageName\n"),
call("SPDXID: SPDXRef-Package\n"),
call("PackageVersion: 12.2\n"),
call("PackageFileName: ./packageFileName\n"),
call("PackageSupplier: Person: supplierName (some@mail.com)\n"),
call("PackageOriginator: Person: originatorName (some@mail.com)\n"),
call("PackageDownloadLocation: https://download.com\n"),
call(f"PackageName: {package.name}\n"),
call(f"SPDXID: {package.spdx_id}\n"),
call(f"PackageVersion: {package.version}\n"),
call(f"PackageFileName: {package.file_name}\n"),
call(f"PackageSupplier: Person: {package.supplier.name} ({package.supplier.email})\n"),
call(f"PackageOriginator: Person: {package.originator.name} ({package.originator.email})\n"),
call(f"PackageDownloadLocation: {package.download_location}\n"),
call("FilesAnalyzed: True\n"),
call("PackageVerificationCode: 85ed0817af83a24ad8da68c2b5094de69833983c (excludes: ./exclude.py)\n"),
call(f"PackageVerificationCode: {package.verification_code.value} (excludes: ./exclude.py)\n"),
call("PackageChecksum: SHA1: 71c4025dd9897b364f3ebbb42c484ff43d00791c\n"),
call("PackageHomePage: https://homepage.com\n"),
call("PackageSourceInfo: sourceInfo\n"),
call("PackageLicenseConcluded: MIT AND GPL-2.0-only\n"),
call("PackageLicenseInfoFromFiles: MIT\n"),
call("PackageLicenseInfoFromFiles: GPL-2.0-only\n"),
call("PackageLicenseInfoFromFiles: NOASSERTION\n"),
call("PackageLicenseDeclared: MIT AND GPL-2.0-only\n"),
call("PackageLicenseComments: packageLicenseComment\n"),
call("PackageCopyrightText: packageCopyrightText\n"),
call("PackageSummary: packageSummary\n"),
call("PackageDescription: packageDescription\n"),
call("PackageComment: packageComment\n"),
call("ExternalRef: PACKAGE-MANAGER maven-central org.apache.tomcat:tomcat:9.0.0.M4\n"),
call("ExternalRefComment: externalPackageRefComment\n"),
call("PackageAttributionText: packageAttributionText\n"),
call("PrimaryPackagePurpose: SOURCE\n"),
call(f"PackageHomePage: {package.homepage}\n"),
call(f"PackageSourceInfo: {package.source_info}\n"),
call(f"PackageLicenseConcluded: {package.license_concluded}\n"),
call(f"PackageLicenseInfoFromFiles: {package.license_info_from_files[0]}\n"),
call(f"PackageLicenseInfoFromFiles: {package.license_info_from_files[1]}\n"),
call(f"PackageLicenseInfoFromFiles: {package.license_info_from_files[2]}\n"),
call(f"PackageLicenseDeclared: {package.license_declared}\n"),
call(f"PackageLicenseComments: {package.license_comment}\n"),
call(f"PackageCopyrightText: {package.copyright_text}\n"),
call(f"PackageSummary: {package.summary}\n"),
call(f"PackageDescription: {package.description}\n"),
call(f"PackageComment: {package.comment}\n"),
call(
f"ExternalRef: PACKAGE-MANAGER {package.external_references[0].reference_type} "
f"{package.external_references[0].locator}\n"
),
call(f"ExternalRefComment: {package.external_references[0].comment}\n"),
call(f"PackageAttributionText: {package.attribution_texts[0]}\n"),
call(f"PrimaryPackagePurpose: {package.primary_package_purpose.name}\n"),
call("ReleaseDate: 2022-12-01T00:00:00Z\n"),
call("BuiltDate: 2022-12-02T00:00:00Z\n"),
call("ValidUntilDate: 2022-12-03T00:00:00Z\n"),
Expand Down
22 changes: 11 additions & 11 deletions tests/spdx/writer/tagvalue/test_snippet_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,18 @@ def test_snippet_writer():
handle.write.assert_has_calls(
[
call("## Snippet Information\n"),
call("SnippetSPDXID: SPDXRef-Snippet\n"),
call("SnippetFromFileSPDXID: SPDXRef-File\n"),
call(f"SnippetSPDXID: {snippet.spdx_id}\n"),
call(f"SnippetFromFileSPDXID: {snippet.file_spdx_id}\n"),
call("SnippetByteRange: 1:2\n"),
call("SnippetLineRange: 3:4\n"),
call("SnippetLicenseConcluded: MIT AND GPL-2.0-only\n"),
call("LicenseInfoInSnippet: MIT\n"),
call("LicenseInfoInSnippet: GPL-2.0-only\n"),
call("LicenseInfoInSnippet: NONE\n"),
call("SnippetLicenseComments: snippetLicenseComment\n"),
call("SnippetCopyrightText: licenseCopyrightText\n"),
call("SnippetComment: snippetComment\n"),
call("SnippetName: snippetName\n"),
call("SnippetAttributionText: snippetAttributionText\n"),
call(f"SnippetLicenseConcluded: {snippet.license_concluded}\n"),
call(f"LicenseInfoInSnippet: {snippet.license_info_in_snippet[0]}\n"),
call(f"LicenseInfoInSnippet: {snippet.license_info_in_snippet[1]}\n"),
call(f"LicenseInfoInSnippet: {snippet.license_info_in_snippet[2]}\n"),
call(f"SnippetLicenseComments: {snippet.license_comment}\n"),
call(f"SnippetCopyrightText: {snippet.copyright_text}\n"),
call(f"SnippetComment: {snippet.comment}\n"),
call(f"SnippetName: {snippet.name}\n"),
call(f"SnippetAttributionText: {snippet.attribution_texts[0]}\n"),
]
)

0 comments on commit 3cf8389

Please sign in to comment.