Allow to read multiple markup formats. Supported are XML and YAML. The parsing and transformation is based on the anymarkup module. The use of anymarkup is optional and implemented as an on demand loading module. If a user uses a yaml config file or a request to convert into yaml is made without an installed anymarkup module an exception is thrown
33 lines
1009 B
Python
33 lines
1009 B
Python
from mock import patch
|
|
from pytest import raises
|
|
|
|
from kiwi.markup.any import MarkupAny
|
|
|
|
from kiwi.exceptions import (
|
|
KiwiDescriptionInvalid,
|
|
KiwiAnyMarkupPluginError
|
|
)
|
|
|
|
|
|
class TestMarkupXML:
|
|
def setup(self):
|
|
self.markup = MarkupAny('../data/example_config.xml')
|
|
|
|
@patch('anymarkup.parse_file')
|
|
def test_raises_markup_conversion_error(self, mock_anymarkup_parse_file):
|
|
mock_anymarkup_parse_file.side_effect = Exception
|
|
with raises(KiwiDescriptionInvalid):
|
|
MarkupAny('../data/example_config.xml')
|
|
|
|
@patch('importlib.import_module')
|
|
def test_raises_anymarkup_not_available(self, mock_importlib):
|
|
mock_importlib.side_effect = Exception
|
|
with raises(KiwiAnyMarkupPluginError):
|
|
MarkupAny('../data/example_config.xml')
|
|
|
|
def test_get_xml_description(self):
|
|
assert 'xslt-' in self.markup.get_xml_description()
|
|
|
|
def test_get_yaml_description(self):
|
|
assert 'xslt-' in self.markup.get_yaml_description()
|