Switch to separate config file version
Use a separately incremented integer to track the configuration file
format version. We start with 2 due to the change that 23c3a951f6
introduced. 1 is declared to be equivalent to the original '0.10'.
The separate versioning has the advantage of being able to increment it
already during the development cycle, and using it with config files
that test/exploit the new format.
Using an integer has the advantages of a) differentiating it clearly
from the now independent kas version and b) simplifying the version
parsing. We can now also remove the string type restriction.
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
This commit is contained in:
committed by
Daniel Wagner
parent
5478e43f8a
commit
2a618686f1
@@ -34,8 +34,8 @@ from kas import includehandler
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def fixed_version(monkeypatch):
|
||||
monkeypatch.setattr(includehandler, '__version__', '0.5.0')
|
||||
monkeypatch.setattr(includehandler, '__compatible_version__', '0.5')
|
||||
monkeypatch.setattr(includehandler, '__file_version__', 5)
|
||||
monkeypatch.setattr(includehandler, '__compatible_file_version__', 4)
|
||||
|
||||
|
||||
class MockFileIO(io.StringIO):
|
||||
@@ -103,50 +103,37 @@ class TestLoadConfig(object):
|
||||
|
||||
self.util_exception_content(testvector)
|
||||
|
||||
def test_err_version_invalid_type(self):
|
||||
exception = includehandler.LoadConfigException
|
||||
testvector = [
|
||||
('header: {version: 1}', exception),
|
||||
('header: {version: a}', exception),
|
||||
('header: {version: 0.4}', exception),
|
||||
('header: {version: 0.5}', exception),
|
||||
('header: {version: 0.6}', exception),
|
||||
]
|
||||
|
||||
self.util_exception_content(testvector)
|
||||
|
||||
def test_err_version_invalid_format(self):
|
||||
exception = includehandler.LoadConfigException
|
||||
testvector = [
|
||||
('header: {version: "0.4"}', exception),
|
||||
('header: {version: "0.4.5"}', exception),
|
||||
('header: {version: "0.5a"}', exception),
|
||||
('header: {version: "0.5.a"}', exception),
|
||||
('header: {version: "0.5.4.3"}', exception),
|
||||
('header: {version: "0.50"}', exception),
|
||||
('header: {version: "0.6a"}', exception),
|
||||
('header: {version: "0.6"}', exception),
|
||||
('header: {version: "0.5"}', exception),
|
||||
('header: {version: "x"}', exception),
|
||||
('header: {version: 3}', exception),
|
||||
('header: {version: 6}', exception),
|
||||
]
|
||||
|
||||
self.util_exception_content(testvector)
|
||||
|
||||
def test_header_valid(self):
|
||||
testvector = [
|
||||
'header: {version: "0.5"}',
|
||||
'header: {version: "0.5.0"}',
|
||||
'header: {version: "0.5.1"}',
|
||||
'header: {version: "0.5.10"}',
|
||||
'header: {version: "0.5"}',
|
||||
'header: {version: "4"}',
|
||||
'header: {version: 4}',
|
||||
'header: {version: 5}',
|
||||
]
|
||||
for string in testvector:
|
||||
with patch_open(includehandler, string=string):
|
||||
includehandler.load_config('x.yml')
|
||||
|
||||
def test_compat_version(self, monkeypatch):
|
||||
monkeypatch.setattr(includehandler, '__compatible_file_version__', 1)
|
||||
with patch_open(includehandler, string='header: {version: "0.10"}'):
|
||||
includehandler.load_config('x.yml')
|
||||
|
||||
|
||||
class TestGlobalIncludes(object):
|
||||
header = '''
|
||||
header:
|
||||
version: "0.5"
|
||||
version: 5
|
||||
{}'''
|
||||
|
||||
def util_include_content(self, testvector):
|
||||
|
Reference in New Issue
Block a user