Skip to content

Commit

Permalink
Merge branch 'main' into issue-775-catch-json-decode-error
Browse files Browse the repository at this point in the history
  • Loading branch information
maxhbr authored Mar 22, 2024
2 parents 92f6a4a + 1e3031c commit fcaba64
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/spdx_tools/spdx/parser/tagvalue/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,7 @@ def p_snippet_range(self, p):

# parsing methods for annotation

@grammar_rule("annotator : ANNOTATOR PERSON_VALUE\n| TOOL_VALUE\n| ORGANIZATION_VALUE")
@grammar_rule("annotator : ANNOTATOR PERSON_VALUE\n| ANNOTATOR TOOL_VALUE\n| ANNOTATOR ORGANIZATION_VALUE")
def p_annotator(self, p):
self.initialize_new_current_element(Annotation)
set_value(p, self.current_element, method_to_apply=ActorParser.parse_actor)
Expand Down
1 change: 1 addition & 0 deletions src/spdx_tools/spdx3/model/software/software_purpose.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,6 @@ class SoftwarePurpose(Enum):
OPERATING_SYSTEM = auto()
OTHER = auto()
PATCH = auto()
REQUIREMENT = auto()
SOURCE = auto()
TEST = auto()
22 changes: 22 additions & 0 deletions tests/spdx/parser/tagvalue/test_annotation_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,28 @@ def test_parse_annotation():
assert annotation.spdx_id == DOCUMENT_SPDX_ID


def test_parse_annotation_with_organization_as_annotator():
parser = Parser()
annotation_str = "\n".join(
[
"Annotator: Organization: some-organization",
"AnnotationDate: 2010-01-29T18:30:22Z",
"AnnotationComment: <text>Document level annotation</text>",
"AnnotationType: OTHER",
f"SPDXREF: {DOCUMENT_SPDX_ID}",
]
)
document = parser.parse("\n".join([DOCUMENT_STR, annotation_str]))
assert document is not None
assert len(document.annotations) == 1
annotation = document.annotations[0]
assert annotation.annotator.name == "some-organization"
assert annotation.annotation_date == datetime(2010, 1, 29, 18, 30, 22)
assert annotation.annotation_comment == "Document level annotation"
assert annotation.annotation_type == AnnotationType.OTHER
assert annotation.spdx_id == DOCUMENT_SPDX_ID


@pytest.mark.parametrize(
"annotation_str, expected_message",
[
Expand Down

0 comments on commit fcaba64

Please sign in to comment.