Skip to content

Commit

Permalink
[issue-788] Improve test
Browse files Browse the repository at this point in the history
Signed-off-by: Meret Behrens <[email protected]>
  • Loading branch information
meretp committed Aug 16, 2024
1 parent 422e6e0 commit 1ab91dd
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 21 deletions.
20 changes: 0 additions & 20 deletions tests/spdx/parser/tagvalue/test_package_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,26 +83,6 @@ def test_parse_package():
assert package.valid_until_date == datetime(2022, 1, 1, 12)


def test_parse_package_with_no_assertion_as_source_info():
parser = Parser()
package_str = "\n".join(
[
"PackageName: Test",
"SPDXID: SPDXRef-Package",
"PackageDownloadLocation: http://example.com/test",
"FilesAnalyzed: true",
"PackageSummary: <text>Test package</text>",
"PackageSourceInfo: NOASSERTION",
]
)
document = parser.parse("\n".join([DOCUMENT_STR, package_str]))
assert document is not None
package = document.packages[0]
assert package.name == "Test"
assert package.spdx_id == "SPDXRef-Package"
assert package.source_info == "NOASSERTION"


@pytest.mark.parametrize(
"package_str, expected_message",
[
Expand Down
28 changes: 27 additions & 1 deletion tests/spdx/parser/tagvalue/test_tag_value_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import pytest

from spdx_tools.spdx.constants import DOCUMENT_SPDX_ID
from spdx_tools.spdx.model import Relationship, RelationshipType
from spdx_tools.spdx.model import Relationship, RelationshipType, SpdxNoAssertion, SpdxNone
from spdx_tools.spdx.parser.error import SPDXParsingError
from spdx_tools.spdx.parser.tagvalue.parser import Parser
from tests.spdx.parser.tagvalue.test_creation_info_parser import DOCUMENT_STR
Expand Down Expand Up @@ -136,3 +136,29 @@ def test_faulty_license_expression():
"and numbers, underscore, dot, colon or hyphen signs and spaces: "
"'LicenseRef-foo/foo'\"]",
]


def test_parse_none_or_no_assertion_as_text():
parser = Parser()
document_str = "\n".join(
[
DOCUMENT_STR,
"PackageName: Test",
"SPDXID: SPDXRef-Package",
"PackageDownloadLocation: http://example.com/test",
"FilesAnalyzed: true",
"PackageSummary: NONE",
"PackageSourceInfo: NOASSERTION",
"PackageLicenseConcluded: NONE",
"PackageLicenseDeclared: NOASSERTION",
]
)
document = parser.parse(document_str)
assert document is not None
package = document.packages[0]
assert package.name == "Test"
assert package.spdx_id == "SPDXRef-Package"
assert package.source_info == "NOASSERTION"
assert package.summary == "NONE"
assert package.license_concluded == SpdxNone()
assert package.license_declared == SpdxNoAssertion()

0 comments on commit 1ab91dd

Please sign in to comment.