This repository was archived by the owner on Sep 9, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +24
-1
lines changed
Expand file tree Collapse file tree 2 files changed +24
-1
lines changed Original file line number Diff line number Diff line change 3434"""Default yamllint configuration"""
3535
3636
37+ # pylint: disable=unnecessary-pass
3738class TaxonomyReadingException (Exception ):
3839 """An exception raised during reading of the taxonomy."""
3940
41+ pass
42+
4043
4144class TaxonomyMessageFormat (enum .Enum ):
4245 """An enum for the format choices for taxonomy parsing messages"""
Original file line number Diff line number Diff line change 66import pathlib
77import re
88from collections .abc import Callable
9+ from unittest .mock import patch
910
1011# Third Party
1112import pytest
1213from assertpy import assert_that
1314
14- from instructlab .schema .taxonomy import TaxonomyMessageFormat , TaxonomyParser
15+ import instructlab .schema .taxonomy # noqa: F401
16+ from instructlab .schema .taxonomy import TaxonomyMessageFormat , TaxonomyParser , TaxonomyReadingException
17+
18+
19+ class TestParserInit :
20+ def test_parser_init_successful_when_schema_version_provided (self ) -> None :
21+ taxonomy = TaxonomyParser (schema_version = 2 )
22+ assert_that (taxonomy ).is_instance_of (TaxonomyParser )
23+ assert_that (taxonomy .schema_version ).is_equal_to (2 )
24+
25+ def test_parser_init_successful_when_schema_version_not_provided_and_defaults_to_latest (self ) -> None :
26+ taxonomy = TaxonomyParser (schema_version = None )
27+ assert_that (taxonomy .schema_version ).is_equal_to (int (instructlab .schema .schema_versions ()[- 1 ].name [1 :]))
28+
29+ @patch .object (instructlab .schema .taxonomy , "schema_versions" , return_value = [])
30+ def test_parser_init_fails_when_schema_version_not_found (self , mock_schema_versions ) -> None :
31+ with pytest .raises (TaxonomyReadingException ) as exc_info :
32+ TaxonomyParser (schema_version = None )
33+ mock_schema_versions .assert_called_once ()
34+ assert_that (str (exc_info .value )).matches (r'Schema base ".*" does not contain any schema versions' )
1535
1636
1737class TestParsingLogging :
You can’t perform that action at this time.
0 commit comments