You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
calculate-utils-4-lib/tests/format/test_xml_xfce.py

53 lines
2.5 KiB

import pytest
from collections import OrderedDict
from calculate.templates.format.xml_xfce_format import XMLXfceFormat
@pytest.mark.xml_xfce
class TestParsingMethods:
def test_if_input_document_contains_just_few_parameter_lines__the_initialised_object_contains_correct_dictionary(self):
document_text = '''<?xml version="1.0" encoding="UTF-8"?>
<channel name="xsettings" version="1.0">
<property name="Net" type="empty">
<property name="ThemeName" type="string" value="Calculate"/>
<property name="IconThemeName" type="string" value="Calculate"/>
<property name="DoubleClickTime" type="int" value="400"/>
</property>
<property name="Xft" type="empty">
<property name="Antialias" type="int" value="1"/>
<property name="HintStyle" type="string" value="hintmedium"/>
</property>
</channel>
'''
net_dict = OrderedDict({('', 'property', 'ThemeName', 'string'): "Calculate",
('', 'property', 'IconThemeName', 'string'): "Calculate",
('', 'property', 'DoubleClickTime', 'int'): '400'})
xft_dict = OrderedDict({('', 'property', 'Antialias', 'int'): "1",
('', 'property', 'HintStyle', 'string'): 'hintmedium'})
channel_content = OrderedDict({('', 'property', 'Net', 'empty'): net_dict,
('', 'property', 'Xft', 'empty'): xft_dict})
result = OrderedDict({('', 'channel', 'xsettings', '1.0'): channel_content})
xml_xfce_object = XMLXfceFormat(document_text)
assert xml_xfce_object._document_dictionary == result
def test_joining_documents_1(self):
with open('./tests/format/testfiles/xml_xfce_original.xml', 'r') as original_file:
original_text = original_file.read()
xml_xfce_original_object = XMLXfceFormat(original_text)
with open('./tests/format/testfiles/xml_xfce_template.xml', 'r') as template_file:
template_text = template_file.read()
xml_xfce_template_object = XMLXfceFormat(template_text)
xml_xfce_original_object.join_template(xml_xfce_template_object)
with open('./tests/format/testfiles/xml_xfce_result.xml', 'r') as result_file:
result_text = result_file.read()
assert xml_xfce_original_object.get_document_text() == result_text