Skip to content

Commit

Permalink
bc: remove const output.LATEST_SUPPORTED_SCHEMA_VERSION (#494)
Browse files Browse the repository at this point in the history
Signed-off-by: Jan Kowalleck <[email protected]>
  • Loading branch information
jkowalleck authored Nov 28, 2023
1 parent e9cc5ee commit b10dc83
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 12 deletions.
2 changes: 0 additions & 2 deletions cyclonedx/output/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):

Expand Down
10 changes: 5 additions & 5 deletions examples/complex.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand All @@ -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(
Expand Down
3 changes: 1 addition & 2 deletions tests/test_deserialize_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down
5 changes: 2 additions & 3 deletions tests/test_deserialize_xml.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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)
Expand Down

0 comments on commit b10dc83

Please sign in to comment.