-
Notifications
You must be signed in to change notification settings - Fork 134
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
spdx3: element_writer: unindent creation information
Signed-off-by: Stanislav Pankevich <[email protected]>
- Loading branch information
Showing
2 changed files
with
42 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: | ||
""" |