Skip to content

Commit

Permalink
spdx3: element_writer: unindent creation information
Browse files Browse the repository at this point in the history
Signed-off-by: Stanislav Pankevich <[email protected]>
  • Loading branch information
stanislaw committed Jan 9, 2024
1 parent 8050fd9 commit cc2943d
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/spdx_tools/spdx3/writer/console/element_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
41 changes: 41 additions & 0 deletions tests/spdx3/writer/tag_value/test_write_document.py
Original file line number Diff line number Diff line change
@@ -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:
"""

0 comments on commit cc2943d

Please sign in to comment.