Skip to content
This repository was archived by the owner on Sep 9, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/instructlab/schema/taxonomy.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,12 @@
"""Default yamllint configuration"""


# pylint: disable=unnecessary-pass
class TaxonomyReadingException(Exception):
"""An exception raised during reading of the taxonomy."""

pass


class TaxonomyMessageFormat(enum.Enum):
"""An enum for the format choices for taxonomy parsing messages"""
Expand Down
22 changes: 21 additions & 1 deletion tests/test_parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,32 @@
import pathlib
import re
from collections.abc import Callable
from unittest.mock import patch

# Third Party
import pytest
from assertpy import assert_that

from instructlab.schema.taxonomy import TaxonomyMessageFormat, TaxonomyParser
import instructlab.schema.taxonomy # noqa: F401
from instructlab.schema.taxonomy import TaxonomyMessageFormat, TaxonomyParser, TaxonomyReadingException


class TestParserInit:
def test_parser_init_successful_when_schema_version_provided(self) -> None:
taxonomy = TaxonomyParser(schema_version=2)
assert_that(taxonomy).is_instance_of(TaxonomyParser)
assert_that(taxonomy.schema_version).is_equal_to(2)

def test_parser_init_successful_when_schema_version_not_provided_and_defaults_to_latest(self) -> None:
taxonomy = TaxonomyParser(schema_version=None)
assert_that(taxonomy.schema_version).is_equal_to(int(instructlab.schema.schema_versions()[-1].name[1:]))

@patch.object(instructlab.schema.taxonomy, "schema_versions", return_value=[])
def test_parser_init_fails_when_schema_version_not_found(self, mock_schema_versions) -> None:
with pytest.raises(TaxonomyReadingException) as exc_info:
TaxonomyParser(schema_version=None)
mock_schema_versions.assert_called_once()
assert_that(str(exc_info.value)).matches(r'Schema base ".*" does not contain any schema versions')


class TestParsingLogging:
Expand Down
Loading