diff --git a/.github/workflows/install_and_test.yml b/.github/workflows/install_and_test.yml index a23887e4b..f0fae5a3c 100644 --- a/.github/workflows/install_and_test.yml +++ b/.github/workflows/install_and_test.yml @@ -32,7 +32,7 @@ jobs: - name: Run tests run: pytest - name: Run CLI - run: pyspdxtools -i ./tests/spdx/data/formats/SPDXJSONExample-v2.3.spdx.json + run: pyspdxtools -i ./tests/spdx/data/SPDXJSONExample-v2.3.spdx.json - name: Install optional dependencies run: python -m pip install networkx diff --git a/README.md b/README.md index 3aa762980..41f2580d6 100644 --- a/README.md +++ b/README.md @@ -64,7 +64,7 @@ instead of `bin`. * Use `pyspdxtools -i ` where `` is the location of the file. The input format is inferred automatically from the file ending. * If you are using a source distribution, try running: - `pyspdxtools -i tests/data/formats/SPDXJSONExample-v2.3.spdx.json` + `pyspdxtools -i tests/data/SPDXJSONExample-v2.3.spdx.json` 2. **CONVERTING** (for converting one format to another): @@ -72,10 +72,10 @@ instead of `bin`. and `` is the location of the output file. The input and output formats are inferred automatically from the file endings. * If you are using a source distribution, try running: - `pyspdxtools -i tests/data/formats/SPDXJSONExample-v2.3.spdx.json -o output.tag` + `pyspdxtools -i tests/data/SPDXJSONExample-v2.3.spdx.json -o output.tag` * If you want to skip the validation process, provide the `--novalidation` flag, like so: - `pyspdxtools -i tests/data/formats/SPDXJSONExample-v2.3.spdx.json -o output.tag --novalidation` + `pyspdxtools -i tests/data/SPDXJSONExample-v2.3.spdx.json -o output.tag --novalidation` (use this with caution: note that undetected invalid documents may lead to unexpected behavior of the tool) * For help use `pyspdxtools --help` @@ -83,13 +83,13 @@ instead of `bin`. 3. **GRAPH GENERATION** (optional feature) * This feature generates a graph representing all elements in the SPDX document and their connections based on the provided - relationships. The graph can be rendered to a picture. Below is an example for the file `tests/data/formats/SPDXJSONExample-v2.3.spdx.json`: + relationships. The graph can be rendered to a picture. Below is an example for the file `tests/data/SPDXJSONExample-v2.3.spdx.json`: ![SPDXJSONExample-v2.3.spdx.png](assets/SPDXJSONExample-v2.3.spdx.png) * Make sure you install the optional dependencies `networkx` and `pygraphviz`. To do so run `pip install ".[graph_generation]"`. * Use `pyspdxtools -i --graph -o ` where `` is an output file name with valid format for `pygraphviz` (check the documentation [here](https://pygraphviz.github.io/documentation/stable/reference/agraph.html#pygraphviz.AGraph.draw)). * If you are using a source distribution, try running - `pyspdxtools -i tests/data/formats/SPDXJSONExample-v2.3.spdx.json --graph -o SPDXJSONExample-v2.3.spdx.png` to generate + `pyspdxtools -i tests/data/SPDXJSONExample-v2.3.spdx.json --graph -o SPDXJSONExample-v2.3.spdx.png` to generate a png with an overview of the structure of the example file. ## Library usage diff --git a/tests/spdx/data/formats/SPDXJSONExample-v2.2.spdx.json b/tests/spdx/data/SPDXJSONExample-v2.2.spdx.json similarity index 100% rename from tests/spdx/data/formats/SPDXJSONExample-v2.2.spdx.json rename to tests/spdx/data/SPDXJSONExample-v2.2.spdx.json diff --git a/tests/spdx/data/formats/SPDXJSONExample-v2.3.spdx.json b/tests/spdx/data/SPDXJSONExample-v2.3.spdx.json similarity index 100% rename from tests/spdx/data/formats/SPDXJSONExample-v2.3.spdx.json rename to tests/spdx/data/SPDXJSONExample-v2.3.spdx.json diff --git a/tests/spdx/data/formats/SPDXRdfExample-v2.2.spdx.rdf.xml b/tests/spdx/data/SPDXRdfExample-v2.2.spdx.rdf.xml similarity index 100% rename from tests/spdx/data/formats/SPDXRdfExample-v2.2.spdx.rdf.xml rename to tests/spdx/data/SPDXRdfExample-v2.2.spdx.rdf.xml diff --git a/tests/spdx/data/formats/SPDXRdfExample-v2.3.spdx.rdf.xml b/tests/spdx/data/SPDXRdfExample-v2.3.spdx.rdf.xml similarity index 100% rename from tests/spdx/data/formats/SPDXRdfExample-v2.3.spdx.rdf.xml rename to tests/spdx/data/SPDXRdfExample-v2.3.spdx.rdf.xml diff --git a/tests/spdx/data/formats/SPDXTagExample-v2.2.spdx b/tests/spdx/data/SPDXTagExample-v2.2.spdx similarity index 100% rename from tests/spdx/data/formats/SPDXTagExample-v2.2.spdx rename to tests/spdx/data/SPDXTagExample-v2.2.spdx diff --git a/tests/spdx/data/formats/SPDXTagExample-v2.3.spdx b/tests/spdx/data/SPDXTagExample-v2.3.spdx similarity index 100% rename from tests/spdx/data/formats/SPDXTagExample-v2.3.spdx rename to tests/spdx/data/SPDXTagExample-v2.3.spdx diff --git a/tests/spdx/data/formats/SPDXXMLExample-v2.2.spdx.xml b/tests/spdx/data/SPDXXMLExample-v2.2.spdx.xml similarity index 100% rename from tests/spdx/data/formats/SPDXXMLExample-v2.2.spdx.xml rename to tests/spdx/data/SPDXXMLExample-v2.2.spdx.xml diff --git a/tests/spdx/data/formats/SPDXXMLExample-v2.3.spdx.xml b/tests/spdx/data/SPDXXMLExample-v2.3.spdx.xml similarity index 100% rename from tests/spdx/data/formats/SPDXXMLExample-v2.3.spdx.xml rename to tests/spdx/data/SPDXXMLExample-v2.3.spdx.xml diff --git a/tests/spdx/data/formats/SPDXYAMLExample-v2.2.spdx.yaml b/tests/spdx/data/SPDXYAMLExample-v2.2.spdx.yaml similarity index 100% rename from tests/spdx/data/formats/SPDXYAMLExample-v2.2.spdx.yaml rename to tests/spdx/data/SPDXYAMLExample-v2.2.spdx.yaml diff --git a/tests/spdx/data/formats/SPDXYAMLExample-v2.3.spdx.yaml b/tests/spdx/data/SPDXYAMLExample-v2.3.spdx.yaml similarity index 100% rename from tests/spdx/data/formats/SPDXYAMLExample-v2.3.spdx.yaml rename to tests/spdx/data/SPDXYAMLExample-v2.3.spdx.yaml diff --git a/tests/spdx/parser/all_formats/test_parse_from_file.py b/tests/spdx/parser/all_formats/test_parse_from_file.py index fe7b54f01..083e7a0fa 100644 --- a/tests/spdx/parser/all_formats/test_parse_from_file.py +++ b/tests/spdx/parser/all_formats/test_parse_from_file.py @@ -34,9 +34,7 @@ def test_parse_from_file_not_found(self, parser, format_name, extension): def test_parse_from_file_with_2_3_example(self, parser, format_name, extension): doc = parser.parse_from_file( - os.path.join( - os.path.dirname(__file__), f"../../data/formats/SPDX{format_name}Example-v2.3.spdx{extension}" - ) + os.path.join(os.path.dirname(__file__), f"../../data/SPDX{format_name}Example-v2.3.spdx{extension}") ) assert type(doc) == Document assert len(doc.annotations) == 5 @@ -48,9 +46,7 @@ def test_parse_from_file_with_2_3_example(self, parser, format_name, extension): def test_parse_json_with_2_2_example(self, parser, format_name, extension): doc = parser.parse_from_file( - os.path.join( - os.path.dirname(__file__), f"../../data/formats/SPDX{format_name}Example-v2.2.spdx{extension}" - ) + os.path.join(os.path.dirname(__file__), f"../../data/SPDX{format_name}Example-v2.2.spdx{extension}") ) assert type(doc) == Document assert len(doc.annotations) == 5 diff --git a/tests/spdx/parser/rdf/test_license_expression_parser.py b/tests/spdx/parser/rdf/test_license_expression_parser.py index 74875eefb..71772ae45 100644 --- a/tests/spdx/parser/rdf/test_license_expression_parser.py +++ b/tests/spdx/parser/rdf/test_license_expression_parser.py @@ -24,7 +24,7 @@ def test_license_expression_parser(): def test_license_expression_parser_with_coupled_licenses(): doc = rdf_parser.parse_from_file( - os.path.join(os.path.dirname(__file__), "../../data/formats/SPDXRdfExample-v2.3.spdx.rdf.xml") + os.path.join(os.path.dirname(__file__), "../../data/SPDXRdfExample-v2.3.spdx.rdf.xml") ) packages_by_spdx_id = {package.spdx_id: package for package in doc.packages} diff --git a/tests/spdx/test_graph_generation.py b/tests/spdx/test_graph_generation.py index 9128625f2..492841847 100644 --- a/tests/spdx/test_graph_generation.py +++ b/tests/spdx/test_graph_generation.py @@ -60,7 +60,7 @@ def test_generate_graph_from_spdx( edges_count: int, relationship_node_keys: List[str], ) -> None: - document = parse_file(str(Path(__file__).resolve().parent.parent / "spdx" / "data" / "formats" / file_name)) + document = parse_file(str(Path(__file__).resolve().parent.parent / "spdx" / "data" / file_name)) graph = generate_relationship_graph_from_spdx(document) assert document.creation_info.spdx_id in graph.nodes()