From b10dc83f1036d22693342ef8711502a899a3f5bb Mon Sep 17 00:00:00 2001 From: Jan Kowalleck Date: Tue, 28 Nov 2023 10:55:21 +0100 Subject: [PATCH] bc: remove const `output.LATEST_SUPPORTED_SCHEMA_VERSION` (#494) Signed-off-by: Jan Kowalleck --- cyclonedx/output/__init__.py | 2 -- examples/complex.py | 10 +++++----- tests/test_deserialize_json.py | 3 +-- tests/test_deserialize_xml.py | 5 ++--- 4 files changed, 8 insertions(+), 12 deletions(-) diff --git a/cyclonedx/output/__init__.py b/cyclonedx/output/__init__.py index 2efeecba..1b6a5d28 100644 --- a/cyclonedx/output/__init__.py +++ b/cyclonedx/output/__init__.py @@ -33,8 +33,6 @@ from .json import Json as JsonOutputter from .xml import Xml as XmlOutputter -LATEST_SUPPORTED_SCHEMA_VERSION = SchemaVersion.V1_5 - class BaseOutput(ABC): diff --git a/examples/complex.py b/examples/complex.py index 94799ec5..45e18025 100644 --- a/examples/complex.py +++ b/examples/complex.py @@ -24,8 +24,8 @@ from cyclonedx.model import OrganizationalEntity, XsUri from cyclonedx.model.bom import Bom from cyclonedx.model.component import Component, ComponentType -from cyclonedx.output import make_outputter, LATEST_SUPPORTED_SCHEMA_VERSION -from cyclonedx.output.json import JsonV1Dot4 +from cyclonedx.output import make_outputter +from cyclonedx.output.json import JsonV1Dot5 from cyclonedx.schema import SchemaVersion, OutputFormat from cyclonedx.validation.json import JsonStrictValidator from cyclonedx.validation import make_schemabased_validator @@ -79,10 +79,10 @@ # region JSON """demo with explicit instructions for SchemaVersion, outputter and validator""" -my_json_outputter: 'JsonOutputter' = JsonV1Dot4(bom) +my_json_outputter: 'JsonOutputter' = JsonV1Dot5(bom) serialized_json = my_json_outputter.output_as_string(indent=2) print(serialized_json) -my_json_validator = JsonStrictValidator(SchemaVersion.V1_4) +my_json_validator = JsonStrictValidator(SchemaVersion.V1_5) try: validation_errors = my_json_validator.validate_str(serialized_json) if validation_errors: @@ -99,7 +99,7 @@ # region XML """demo with implicit instructions for SchemaVersion, outputter and validator. TypeCheckers will catch errors.""" -my_xml_outputter: 'XmlOutputter' = make_outputter(bom, OutputFormat.XML, LATEST_SUPPORTED_SCHEMA_VERSION) +my_xml_outputter: 'XmlOutputter' = make_outputter(bom, OutputFormat.XML, SchemaVersion.V1_5) serialized_xml = my_xml_outputter.output_as_string(indent=2) print(serialized_xml) my_xml_validator: 'XmlValidator' = make_schemabased_validator( diff --git a/tests/test_deserialize_json.py b/tests/test_deserialize_json.py index 1033ed0a..75022282 100644 --- a/tests/test_deserialize_json.py +++ b/tests/test_deserialize_json.py @@ -26,7 +26,6 @@ from cyclonedx.model.bom import Bom from cyclonedx.model.license import DisjunctiveLicense, LicenseExpression, LicenseRepository -from cyclonedx.output import LATEST_SUPPORTED_SCHEMA_VERSION from cyclonedx.schema import OutputFormat, SchemaVersion from tests import OWN_DATA_DIRECTORY, DeepCompareMixin, SnapshotMixin, mksname, uuid_generator from tests._data.models import all_get_bom_funct_valid, all_get_bom_funct_with_incomplete_deps @@ -40,7 +39,7 @@ class TestDeserializeJson(TestCase, SnapshotMixin, DeepCompareMixin): @patch('cyclonedx.model.bom_ref.uuid4', side_effect=uuid_generator(0, version=4)) def test_prepared(self, get_bom: Callable[[], Bom], *_: Any, **__: Any) -> None: # only latest schema will have all data populated in serialized form - snapshot_name = mksname(get_bom, LATEST_SUPPORTED_SCHEMA_VERSION, OutputFormat.JSON) + snapshot_name = mksname(get_bom, SchemaVersion.V1_5, OutputFormat.JSON) expected = get_bom() json = json_loads(self.readSnapshot(snapshot_name)) bom = Bom.from_json(json) diff --git a/tests/test_deserialize_xml.py b/tests/test_deserialize_xml.py index ce1a25d9..141810f1 100644 --- a/tests/test_deserialize_xml.py +++ b/tests/test_deserialize_xml.py @@ -23,8 +23,7 @@ from ddt import ddt, named_data from cyclonedx.model.bom import Bom -from cyclonedx.output import LATEST_SUPPORTED_SCHEMA_VERSION -from cyclonedx.schema import OutputFormat +from cyclonedx.schema import OutputFormat, SchemaVersion from tests import DeepCompareMixin, SnapshotMixin, mksname, uuid_generator from tests._data.models import all_get_bom_funct_valid, all_get_bom_funct_with_incomplete_deps @@ -37,7 +36,7 @@ class TestDeserializeXml(TestCase, SnapshotMixin, DeepCompareMixin): @patch('cyclonedx.model.bom_ref.uuid4', side_effect=uuid_generator(0, version=4)) def test_prepared(self, get_bom: Callable[[], Bom], *_: Any, **__: Any) -> None: # only latest schema will have all data populated in serialized form - snapshot_name = mksname(get_bom, LATEST_SUPPORTED_SCHEMA_VERSION, OutputFormat.XML) + snapshot_name = mksname(get_bom, SchemaVersion.V1_5, OutputFormat.XML) expected = get_bom() with open(self.getSnapshotFile(snapshot_name), 'r') as s: bom = Bom.from_xml(s)