def test_mergeDocument_2(): """ Merge Document Test 2 With 2 levels """ etree_1 = etree.XML(""" <preference> <tag name="first_level"> <tag name="name" value="old"/> </tag> </preference> """, parser=XMLPARSER) etree_2 = etree.XML(""" <preference> <tag name="first_level"> <tag name="name" value="new"/> </tag> </preference> """, parser=XMLPARSER) answer = etree.XML(""" <preference> <tag name="first_level"> <tag name="name" value="new"/> </tag> </preference> """, parser=XMLPARSER) result = mergeDocuments(etree_1, etree_2) compare_etree(answer, result)
def test_mergeDocument_10(): """ Merge Document Test 10 Strange Case With a tag nusted under a tag with a value """ etree_1 = etree.XML(""" <preference name="Preferences" value=""> <tag name="first_level"> <tag name="name1" value="old"/> </tag> </preference> """, parser=XMLPARSER) etree_2 = etree.XML(""" <preference name="Preferences" value=""> <tag name="first_level"/> </preference> """, parser=XMLPARSER) answer = etree.XML(""" <preference> <tag name="first_level"> <tag name="name1" value="old"/> </tag> </preference> """, parser=XMLPARSER) result = mergeDocuments(etree_1, etree_2) compare_etree(answer, result)
def test_mergeDocument_1(): """ Merge Document Test 1 Simple Test """ etree_1 = etree.XML(""" <preference> <tag name="name" value="old"/> </preference> """, parser=XMLPARSER) etree_2 = etree.XML(""" <preference> <tag name="name" value="new"/> </preference> """, parser=XMLPARSER) answer = etree.XML(""" <preference> <tag name="name" value="new"/> </preference> """, parser=XMLPARSER) result = mergeDocuments(etree_1, etree_2) compare_etree(answer, result)
def test_mergeDocument_6(): """ Merge Document Test 6 Has type attributes order get mest up """ etree_1 = etree.XML(""" <preference> <tag name="test1" type="Boolean" value="true"/> <tag name="test2" type="Boolean" value="true"/> <tag name="test3" type="Boolean" value="true"/> <tag name="first_level"> <tag name="test1" type="Boolean" value="true"/> <tag name="test2" type="Boolean" value="true"/> <tag name="test3" type="Boolean" value="true"/> </tag> </preference> """, parser=XMLPARSER) etree_2 = etree.XML(""" <preference> <tag name="test1" value="false"/> <tag name="test3" type="String" value="false"/> <tag name="first_level"> <tag name="test1" value="false"/> <tag name="test3" type="String" value="false"/> </tag> </preference> """, parser=XMLPARSER) answer = etree.XML(""" <preference> <tag name="test1" type="Boolean" value="false"/> <tag name="test2" type="Boolean" value="true"/> <tag name="test3" type="Boolean" value="false"/> <tag name="first_level"> <tag name="test1" type="Boolean" value="false"/> <tag name="test2" type="Boolean" value="true"/> <tag name="test3" type="Boolean" value="false"/> </tag> </preference> """, parser=XMLPARSER) result = mergeDocuments(etree_1, etree_2) compare_etree(answer, result)
def test_mergeDocument_7(): """ Merge Document Test 7 merging uris """ etree_1 = etree.XML(""" <preference> <tag name="test1" type="Boolean" value="true" uri="http://host/data_service/00-RhsMCPzWzqd577N34mZZVC/preference/1271/tag/1277"/> <tag name="first_level" uri="http://host/data_service/00-RhsMCPzWzqd577N34mZZVC/preference/1271/tag/1278"> <tag name="test1" type="Boolean" value="true" uri="http://host/data_service/00-RhsMCPzWzqd577N34mZZVC/preference/1271/tag/1278/tag/1530"/> </tag> </preference> """, parser=XMLPARSER) etree_2 = etree.XML(""" <preference> <tag name="test1" value="false" uri="http://host/data_service/00-RhsMCPzWzqd577N34mZZVC/preference/1272/tag/1234"/> <tag name="first_level" uri="http://host/data_service/00-RhsMCPzWzqd577N34mZZVC/preference/1272/tag/1235"> <tag name="test1" value="false" uri="http://host/data_service/00-RhsMCPzWzqd577N34mZZVC/preference/1272/tag/1235/tag/1423"/> </tag> </preference> """, parser=XMLPARSER) answer = etree.XML(""" <preference> <tag name="test1" type="Boolean" value="false" uri="http://host/data_service/00-RhsMCPzWzqd577N34mZZVC/preference/1272/tag/1234"/> <tag name="first_level" uri="http://host/data_service/00-RhsMCPzWzqd577N34mZZVC/preference/1272/tag/1235"> <tag name="test1" type="Boolean" value="false" uri="http://host/data_service/00-RhsMCPzWzqd577N34mZZVC/preference/1272/tag/1235/tag/1423"/> </tag> </preference> """, parser=XMLPARSER) result = mergeDocuments(etree_1, etree_2) compare_etree(answer, result)
def test_mergeDocument_5(): """ Merge Document Test 5 Normal Use Case """ etree_1 = etree.XML(""" <preference> <tag name="test1" value="test1_old"/> <tag name="test2" value="test2_old"/> <tag name="first_level"> <tag name="test1" value="test1_old"/> <tag name="test2" value="test2_old"> <template> <tag name="template_param_1" value="template_config_1"/> <tag name="template_param_2" value="template_config_2"/> </template> </tag> <tag name="second_level"> <tag name="test1" value="test1_old"/> <tag name="test2" value="test2_old"/> </tag> </tag> </preference> """, parser=XMLPARSER) etree_2 = etree.XML(""" <preference> <tag name="test2" value="test2_new"/> <tag name="first_level"> <tag name="test1" value="test1_new"> <template> <tag name="template_param_1" value="template_config_1"/> <tag name="template_param_2" value="template_config_2"/> </template> </tag> <tag name="test2" value="test2_new"/> <tag name="second_level"> <tag name="test1" value="test1_new"/> </tag> </tag> </preference> """, parser=XMLPARSER) answer = etree.XML(""" <preference> <tag name="test1" value="test1_old"/> <tag name="test2" value="test2_new"/> <tag name="first_level"> <tag name="test1" value="test1_new"/> <tag name="test2" value="test2_new"> <template> <tag name="template_param_1" value="template_config_1"/> <tag name="template_param_2" value="template_config_2"/> </template> </tag> <tag name="second_level"> <tag name="test1" value="test1_new"/> <tag name="test2" value="test2_old"/> </tag> </tag> </preference> """, parser=XMLPARSER) result = mergeDocuments(etree_1, etree_2) compare_etree(answer, result)
def test_mergeDocument_4(): """ Merge Document Test 4 More Strange Case """ etree_1 = etree.XML(""" <preference> <template> <tag name="name" value="template_name_old"/> <tag name="type" value="template_type_old"/> </template> <tag name="first_level"> <template> <tag name="name" value="template_name"/> <tag name="type" value="template_type"/> </template> <tag name= "node1" value="value1_old"/> <tag name= "node2" value="value2_old"/> </tag> </preference> """, parser=XMLPARSER) etree_2 = etree.XML(""" <preference> <template> <tag name="name" value="template_name_new"/> <tag name="type" value="template_type_new"/> </template> <tag name="first_level"> <template> <tag name="name" value="template_name_new"/> <tag name="type" value="template_type_new"/> </template> <tag name= "node1" value="value1_new"/> </tag> </preference> """, parser=XMLPARSER) answer = etree.XML(""" <preference> <template> <tag name="name" value="template_name_old"/> <tag name="type" value="template_type_old"/> </template> <tag name="first_level"> <template> <tag name="name" value="template_name"/> <tag name="type" value="template_type"/> </template> <tag name= "node1" value="value1_new"/> <tag name= "node2" value="value2_old"/> </tag> </preference> """, parser=XMLPARSER) result = mergeDocuments(etree_1, etree_2) compare_etree(answer, result)