def test_merge_2_1(self): # c1 overrides c2 c1 = libcomps.Comps() c1.fromxml_f("comps/comps_part1.xml") c2 = libcomps.Comps() c2.fromxml_f("comps/comps_part2.xml") self.comps += c2 self.comps += c1 merged_comps = libcomps.Comps() merged_comps.fromxml_f("comps/merged_comps_2_1.xml") self.assertEqual(self.comps.xml_str(), merged_comps.xml_str()) self.assertTrue(self.comps == merged_comps)
def test_merge_2_2(self): # second identity test c2 = libcomps.Comps() c2.fromxml_f("comps/comps_part2.xml") self.comps += c2 self.comps += c2 self.assertEqual(self.comps, c2) self.assertEqual(self.comps.xml_str(), c2.xml_str())
def test_empty_by_lang_tags(self): self.comps = libcomps.Comps() self.comps.fromxml_f("comps/comps_empty_by_lang_tags.xml") for group in self.comps.groups: self.assertEqual("{}", str(group.name_by_lang)) self.assertEqual("{}", str(group.desc_by_lang)) for category in self.comps.categories: self.assertEqual("{}", str(category.name_by_lang)) self.assertEqual("{}", str(category.desc_by_lang))
def test_merge_1_1(self): # first identity test c1 = libcomps.Comps() c1.fromxml_f("comps/comps_part1.xml") self.comps += c1 self.comps += c1 self.assertEqual(self.comps, c1) self.assertEqual(self.comps.xml_str(), c1.xml_str())
def test_add_group(self): self.comps = libcomps.Comps() group = libcomps.Group() group.id = "core" self.comps.groups.append(group) data = self.comps.xml_str( xml_options={ "empty_groups": True, "default_explicit": True, "uservisible_explicit": True }) expected_data_1 = """<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE comps PUBLIC "-//Red Hat, Inc.//DTD Comps info//EN" "comps.dtd"> <comps> <group> <id>core</id> <default>false</default> <uservisible>true</uservisible> </group> </comps> """ self.assertEqual(data, expected_data_1) group.display_order = 0 expected_data_2 = """<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE comps PUBLIC "-//Red Hat, Inc.//DTD Comps info//EN" "comps.dtd"> <comps> <group> <id>core</id> <default>false</default> <uservisible>true</uservisible> <display_order>0</display_order> </group> </comps> """ data = self.comps.xml_str( xml_options={ "empty_groups": True, "default_explicit": True, "uservisible_explicit": True }) self.assertEqual(data, expected_data_2) group.display_order = None data = self.comps.xml_str( xml_options={ "empty_groups": True, "default_explicit": True, "uservisible_explicit": True }) self.assertEqual(data, expected_data_1)
def test_duplicate_groups(self): self.comps = libcomps.Comps() group = libcomps.Group() group.id = "core" self.comps.groups.append(group) group = libcomps.Group() group.id = "core" #self.assertRaises(self.comps.groups.append(group)) #print self.comps.xml_str() self.comps.fromxml_str(self.comps.xml_str())
def setUp(self): self.maxDiff = None self.comps = libcomps.Comps()
def test_add_group_missing_id(self): self.comps = libcomps.Comps() group = libcomps.Group() self.assertRaises(ValueError, self.comps.groups.append, group)
def setUp(self): self.comps = libcomps.Comps() self.comps.fromxml_f("comps/comps-f21.xml") self.tmp_dir = tempfile.mkdtemp() self.tmp_file = os.path.join(self.tmp_dir, "comps.xml")