def test_multipleEnums_areEnumsReadCorrectly(self): xml_doc = ET.fromstring(self.xmlMultipleEnums) parsed_doc = structureparser.global_enums(xml_doc) self.assertEqual(parsed_doc[0]["values"][0]["name"], "Maybe_is_Enough") self.assertEqual(parsed_doc[1]["values"][0]["id"], 0x200)
def test_singleEnum_areEnumsReadCorrectly(self): xml_doc = ET.fromstring(self.xmlSingleEnum) enum_ast = structureparser.global_enums(xml_doc)[0]["values"][-1] self.assertEqual(enum_ast["id"], 300) self.assertEqual(enum_ast["name"], "Warmongers")
def test_multipleEnums(self): xml_doc = ET.fromstring(self.xmlMultipleEnums) parsed_doc = structureparser.global_enums(xml_doc) self.assertEqual(len(parsed_doc), 2) self.assertEqual(parsed_doc[0]["name"], "messageid_enum_multi") self.assertEqual(parsed_doc[1]["name"], "messageid_enum_2")
def test_noEnums(self): xml_doc = ET.fromstring(self.noEnums) parsed_doc = structureparser.global_enums(xml_doc) self.assertEqual(len(parsed_doc), 0)
def test_singleEnum(self): xml_doc = ET.fromstring(self.xmlSingleEnum) parsed_doc = structureparser.global_enums(xml_doc) self.assertEqual(len(parsed_doc), 1) self.assertEqual(parsed_doc[0]["name"], "messageid_enum")