File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1818# Convert original document to an SPDX3 payload
1919spdx3_payload = bump_spdx_document (spdx2_document )
2020# Write SPDX3 payload in json-ld format
21- write_payload (spdx3_payload , "spdx2_to_3.json " )
21+ write_payload (spdx3_payload , "spdx2_to_3" )
Original file line number Diff line number Diff line change 1+ # SPDX-FileCopyrightText: 2023 spdx contributors
2+ #
3+ # SPDX-License-Identifier: Apache-2.0
4+ import os .path
5+ import runpy
6+
7+ import pytest
8+
9+
10+ @pytest .fixture
11+ def cleanup_output_files ():
12+ yield
13+
14+ files_to_delete = ["spdx2_to_3.jsonld" , "my_spdx_document.spdx.json" ]
15+ for file in files_to_delete :
16+ output_file = os .path .join (os .path .dirname (__file__ ), file )
17+ if os .path .exists (output_file ):
18+ os .remove (output_file )
19+
20+
21+ def run_example (example_file : str ):
22+ file_path = os .path .join (os .path .dirname (__file__ ), "../../../examples/" , example_file )
23+ runpy .run_path (file_path )
24+
25+
26+ def test_spdx2_parse_file ():
27+ run_example ("spdx2_parse_file.py" )
28+
29+
30+ @pytest .mark .usefixtures ('cleanup_output_files' )
31+ def test_spdx2_convert_to_spdx3 ():
32+ run_example ("spdx2_convert_to_spdx3.py" )
33+
34+ output_file = os .path .join (os .path .dirname (__file__ ), "spdx2_to_3.jsonld" )
35+ assert os .path .exists (output_file )
36+
37+
38+ @pytest .mark .usefixtures ('cleanup_output_files' )
39+ def test_spdx2_document_from_scratch ():
40+ run_example ("spdx2_document_from_scratch.py" )
41+
42+ output_file = os .path .join (os .path .dirname (__file__ ), "my_spdx_document.spdx.json" )
43+ assert os .path .exists (output_file )
You can’t perform that action at this time.
0 commit comments