diff --git a/src/spdx_tools/spdx3/writer/console/element_writer.py b/src/spdx_tools/spdx3/writer/console/element_writer.py index 61eb72ecd..12329e172 100644 --- a/src/spdx_tools/spdx3/writer/console/element_writer.py +++ b/src/spdx_tools/spdx3/writer/console/element_writer.py @@ -16,7 +16,7 @@ def write_element_properties(element: Element, text_output: TextIO): write_value("SPDXID", element.spdx_id, text_output) write_value("name", element.name, text_output) if element.creation_info: - write_creation_info(element.creation_info, text_output, True) + write_creation_info(element.creation_info, text_output, False) write_value("summary", element.summary, text_output) write_value("description", element.description, text_output) write_value("comment", element.comment, text_output) diff --git a/tests/spdx3/writer/tag_value/test_write_document.py b/tests/spdx3/writer/tag_value/test_write_document.py new file mode 100644 index 000000000..47835f286 --- /dev/null +++ b/tests/spdx3/writer/tag_value/test_write_document.py @@ -0,0 +1,41 @@ +import io +from datetime import datetime + +from semantic_version import Version + +from spdx_tools.spdx3.model import CreationInfo, SpdxDocument, \ + ProfileIdentifierType +from spdx_tools.spdx3.writer.console.spdx_document_writer import \ + write_spdx_document + + +def test_render_creation_info(): + fake_datetime = datetime(year=2024, month=1, day=1) + spec_version = Version("3.0.0") + creation_info = CreationInfo( + spec_version=spec_version, + created=fake_datetime, + created_by=[], + profile=[ProfileIdentifierType.SOFTWARE], + ) + spdx_document = SpdxDocument( + spdx_id="SPDXRef-FOO", + name=f"BAR", + element=[], + root_element=[], + creation_info=creation_info, + ) + output_str = io.StringIO() + write_spdx_document(spdx_document, text_output=output_str) + + assert output_str.getvalue() == """\ +## SPDX Document +SPDXID: SPDXRef-FOO +name: BAR +# Creation Information +specVersion: 3.0.0 +created: 2024-01-01T00:00:00Z +profile: SOFTWARE +data license: CC0-1.0 +elements: +"""